From e3a846182881111333b401971ce5fcf0ceeebd8a Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Tue, 3 Dec 2024 15:54:53 -0700 Subject: [PATCH] cmd: updated --host flag and removed --port --- cmd/generate.go | 9 +++++---- cmd/serve.go | 9 +++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cmd/generate.go b/cmd/generate.go index c1d02af..0e480d0 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -50,8 +50,9 @@ var generateCmd = &cobra.Command{ if verbose { b, err := json.MarshalIndent(conf, "", " ") if err != nil { - fmt.Printf("failed to marshal conf: %v\n", err) + log.Error().Err(err).Printf("failed to marshal config") } + // print the config file as JSON fmt.Printf("%v\n", string(b)) } @@ -92,17 +93,17 @@ var generateCmd = &cobra.Command{ } // Generate files by supplying a list of targets as string values. Currently, -// targets are defined statically in a conf file. Targets are ran recursively +// targets are defined statically in a config file. Targets are ran recursively // if more targets are nested in a defined target, but will not run additional // child targets if it is the same as the parent. // // NOTE: This may be changed in the future how this is done. func RunTargets(conf *config.Config, args []string, targets ...string) { - // generate conf with each supplied target + // generate config with each supplied target for _, target := range targets { outputBytes, err := generator.GenerateWithTarget(conf, target) if err != nil { - log.Error().Err(err).Msg("failed to generate conf") + log.Error().Err(err).Msg("failed to generate config") os.Exit(1) } diff --git a/cmd/serve.go b/cmd/serve.go index d421538..740bef7 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -32,7 +32,7 @@ var serveCmd = &cobra.Command{ } } - // show conf as JSON and generators if verbose + // show config as JSON and generators if verbose if verbose { b, err := json.MarshalIndent(conf, "", "\t") if err != nil { @@ -44,9 +44,7 @@ var serveCmd = &cobra.Command{ // set up the routes and start the serve server := server.Server{ Config: &conf, - Server: &http.Server{ - Addr: fmt.Sprintf("%s:%d", conf.Server.Host, conf.Server.Port), - }, + Server: &http.Server{Addr: conf.Server.Host}, Jwks: server.Jwks{ Uri: conf.Server.Jwks.Uri, Retries: conf.Server.Jwks.Retries, @@ -67,8 +65,7 @@ var serveCmd = &cobra.Command{ } func init() { - serveCmd.Flags().StringVar(&conf.Server.Host, "host", conf.Server.Host, "set the server host") - serveCmd.Flags().IntVar(&conf.Server.Port, "port", conf.Server.Port, "set the server port") + serveCmd.Flags().StringVar(&conf.Server.Host, "host", conf.Server.Host, "set the server host and port") // serveCmd.Flags().StringVar(&pluginPath, "plugin", "", "set the generator plugins directory path") serveCmd.Flags().StringVar(&conf.Server.Jwks.Uri, "jwks-uri", conf.Server.Jwks.Uri, "set the JWKS url to fetch public key") serveCmd.Flags().IntVar(&conf.Server.Jwks.Retries, "jwks-fetch-retries", conf.Server.Jwks.Retries, "set the JWKS fetch retry count")