refactor: name changes and code clean up
This commit is contained in:
parent
b31056f297
commit
32065dc163
5 changed files with 134 additions and 135 deletions
|
|
@ -25,11 +25,11 @@ var fetchCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
// check to see if an access token is available from env
|
||||
if config.AccessToken == "" {
|
||||
if conf.AccessToken == "" {
|
||||
// check if OCHAMI_ACCESS_TOKEN env var is set if no access token is provided and use that instead
|
||||
accessToken := os.Getenv("ACCESS_TOKEN")
|
||||
if accessToken != "" {
|
||||
config.AccessToken = accessToken
|
||||
conf.AccessToken = accessToken
|
||||
} else {
|
||||
// TODO: try and fetch token first if it is needed
|
||||
if verbose {
|
||||
|
|
@ -46,7 +46,7 @@ var fetchCmd = &cobra.Command{
|
|||
|
||||
for _, target := range targets {
|
||||
// make a request for each target
|
||||
url := fmt.Sprintf("%s:%d/generate?target=%s", remoteHost, remotePort, target)
|
||||
url := fmt.Sprintf("%s/generate?target=%s", remoteHost, target)
|
||||
res, body, err := util.MakeRequest(url, http.MethodGet, nil, headers)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("failed to make request")
|
||||
|
|
@ -63,8 +63,7 @@ var fetchCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
func init() {
|
||||
fetchCmd.Flags().StringVar(&remoteHost, "host", "", "set the remote configurator host")
|
||||
fetchCmd.Flags().IntVar(&remotePort, "port", 3334, "set the remote configurator port")
|
||||
fetchCmd.Flags().StringVar(&remoteHost, "host", "", "set the remote configurator host and port")
|
||||
fetchCmd.Flags().StringSliceVar(&targets, "target", nil, "set the target configs to make")
|
||||
fetchCmd.Flags().StringVarP(&outputPath, "output", "o", "", "set the output path for config targets")
|
||||
fetchCmd.Flags().StringVar(&accessToken, "access-token", "o", "set the output path for config targets")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue