From 03b796312ada292e3fd2c4ccc5d82af5a766dc62 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Sun, 17 Nov 2024 16:02:13 -0800 Subject: [PATCH] cli: gate grpc client and auth flags behind feature flag Previously the holos render platform and component subcommands had flags for oidc authentication and client access to the gRPC service. These flags aren't currently used, they're remnants from the json powered form prototype. This patch gates the flags behind a feature flag which is disabled by default. Result: holos render platform --help render an entire platform Usage: holos render platform DIRECTORY [flags] Examples: holos render platform ./platform Flags: --concurrency int number of components to render concurrently (default 8) -v, --version version for platform Global Flags: --log-drop strings log attributes to drop (example "user-agent,version") --log-format string log format (text|json|console) (default "console") --log-level string log level (debug|info|warn|error) (default "info") --- HOLOS_FEATURE_CLIENT=1 holos render platform --help render an entire platform Usage: holos render platform DIRECTORY [flags] Examples: holos render platform ./platform Flags: --concurrency int number of components to render concurrently (default 8) --oidc-client-id string oidc client id. (default "270319630705329162@holos_platform") --oidc-extra-scopes strings optional oidc scopes --oidc-force-refresh force refresh --oidc-issuer string oidc token issuer url. (default "https://login.holos.run") --oidc-scopes strings required oidc scopes (default openid,email,profile,groups,offline_access) --server string server to connect to (default "https://app.holos.run:443") -v, --version version for platform Global Flags: --log-drop strings log attributes to drop (example "user-agent,version") --log-format string log format (text|json|console) (default "console") --log-level string log level (debug|info|warn|error) (default "info") --- internal/cli/render/render.go | 20 ++++++++++++-------- internal/holos/types.go | 1 + version/embedded/patch | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/internal/cli/render/render.go b/internal/cli/render/render.go index cebe6e6c..2af430c9 100644 --- a/internal/cli/render/render.go +++ b/internal/cli/render/render.go @@ -28,13 +28,13 @@ func New(cfg *holos.Config, feature holos.Flagger) *cobra.Command { cmd := command.New("render") cmd.Args = cobra.NoArgs cmd.Short = "render platforms and components to manifest files" - cmd.AddCommand(NewComponent(cfg)) - cmd.AddCommand(NewPlatform(cfg)) + cmd.AddCommand(NewComponent(cfg, feature)) + cmd.AddCommand(NewPlatform(cfg, feature)) return cmd } // New returns the component subcommand for the render command -func NewComponent(cfg *holos.Config) *cobra.Command { +func NewComponent(cfg *holos.Config, feature holos.Flagger) *cobra.Command { cmd := command.New("component DIRECTORY") cmd.Args = cobra.ExactArgs(1) cmd.Short = "render a platform component" @@ -43,8 +43,10 @@ func NewComponent(cfg *holos.Config) *cobra.Command { cmd.Flags().AddGoFlagSet(cfg.ClusterFlagSet()) config := client.NewConfig(cfg) - cmd.PersistentFlags().AddGoFlagSet(config.ClientFlagSet()) - cmd.PersistentFlags().AddGoFlagSet(config.TokenFlagSet()) + if feature.Flag(holos.ClientFeature) { + cmd.PersistentFlags().AddGoFlagSet(config.ClientFlagSet()) + cmd.PersistentFlags().AddGoFlagSet(config.TokenFlagSet()) + } flagSet := flag.NewFlagSet("", flag.ContinueOnError) @@ -176,15 +178,17 @@ func NewComponent(cfg *holos.Config) *cobra.Command { return cmd } -func NewPlatform(cfg *holos.Config) *cobra.Command { +func NewPlatform(cfg *holos.Config, feature holos.Flagger) *cobra.Command { cmd := command.New("platform DIRECTORY") cmd.Args = cobra.ExactArgs(1) cmd.Example = " holos render platform ./platform" cmd.Short = "render an entire platform" config := client.NewConfig(cfg) - cmd.PersistentFlags().AddGoFlagSet(config.ClientFlagSet()) - cmd.PersistentFlags().AddGoFlagSet(config.TokenFlagSet()) + if feature.Flag(holos.ClientFeature) { + cmd.PersistentFlags().AddGoFlagSet(config.ClientFlagSet()) + cmd.PersistentFlags().AddGoFlagSet(config.TokenFlagSet()) + } var concurrency int cmd.Flags().IntVar(&concurrency, "concurrency", min(runtime.NumCPU(), 8), "number of components to render concurrently") diff --git a/internal/holos/types.go b/internal/holos/types.go index 6b507b7d..ce1e694c 100644 --- a/internal/holos/types.go +++ b/internal/holos/types.go @@ -31,6 +31,7 @@ type feature string const BuildFeature = feature("BUILD") const ServerFeature = feature("SERVER") +const ClientFeature = feature("CLIENT") const PreflightFeature = feature("PREFLIGHT") const GenerateComponentFeature = feature("GENERATE_COMPONENT") const SecretsFeature = feature("SECRETS") diff --git a/version/embedded/patch b/version/embedded/patch index 0cfbf088..00750edc 100644 --- a/version/embedded/patch +++ b/version/embedded/patch @@ -1 +1 @@ -2 +3