You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/02/01 06:55:35 UTC

[GitHub] [apisix-dashboard] starsz opened a new issue #1406: ManagerAPI should support -c to set the config file.

starsz opened a new issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406


   # Feature request
   
   ## Please describe your feature
   
   Now the manager API use cobra to manage CLI interactions.So I think we can support "-c" to set the config file.
   
   ## Describe the solution you'd like
   
   Support "-c" to set the config file.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] vinayaksh42 commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
vinayaksh42 commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-771915285


   Hey, can I give this issue a try?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] vinayaksh42 commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
vinayaksh42 commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772796540


   When we are running it from the output folder then we are one level below in the file structure because of which the "couldn't open sink" error is given. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] starsz commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
starsz commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772542324


   > Can you guide me on how can i interact with the cli?
   
   Of course.
   
   First, `make api-run` is used for `dry-run` as you can see.
   So we wouldn't use it in a production environment.
   We should do `./api/build.sh` to build the binary of manger-api. Like this:
   
   ```
   ./api/build.sh
   + export ENV=local
   + ENV=local
   ++ pwd
   + pwd=/Users/peter/Work/project/apisix-dashboard
   + rm -rf output
   + mkdir -p output/conf
   + mkdir -p output/dag-to-lua
   + [[ ! -f dag-to-lua-1.1/lib/dag-to-lua.lua ]]
   ....
   + cp -r /tmp/dag-to-lua-1.1/lib/cli.lua /tmp/dag-to-lua-1.1/lib/dag-to-lua.lua /tmp/dag-to-lua-1.1/lib/json.lua ./output/dag-to-lua
   + cd ./api
   + go build -o ../output/manager-api -ldflags '-X github.com/apisix/manager-api/cmd.Version=master -X github.com/apisix/manager-api/cmd.GitHash=0a0a42a' ./cmd/manager
   + cd ..
   + cp ./api/conf/schema.json ./output/conf/schema.json
   + cp ./api/conf/conf.yaml ./output/conf/conf.yaml
   + echo 'Build the Manager API successfully'
   Build the Manager API successfully
   
   ```
   Then we can get the binary of manager-api at the `output` directory.
   
   ```
   ➜ cd output && ls
   conf        dag-to-lua  manager-api
   ```
   
   We can do `./manger-api -h` to see the help info.
   
   ```
   ./manager-api -h
   APISIX Manager API
   
   Usage:
     manager-api [flags]
     manager-api [command]
   
   Available Commands:
     help        Help about any command
     stop
   
   Flags:
     -h, --help              help for manager-api
     -p, --work-dir string   current work directory (default ".")
   
   Use "manager-api [command] --help" for more information about a command.
   ```
   
   The purpose of this issue is that we want to support "-c" command so that we can set the config path through the cli.
   
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] vinayaksh42 commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
vinayaksh42 commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772272620


   @starsz is this the [file](https://github.com/apache/apisix-dashboard/blob/master/api/cmd/managerapi.go) in which I am supposed to make the changes?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] vinayaksh42 commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
vinayaksh42 commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-773609569


   > > When we are running it from the output folder then we are one level below in the file structure because of which the "couldn't open sink" error is given.
   > 
   > I think now we should provide the `work_dir` and `conf path` both.
   > 
   > Please have try like:
   > 
   > `./output/manager-api -p ./api -c ./api/conf/conf.yaml`
   
   This seems to be working perfectly
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] zaunist commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
zaunist commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-950487844


   @juzhiyuan It looks like this feature is already supported in the latest release https://github.com/apache/apisix-dashboard/blob/05e10ffda9dda2e6cbf79af3809b65b50c4ec689/api/cmd/root.go#L54


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] vinayaksh42 commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
vinayaksh42 commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-773023455


   > > When we are running it from the output folder then we are one level below in the file structure because of which the "couldn't open sink" error is given.
   > 
   > I think now we should provide the `work_dir` and `conf path` both.
   > 
   > Please have try like:
   > 
   > `./output/manager-api -p ./api -c ./api/conf/conf.yaml`
   
   Will give this a try
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] starsz commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
starsz commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772285692


   > @starsz is this the [file](https://github.com/apache/apisix-dashboard/blob/master/api/cmd/managerapi.go) in which I am supposed to make the changes?
   
   Yes, you are right.
   First, you should be familiar with this lib [cobra](https://github.com/spf13/cobra).
   And then add `-c` flag like this: https://github.com/apache/apisix-dashboard/blob/0a0a42ae1c81f21a03c98a991b707dba6b724364/api/cmd/managerapi.go#L134
   
   to set the config path which is used in 
   https://github.com/apache/apisix-dashboard/blob/0a0a42ae1c81f21a03c98a991b707dba6b724364/api/internal/conf/conf.go#L127.
   
   Much appreciated.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] starsz commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
starsz commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772979160


   > When we are running it from the output folder then we are one level below in the file structure because of which the "couldn't open sink" error is given.
   
   I think now we should provide the `work_dir` and `conf path` both.
   
   Please have try like: 
   
   `
   ./output/manager-api -p ./api -c ./api/conf/conf.yaml
   `


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] vinayaksh42 commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
vinayaksh42 commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772533164


   @starsz 
   i am getting the following output on running the make api-run command:
   ```css
   vinayak@vinayak-B150M-D3H:~/github/apisix-dashboard$ make api-run
   api/build.sh --dry-run
   The manager-api is running successfully!
   
   Version : master
   GitHash : 6e98820
   Listen  : 127.0.0.1:9000
   Loglevel: warn
   Logfile : /home/vinayak/github/apisix-dashboard/api/logs/error.log
   ```
   Can you guide me on how can i interact with the cli?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] nic-chen commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
nic-chen commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772085795


   @vinayaksh42  absolutely,thanks!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] bzp2010 closed issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
bzp2010 closed issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] starsz edited a comment on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
starsz edited a comment on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772542324


   > Can you guide me on how can i interact with the cli?
   
   @vinayaksh42 .Of course.
   
   First, `make api-run` is used for `dry-run` as you can see.
   So we wouldn't use it in a production environment.
   We should do `./api/build.sh` to build the binary of manger-api. Like this:
   
   ```
   ./api/build.sh
   + export ENV=local
   + ENV=local
   ++ pwd
   + pwd=/Users/peter/Work/project/apisix-dashboard
   + rm -rf output
   + mkdir -p output/conf
   + mkdir -p output/dag-to-lua
   + [[ ! -f dag-to-lua-1.1/lib/dag-to-lua.lua ]]
   ....
   + cp -r /tmp/dag-to-lua-1.1/lib/cli.lua /tmp/dag-to-lua-1.1/lib/dag-to-lua.lua /tmp/dag-to-lua-1.1/lib/json.lua ./output/dag-to-lua
   + cd ./api
   + go build -o ../output/manager-api -ldflags '-X github.com/apisix/manager-api/cmd.Version=master -X github.com/apisix/manager-api/cmd.GitHash=0a0a42a' ./cmd/manager
   + cd ..
   + cp ./api/conf/schema.json ./output/conf/schema.json
   + cp ./api/conf/conf.yaml ./output/conf/conf.yaml
   + echo 'Build the Manager API successfully'
   Build the Manager API successfully
   
   ```
   Then we can get the binary of manager-api at the `output` directory.
   
   ```
   ➜ cd output && ls
   conf        dag-to-lua  manager-api
   ```
   
   We can do `./manger-api -h` to see the help info.
   
   ```
   ./manager-api -h
   APISIX Manager API
   
   Usage:
     manager-api [flags]
     manager-api [command]
   
   Available Commands:
     help        Help about any command
     stop
   
   Flags:
     -h, --help              help for manager-api
     -p, --work-dir string   current work directory (default ".")
   
   Use "manager-api [command] --help" for more information about a command.
   ```
   
   The purpose of this issue is that we want to support "-c" command so that we can set the config path through the cli.
   
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] vinayaksh42 commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
vinayaksh42 commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772616248


   i have added the following code in the managerapi.go
   ```css
   cmd.PersistentFlags().StringVarP(&conf.FilePath, "filepath","c", conf.FilePath, "Config file path")
   ```
   upon running the command 
   ```css
   ./manager-api -c ./api/conf/test.yaml
   ```
   i get the response 
   ```
   panic: couldn't open sink "/home/vinayak/github/apisix-dashboard/output/logs/error.log": open /home/vinayak/github/apisix-dashboard/output/logs/error.log: no such file or directory
   ```
   even tho i have made a test.yaml file in the conf folder.
   
   I am not sure if i am right or not but when i run 
   ```
   ./manager-api -p ../
   ```
   it returns the same error as the above one 
   ```
   panic: couldn't open sink "/home/vinayak/github/apisix-dashboard/output/logs/error.log": open /home/vinayak/github/apisix-dashboard/output/logs/error.log: no such file or directory
   ```
   but when i run 
   ```css
   ./manager-api -p ../api/
   ```
   the manager-api starts without any issue or error
   ```
   The manager-api is running successfully!
   
   Version : master
   GitHash : 6e98820
   Listen  : 127.0.0.1:9000
   Loglevel: warn
   Logfile : /home/vinayak/github/apisix-dashboard/api/logs/error.log
   ```
   I think there is some fault with the working directory command cause ultimately we have the following line of code for the config file path
   ```go
   filePath := WorkDir + "/conf/conf.json"
   ```
   I have added a filepath variable for collecting the new filepath which will be supplied by the flag. Should i make a Work-in-progress pr for this?
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] imjoey commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
imjoey commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772544956


   > Can you guide me on how can i interact with the cli?
   
   Hi @vinayaksh42 , the command `go run ./cmd/manager` under `./api` directory would start the manager-api locally. If additional flag `-h` is specified, it will provide with more detailed usage on the `manager-api` command. Please see the following example.
   
   ```
   ➜  api git:(master) go run ./cmd/manager
   The manager-api is running successfully!
   
   Version :
   GitHash :
   Listen  : 127.0.0.1:9000
   Loglevel: warn
   Logfile : /Users/imjoey/Work/apache-apisix/apisix-dashboard/api/logs/error.log
   ```
   
   ```
   ➜  api git:(master) go run ./cmd/manager -h
   APISIX Manager API
   
   Usage:
     manager-api [flags]
     manager-api [command]
   
   Available Commands:
     help        Help about any command
     stop
   
   Flags:
     -h, --help              help for manager-api
     -p, --work-dir string   current work directory (default ".")
   
   Use "manager-api [command] --help" for more information about a command.
   
   ```
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] vinayaksh42 commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
vinayaksh42 commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-771915285


   Hey, can I give this issue a try?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] nic-chen commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
nic-chen commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772085795


   @vinayaksh42  absolutely,thanks!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] starsz commented on issue #1406: ManagerAPI should support -c to set the config file.

Posted by GitBox <gi...@apache.org>.
starsz commented on issue #1406:
URL: https://github.com/apache/apisix-dashboard/issues/1406#issuecomment-772263725


   > Hey, can I give this issue a try?
   
   Pretty good. I am so glad to hear that.
   If you encounter any problems, please contact us.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org