From 0ffcbb0c4bcc666a3facadd0057eb609c2d8c1cb Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Fri, 30 Jul 2021 16:50:44 -0400 Subject: [PATCH] Reserve -i for cli identity --- ziti/cmd/ziti/cmd/common/options.go | 1 + .../cmd/edge_controller/create_edge_router_policy.go | 4 ++-- .../ziti/cmd/edge_controller/create_posture_check.go | 2 +- .../create_service_edge_router_policy.go | 4 ++-- .../ziti/cmd/edge_controller/create_service_policy.go | 4 ++-- ziti/cmd/ziti/cmd/edge_controller/root.go | 10 +--------- .../cmd/edge_controller/update_authenticator_updb.go | 8 ++++---- ziti/cmd/ziti/cmd/edge_controller/update_ca.go | 2 +- .../cmd/edge_controller/update_edge_router_policy.go | 4 ++-- .../ziti/cmd/edge_controller/update_posture_check.go | 2 +- .../update_service_edge_router_policy.go | 4 ++-- .../ziti/cmd/edge_controller/update_service_policy.go | 4 ++-- 12 files changed, 21 insertions(+), 28 deletions(-) diff --git a/ziti/cmd/ziti/cmd/common/options.go b/ziti/cmd/ziti/cmd/common/options.go index 9801c74c6..625fd8445 100644 --- a/ziti/cmd/ziti/cmd/common/options.go +++ b/ziti/cmd/ziti/cmd/common/options.go @@ -36,6 +36,7 @@ type CommonOptions struct { Staging bool ConfigIdentity string Timeout int + Identity string } func (options *CommonOptions) TimeoutContext() (context.Context, context.CancelFunc) { diff --git a/ziti/cmd/ziti/cmd/edge_controller/create_edge_router_policy.go b/ziti/cmd/ziti/cmd/edge_controller/create_edge_router_policy.go index 3b6dae455..e3936db59 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/create_edge_router_policy.go +++ b/ziti/cmd/ziti/cmd/edge_controller/create_edge_router_policy.go @@ -58,8 +58,8 @@ func newCreateEdgeRouterPolicyCmd(f cmdutil.Factory, out io.Writer, errOut io.Wr // allow interspersing positional args and flags cmd.Flags().SetInterspersed(true) - cmd.Flags().StringSliceVarP(&options.edgeRouterRoles, "edge-router-roles", "e", nil, "Edge router roles of the new edge router policy") - cmd.Flags().StringSliceVarP(&options.identityRoles, "identity-roles", "i", nil, "Identity roles of the new edge router policy") + cmd.Flags().StringSliceVar(&options.edgeRouterRoles, "edge-router-roles", nil, "Edge router roles of the new edge router policy") + cmd.Flags().StringSliceVar(&options.identityRoles, "identity-roles", nil, "Identity roles of the new edge router policy") cmd.Flags().StringVar(&options.semantic, "semantic", "AllOf", "Semantic dictating how multiple attributes should be interpreted. Valid values: AnyOf, AllOf") options.AddCommonFlags(cmd) diff --git a/ziti/cmd/ziti/cmd/edge_controller/create_posture_check.go b/ziti/cmd/ziti/cmd/edge_controller/create_posture_check.go index dbf26bed7..f7102a458 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/create_posture_check.go +++ b/ziti/cmd/ziti/cmd/edge_controller/create_posture_check.go @@ -785,7 +785,7 @@ func newCreatePostureCheckMfaCmd(f cmdutil.Factory, out io.Writer, errOut io.Wri cmd.Flags().IntVarP(&options.timeoutSeconds, "seconds", "s", -1, "Seconds an MFA posture check allows before an additional MFA code must be submitted") cmd.Flags().BoolVarP(&options.promptOnWake, "wake", "w", false, "Prompt for MFA code on endpoint wake") cmd.Flags().BoolVarP(&options.promptOnUnlock, "unlock", "u", false, "Prompt for MFA code on endpoint unlock") - cmd.Flags().BoolVarP(&options.ignoreLegacyEndpoints, "ignore-legacy", "i", false, "Ignore prompts and timeout for endpoints that do not support MFA timeout/prompts") + cmd.Flags().BoolVar(&options.ignoreLegacyEndpoints, "ignore-legacy", false, "Ignore prompts and timeout for endpoints that do not support MFA timeout/prompts") options.addPostureFlags(cmd) return cmd diff --git a/ziti/cmd/ziti/cmd/edge_controller/create_service_edge_router_policy.go b/ziti/cmd/ziti/cmd/edge_controller/create_service_edge_router_policy.go index 3774301f0..58944c5b9 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/create_service_edge_router_policy.go +++ b/ziti/cmd/ziti/cmd/edge_controller/create_service_edge_router_policy.go @@ -58,8 +58,8 @@ func newCreateServiceEdgeRouterPolicyCmd(f cmdutil.Factory, out io.Writer, errOu // allow interspersing positional args and flags cmd.Flags().SetInterspersed(true) - cmd.Flags().StringSliceVarP(&options.edgeRouterRoles, "edge-router-roles", "e", nil, "Edge router roles of the new service edge router policy") - cmd.Flags().StringSliceVarP(&options.serviceRoles, "service-roles", "s", nil, "Identity roles of the new service edge router policy") + cmd.Flags().StringSliceVar(&options.edgeRouterRoles, "edge-router-roles", nil, "Edge router roles of the new service edge router policy") + cmd.Flags().StringSliceVar(&options.serviceRoles, "service-roles", nil, "Identity roles of the new service edge router policy") cmd.Flags().StringVar(&options.semantic, "semantic", "AllOf", "Semantic dictating how multiple attributes should be interpreted. Valid values: AnyOf, AllOf") options.AddCommonFlags(cmd) diff --git a/ziti/cmd/ziti/cmd/edge_controller/create_service_policy.go b/ziti/cmd/ziti/cmd/edge_controller/create_service_policy.go index 82cc12cad..478ac5756 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/create_service_policy.go +++ b/ziti/cmd/ziti/cmd/edge_controller/create_service_policy.go @@ -62,8 +62,8 @@ func newCreateServicePolicyCmd(f cmdutil.Factory, out io.Writer, errOut io.Write // allow interspersing positional args and flags cmd.Flags().SetInterspersed(true) - cmd.Flags().StringSliceVarP(&options.serviceRoles, "service-roles", "s", nil, "Service roles of the new service policy") - cmd.Flags().StringSliceVarP(&options.identityRoles, "identity-roles", "i", nil, "Identity roles of the new service policy") + cmd.Flags().StringSliceVar(&options.serviceRoles, "service-roles", nil, "Service roles of the new service policy") + cmd.Flags().StringSliceVar(&options.identityRoles, "identity-roles", nil, "Identity roles of the new service policy") cmd.Flags().StringVar(&options.semantic, "semantic", "AllOf", "Semantic dictating how multiple attributes should be interpreted. Valid values: AnyOf, AllOf") cmd.Flags().StringSliceVarP(&options.postureCheckRoles, "posture-check-roles", "p", nil, "Posture check roles of the new service policy") options.AddCommonFlags(cmd) diff --git a/ziti/cmd/ziti/cmd/edge_controller/root.go b/ziti/cmd/ziti/cmd/edge_controller/root.go index cedc446f8..aef3ea8ee 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/root.go +++ b/ziti/cmd/ziti/cmd/edge_controller/root.go @@ -30,7 +30,6 @@ import ( // NewCmdEdge creates a command object for the "controller" command func NewCmdEdge(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { cmd := util.NewEmptyParentCmd("edge", "Interact with Ziti Edge Components") - cmd.AddCommand(newCmdEdgeController(f, out, errOut)) populateEdgeCommands(f, out, errOut, cmd) return cmd } @@ -58,21 +57,14 @@ func (options *edgeOptions) ErrOutputWriter() io.Writer { return options.CommonOptions.Err } func (options *edgeOptions) AddCommonFlags(cmd *cobra.Command) { + cmd.Flags().StringVarP(&options.Identity, "cli-identity", "i", "default", "Specify the saved identity you want the CLI to use when connect to the controller with") cmd.Flags().BoolVarP(&options.OutputJSONResponse, "output-json", "j", false, "Output the full JSON response from the Ziti Edge Controller") cmd.Flags().BoolVar(&options.OutputJSONRequest, "output-request-json", false, "Output the full JSON request to the Ziti Edge Controller") cmd.Flags().IntVarP(&options.Timeout, "timeout", "", 5, "Timeout for REST operations (specified in seconds)") cmd.Flags().BoolVarP(&options.Verbose, "verbose", "", false, "Enable verbose logging") } -// newCmdEdgeController creates a command object for the "edge controller" command -func newCmdEdgeController(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { - cmd := util.NewEmptyParentCmd("controller", "Interact with a Ziti Edge Controller") - populateEdgeCommands(f, out, errOut, cmd) - return cmd -} - func populateEdgeCommands(f cmdutil.Factory, out io.Writer, errOut io.Writer, cmd *cobra.Command) *cobra.Command { - cmd.AddCommand(newCreateCmd(f, out, errOut)) cmd.AddCommand(newDeleteCmd(f, out, errOut)) cmd.AddCommand(newLoginCmd(f, out, errOut)) diff --git a/ziti/cmd/ziti/cmd/edge_controller/update_authenticator_updb.go b/ziti/cmd/ziti/cmd/edge_controller/update_authenticator_updb.go index a7c66e160..e7f3ee5ee 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/update_authenticator_updb.go +++ b/ziti/cmd/ziti/cmd/edge_controller/update_authenticator_updb.go @@ -42,9 +42,9 @@ func newUpdateAuthenticatorUpdb(idType string, options edgeOptions) *cobra.Comma edgeOptions: options, } cmd := &cobra.Command{ - Use: idType + " (-i -p ) | (-c -n )", + Use: idType + " (--identity -p ) | (-c -n )", Short: "allows an admin to set the updb authenticator of an identity or an authenticated session to update its authenticator ", - Long: "The -i and -p flags are used in conjunction to set the password of an already existing updb authenticator. The -o and -n flags are used to update the current authenticated sessions updb authenticator", + Long: "The --identity and -p flags are used in conjunction to set the password of an already existing updb authenticator. The -o and -n flags are used to update the current authenticated sessions updb authenticator", Args: cobra.ExactArgs(0), Run: func(cmd *cobra.Command, args []string) { options.Cmd = cmd @@ -58,7 +58,7 @@ func newUpdateAuthenticatorUpdb(idType string, options edgeOptions) *cobra.Comma // allow interspersing positional args and flags cmd.Flags().SetInterspersed(true) - cmd.Flags().StringVarP(&updbOptions.identity, "identity", "i", "", "The id or name of the identity to update a password for, may be used with --password (requires admin)") + cmd.Flags().StringVar(&updbOptions.identity, "identity", "", "The id or name of the identity to update a password for, may be used with --password (requires admin)") cmd.Flags().StringVarP(&updbOptions.identityPassword, "password", "p", "", "The password to set for an identity, may be used with --identity (requires admin), if not supplied a valued will be prompted for") cmd.Flags().BoolVarP(&updbOptions.self, "self", "s", false, "Specify updating a password for the currently active identity can use --old and --new to supply passwords") @@ -144,7 +144,7 @@ func setIdentityPassword(identity, password string, options edgeOptions) error { filter := fmt.Sprintf(`identity="%s" and method="updb"`, id) result, err := client.Authenticator.ListAuthenticators(&authenticator.ListAuthenticatorsParams{ - Filter: &filter, + Filter: &filter, Context: context.Background(), }, nil) diff --git a/ziti/cmd/ziti/cmd/edge_controller/update_ca.go b/ziti/cmd/ziti/cmd/edge_controller/update_ca.go index 9580586fb..3c39cbc65 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/update_ca.go +++ b/ziti/cmd/ziti/cmd/edge_controller/update_ca.go @@ -104,7 +104,7 @@ func newUpdateCaCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.C cmd.Flags().BoolVarP(&options.authEnabled, "auth", "e", false, "Whether the CA can be used for authentication or not") cmd.Flags().BoolVarP(&options.ottCaEnrollment, "ottca", "o", false, "Whether the CA can be used for one-time-token CA enrollment") cmd.Flags().BoolVarP(&options.autoCaEnrollment, "autoca", "u", false, "Whether the CA can be used for auto CA enrollment") - cmd.Flags().StringSliceVarP(&options.identityAttributes, "identity-attributes", "i", nil, "The roles to give to identities enrolled via the CA") + cmd.Flags().StringSliceVarP(&options.identityAttributes, "identity-attributes", "a", nil, "The roles to give to identities enrolled via the CA") cmd.Flags().StringVarP(&options.identityNameFormat, "identity-name-format", "f", "", "The naming format to use for identities enrolling via the CA") options.AddCommonFlags(cmd) return cmd diff --git a/ziti/cmd/ziti/cmd/edge_controller/update_edge_router_policy.go b/ziti/cmd/ziti/cmd/edge_controller/update_edge_router_policy.go index d329f857c..1170a0457 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/update_edge_router_policy.go +++ b/ziti/cmd/ziti/cmd/edge_controller/update_edge_router_policy.go @@ -60,8 +60,8 @@ func newUpdateEdgeRouterPolicyCmd(f cmdutil.Factory, out io.Writer, errOut io.Wr // allow interspersing positional args and flags cmd.Flags().SetInterspersed(true) cmd.Flags().StringVarP(&options.name, "name", "n", "", "Set the name of the edge router policy") - cmd.Flags().StringSliceVarP(&options.edgeRouterRoles, "edge-router-roles", "e", nil, "Edge router roles of the edge router policy") - cmd.Flags().StringSliceVarP(&options.identityRoles, "identity-roles", "i", nil, "Identity roles of the edge router policy") + cmd.Flags().StringSliceVar(&options.edgeRouterRoles, "edge-router-roles", nil, "Edge router roles of the edge router policy") + cmd.Flags().StringSliceVar(&options.identityRoles, "identity-roles", nil, "Identity roles of the edge router policy") options.AddCommonFlags(cmd) return cmd diff --git a/ziti/cmd/ziti/cmd/edge_controller/update_posture_check.go b/ziti/cmd/ziti/cmd/edge_controller/update_posture_check.go index 526357d72..71d9d6b1b 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/update_posture_check.go +++ b/ziti/cmd/ziti/cmd/edge_controller/update_posture_check.go @@ -222,7 +222,7 @@ func newUpdatePostureCheckMfaCmd(f cmdutil.Factory, out io.Writer, errOut io.Wri cmd.Flags().BoolVarP(&options.promptOnUnlock, "unlock", "u", false, "Prompt for MFA code on endpoint unlock") cmd.Flags().BoolVarP(&options.promptOnUnlock, "no-unlock", "q", false, "Do not prompt for MFA code on endpoint unlock") - cmd.Flags().BoolVarP(&options.ignoreLegacyEndpoints, "ignore-legacy", "i", false, "Ignore prompts and timeout for endpoints that do not support MFA timeout/prompts") + cmd.Flags().BoolVar(&options.ignoreLegacyEndpoints, "ignore-legacy", false, "Ignore prompts and timeout for endpoints that do not support MFA timeout/prompts") cmd.Flags().BoolVarP(&options.ignoreLegacyEndpoints, "no-ignore-legacy", "l", false, "Do not ignore prompts and timeout for endpoints that do not support MFA timeout/prompts") cmd.Flags().StringSliceVarP(&options.roleAttributes, "role-attributes", "a", nil, "Set role attributes of the posture check. Use --role-attributes '' to set an empty list") diff --git a/ziti/cmd/ziti/cmd/edge_controller/update_service_edge_router_policy.go b/ziti/cmd/ziti/cmd/edge_controller/update_service_edge_router_policy.go index 06802cd16..9ae304e4f 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/update_service_edge_router_policy.go +++ b/ziti/cmd/ziti/cmd/edge_controller/update_service_edge_router_policy.go @@ -60,8 +60,8 @@ func newUpdateServiceEdgeRouterPolicyCmd(f cmdutil.Factory, out io.Writer, errOu // allow interspersing positional args and flags cmd.Flags().SetInterspersed(true) cmd.Flags().StringVarP(&options.name, "name", "n", "", "Set the name of the edge router policy") - cmd.Flags().StringSliceVarP(&options.edgeRouterRoles, "edge-router-roles", "e", nil, "Edge router roles of the service edge router policy") - cmd.Flags().StringSliceVarP(&options.serviceRoles, "service-roles", "s", nil, "Service roles of the service edge router policy") + cmd.Flags().StringSliceVar(&options.edgeRouterRoles, "edge-router-roles", nil, "Edge router roles of the service edge router policy") + cmd.Flags().StringSliceVar(&options.serviceRoles, "service-roles", nil, "Service roles of the service edge router policy") options.AddCommonFlags(cmd) return cmd diff --git a/ziti/cmd/ziti/cmd/edge_controller/update_service_policy.go b/ziti/cmd/ziti/cmd/edge_controller/update_service_policy.go index c77f702cd..9bc6e5a57 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/update_service_policy.go +++ b/ziti/cmd/ziti/cmd/edge_controller/update_service_policy.go @@ -61,8 +61,8 @@ func newUpdateServicePolicyCmd(f cmdutil.Factory, out io.Writer, errOut io.Write // allow interspersing positional args and flags cmd.Flags().SetInterspersed(true) cmd.Flags().StringVarP(&options.name, "name", "n", "", "Set the name of the service policy") - cmd.Flags().StringSliceVarP(&options.serviceRoles, "service-roles", "s", nil, "Service roles of the service policy") - cmd.Flags().StringSliceVarP(&options.identityRoles, "identity-roles", "i", nil, "Identity roles of the service policy") + cmd.Flags().StringSliceVar(&options.serviceRoles, "service-roles", nil, "Service roles of the service policy") + cmd.Flags().StringSliceVar(&options.identityRoles, "identity-roles", nil, "Identity roles of the service policy") cmd.Flags().StringSliceVarP(&options.postureCheckRoles, "posture-check-roles", "p", nil, "Posture Check roles of the service policy") options.AddCommonFlags(cmd)