From bbce7e844c4d0145893e39b4be57713dc165932f Mon Sep 17 00:00:00 2001 From: srinandan Date: Thu, 9 Jan 2020 21:52:35 -0800 Subject: [PATCH] flatten structure --- cmd/apis/apis.go | 3 +-- cmd/apis/{traceapi => }/crttrcapi.go | 15 ++++++++------- cmd/apis/{traceapi => }/gettrcapi.go | 19 ++++++++++--------- cmd/apis/{traceapi => }/listtrcapi.go | 13 +++++++------ cmd/apis/{traceapi => }/traceapi.go | 13 +++++-------- cmd/env/{debugmask => }/debugmask.go | 14 ++++++-------- cmd/env/env.go | 8 +++----- cmd/env/{debugmask => }/getdebugmask.go | 7 ++++--- cmd/env/getenv.go | 1 - cmd/env/{iam => }/getiam.go | 7 ++++--- cmd/env/{iam => }/iam.go | 20 ++++++++++---------- cmd/env/{iam => }/setax.go | 5 +++-- cmd/env/{debugmask => }/setdebugmask.go | 7 ++++--- cmd/env/{iam => }/setdeploy.go | 5 +++-- cmd/env/{iam => }/setsync.go | 5 +++-- cmd/env/{iam => }/testiam.go | 5 +++-- 16 files changed, 74 insertions(+), 73 deletions(-) rename cmd/apis/{traceapi => }/crttrcapi.go (80%) rename cmd/apis/{traceapi => }/gettrcapi.go (76%) rename cmd/apis/{traceapi => }/listtrcapi.go (82%) rename cmd/apis/{traceapi => }/traceapi.go (86%) rename cmd/env/{debugmask => }/debugmask.go (78%) rename cmd/env/{debugmask => }/getdebugmask.go (90%) rename cmd/env/{iam => }/getiam.go (90%) rename cmd/env/{iam => }/iam.go (71%) rename cmd/env/{iam => }/setax.go (94%) rename cmd/env/{debugmask => }/setdebugmask.go (91%) rename cmd/env/{iam => }/setdeploy.go (94%) rename cmd/env/{iam => }/setsync.go (94%) rename cmd/env/{iam => }/testiam.go (93%) diff --git a/cmd/apis/apis.go b/cmd/apis/apis.go index 3f433621..90ce8d47 100644 --- a/cmd/apis/apis.go +++ b/cmd/apis/apis.go @@ -16,7 +16,6 @@ package apis import ( "github.com/spf13/cobra" - traceapi "github.com/srinandan/apigeecli/cmd/apis/traceapi" ) //Cmd to manage apis @@ -46,5 +45,5 @@ func init() { Cmd.AddCommand(GetCmd) Cmd.AddCommand(ImpCmd) Cmd.AddCommand(UndepCmd) - Cmd.AddCommand(traceapi.Cmd) + Cmd.AddCommand(TraceCmd) } diff --git a/cmd/apis/traceapi/crttrcapi.go b/cmd/apis/crttrcapi.go similarity index 80% rename from cmd/apis/traceapi/crttrcapi.go rename to cmd/apis/crttrcapi.go index 756a6bfd..d5c776b8 100644 --- a/cmd/apis/traceapi/crttrcapi.go +++ b/cmd/apis/crttrcapi.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package traceapi +package apis import ( "github.com/spf13/cobra" @@ -21,11 +21,12 @@ import ( ) //Cmd to manage tracing of apis -var CreateCmd = &cobra.Command{ +var CreateTrcCmd = &cobra.Command{ Use: "create", Short: "Create a new debug session for an API proxy", Long: "Create a new debug session for Apigee API proxy revision deployed in an environment", Args: func(cmd *cobra.Command, args []string) (err error) { + apiclient.SetApigeeOrg(org) apiclient.SetApigeeEnv(env) return nil }, @@ -39,13 +40,13 @@ var filter map[string]string func init() { - CreateCmd.Flags().StringVarP(&name, "name", "n", + CreateTrcCmd.Flags().StringVarP(&name, "name", "n", "", "API proxy name") - CreateCmd.Flags().IntVarP(&revision, "rev", "v", + CreateTrcCmd.Flags().IntVarP(&revision, "rev", "v", -1, "API Proxy revision") - CreateCmd.Flags().StringToStringVar(&filter, "filter", + CreateTrcCmd.Flags().StringToStringVar(&filter, "filter", nil, "Filter Conditions; format is name1=value1,name2=value2...") - _ = CreateCmd.MarkFlagRequired("name") - _ = CreateCmd.MarkFlagRequired("rev") + _ = CreateTrcCmd.MarkFlagRequired("name") + _ = CreateTrcCmd.MarkFlagRequired("rev") } diff --git a/cmd/apis/traceapi/gettrcapi.go b/cmd/apis/gettrcapi.go similarity index 76% rename from cmd/apis/traceapi/gettrcapi.go rename to cmd/apis/gettrcapi.go index e236fda8..f1eca434 100644 --- a/cmd/apis/traceapi/gettrcapi.go +++ b/cmd/apis/gettrcapi.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package traceapi +package apis import ( "github.com/spf13/cobra" @@ -21,11 +21,12 @@ import ( ) //Cmd to manage tracing of apis -var GetCmd = &cobra.Command{ +var GetTrcCmd = &cobra.Command{ Use: "get", Short: "Get a debug session for an API proxy revision", Long: "Get a debug session for an API proxy revision deployed in an environment", Args: func(cmd *cobra.Command, args []string) (err error) { + apiclient.SetApigeeOrg(org) apiclient.SetApigeeEnv(env) return nil }, @@ -39,16 +40,16 @@ var sessionID, messageID string func init() { - GetCmd.Flags().StringVarP(&name, "name", "n", + GetTrcCmd.Flags().StringVarP(&name, "name", "n", "", "API proxy name") - GetCmd.Flags().IntVarP(&revision, "rev", "v", + GetTrcCmd.Flags().IntVarP(&revision, "rev", "v", -1, "API Proxy revision") - GetCmd.Flags().StringVarP(&sessionID, "ses", "s", + GetTrcCmd.Flags().StringVarP(&sessionID, "ses", "s", "", "Debug session Id") - GetCmd.Flags().StringVarP(&messageID, "msg", "m", + GetTrcCmd.Flags().StringVarP(&messageID, "msg", "m", "", "Debug session Id") - _ = GetCmd.MarkFlagRequired("name") - _ = GetCmd.MarkFlagRequired("rev") - _ = GetCmd.MarkFlagRequired("ses") + _ = GetTrcCmd.MarkFlagRequired("name") + _ = GetTrcCmd.MarkFlagRequired("rev") + _ = GetTrcCmd.MarkFlagRequired("ses") } diff --git a/cmd/apis/traceapi/listtrcapi.go b/cmd/apis/listtrcapi.go similarity index 82% rename from cmd/apis/traceapi/listtrcapi.go rename to cmd/apis/listtrcapi.go index ce7c5cdd..f2066667 100644 --- a/cmd/apis/traceapi/listtrcapi.go +++ b/cmd/apis/listtrcapi.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package traceapi +package apis import ( "github.com/spf13/cobra" @@ -21,11 +21,12 @@ import ( ) //Cmd to manage tracing of apis -var ListCmd = &cobra.Command{ +var ListTrcCmd = &cobra.Command{ Use: "list", Short: "List all debug sessions for an API proxy revision", Long: "List all debug sessions for an API proxy revision deployed in an environment", Args: func(cmd *cobra.Command, args []string) (err error) { + apiclient.SetApigeeOrg(org) apiclient.SetApigeeEnv(env) return nil }, @@ -37,12 +38,12 @@ var ListCmd = &cobra.Command{ func init() { - ListCmd.Flags().StringVarP(&name, "name", "n", + ListTrcCmd.Flags().StringVarP(&name, "name", "n", "", "API proxy name") - ListCmd.Flags().IntVarP(&revision, "rev", "v", + ListTrcCmd.Flags().IntVarP(&revision, "rev", "v", -1, "API Proxy revision") - _ = ListCmd.MarkFlagRequired("name") - _ = ListCmd.MarkFlagRequired("rev") + _ = ListTrcCmd.MarkFlagRequired("name") + _ = ListTrcCmd.MarkFlagRequired("rev") } diff --git a/cmd/apis/traceapi/traceapi.go b/cmd/apis/traceapi.go similarity index 86% rename from cmd/apis/traceapi/traceapi.go rename to cmd/apis/traceapi.go index b5cedbb5..65165ff6 100644 --- a/cmd/apis/traceapi/traceapi.go +++ b/cmd/apis/traceapi.go @@ -12,22 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -package traceapi +package apis import ( "github.com/spf13/cobra" ) //Cmd to manage tracing of apis -var Cmd = &cobra.Command{ +var TraceCmd = &cobra.Command{ Use: "trace", Short: "Manage debugging/tracing of Apigee API proxies", Long: "Manage debugging/tracing of Apigee API proxy revisions deployed in an environment", } -var env, name string -var revision int - func init() { Cmd.PersistentFlags().StringVarP(&env, "env", "e", @@ -35,7 +32,7 @@ func init() { _ = Cmd.MarkPersistentFlagRequired("env") - Cmd.AddCommand(CreateCmd) - Cmd.AddCommand(ListCmd) - Cmd.AddCommand(GetCmd) + TraceCmd.AddCommand(CreateTrcCmd) + TraceCmd.AddCommand(ListTrcCmd) + TraceCmd.AddCommand(GetTrcCmd) } diff --git a/cmd/env/debugmask/debugmask.go b/cmd/env/debugmask.go similarity index 78% rename from cmd/env/debugmask/debugmask.go rename to cmd/env/debugmask.go index ef72a4d8..d88ef6e2 100644 --- a/cmd/env/debugmask/debugmask.go +++ b/cmd/env/debugmask.go @@ -12,28 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -package debugmask +package env import ( "github.com/spf13/cobra" ) //Cmd to manage tracing of apis -var Cmd = &cobra.Command{ +var DebugCmd = &cobra.Command{ Use: "debugmask", Short: "Manage debugmasks for the environment", Long: "Manage debugmasks for the environment", } -var env string - func init() { - Cmd.PersistentFlags().StringVarP(&env, "env", "e", + DebugCmd.PersistentFlags().StringVarP(&environment, "env", "e", "", "Apigee environment name") - _ = Cmd.MarkPersistentFlagRequired("env") + _ = DebugCmd.MarkPersistentFlagRequired("env") - Cmd.AddCommand(GetCmd) - Cmd.AddCommand(SetCmd) + DebugCmd.AddCommand(GetDebugCmd) + DebugCmd.AddCommand(SetDebugCmd) } diff --git a/cmd/env/env.go b/cmd/env/env.go index a7b07fef..9ae20621 100644 --- a/cmd/env/env.go +++ b/cmd/env/env.go @@ -16,8 +16,6 @@ package env import ( "github.com/spf13/cobra" - "github.com/srinandan/apigeecli/cmd/env/debugmask" - "github.com/srinandan/apigeecli/cmd/env/iam" ) //Cmd to manage envs @@ -28,7 +26,7 @@ var Cmd = &cobra.Command{ Long: "Manage Apigee environments", } -var org string +var org, environment string func init() { @@ -39,6 +37,6 @@ func init() { Cmd.AddCommand(ListCmd) Cmd.AddCommand(GetCmd) - Cmd.AddCommand(iam.Cmd) - Cmd.AddCommand(debugmask.Cmd) + Cmd.AddCommand(IamCmd) + Cmd.AddCommand(DebugCmd) } diff --git a/cmd/env/debugmask/getdebugmask.go b/cmd/env/getdebugmask.go similarity index 90% rename from cmd/env/debugmask/getdebugmask.go rename to cmd/env/getdebugmask.go index 38b6cc69..1df90c83 100644 --- a/cmd/env/debugmask/getdebugmask.go +++ b/cmd/env/getdebugmask.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package debugmask +package env import ( "github.com/spf13/cobra" @@ -21,12 +21,13 @@ import ( ) //Cmd to manage tracing of apis -var GetCmd = &cobra.Command{ +var GetDebugCmd = &cobra.Command{ Use: "get", Short: "Get debugmasks for an Environment", Long: "Get debugmasks for an Environment", Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetApigeeEnv(env) + apiclient.SetApigeeOrg(org) + apiclient.SetApigeeEnv(environment) return nil }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/env/getenv.go b/cmd/env/getenv.go index 8ceb10d9..80c84090 100644 --- a/cmd/env/getenv.go +++ b/cmd/env/getenv.go @@ -37,7 +37,6 @@ var GetCmd = &cobra.Command{ } var config = false -var environment string func init() { diff --git a/cmd/env/iam/getiam.go b/cmd/env/getiam.go similarity index 90% rename from cmd/env/iam/getiam.go rename to cmd/env/getiam.go index f9128da9..aad29f0b 100644 --- a/cmd/env/iam/getiam.go +++ b/cmd/env/getiam.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package iam +package env import ( "github.com/spf13/cobra" @@ -21,12 +21,13 @@ import ( ) //Cmd to manage tracing of apis -var GetCmd = &cobra.Command{ +var GetIamCmd = &cobra.Command{ Use: "get", Short: "Gets the IAM policy on an Environment", Long: "Gets the IAM policy on an Environment", Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetApigeeEnv(env) + apiclient.SetApigeeOrg(org) + apiclient.SetApigeeEnv(environment) return nil }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/env/iam/iam.go b/cmd/env/iam.go similarity index 71% rename from cmd/env/iam/iam.go rename to cmd/env/iam.go index 6b0a15f5..3e3945ba 100644 --- a/cmd/env/iam/iam.go +++ b/cmd/env/iam.go @@ -12,31 +12,31 @@ // See the License for the specific language governing permissions and // limitations under the License. -package iam +package env import ( "github.com/spf13/cobra" ) //Cmd to manage tracing of apis -var Cmd = &cobra.Command{ +var IamCmd = &cobra.Command{ Use: "iam", Short: "Manage IAM permissions for the environment", Long: "Manage IAM permissions for the environment", } -var env, serviceAccountName string +var serviceAccountName string func init() { - Cmd.PersistentFlags().StringVarP(&env, "env", "e", + IamCmd.PersistentFlags().StringVarP(&environment, "env", "e", "", "Apigee environment name") - _ = Cmd.MarkPersistentFlagRequired("env") + _ = IamCmd.MarkPersistentFlagRequired("env") - Cmd.AddCommand(GetCmd) - Cmd.AddCommand(SetAxCmd) - Cmd.AddCommand(SetDepCmd) - Cmd.AddCommand(SetSyncCmd) - Cmd.AddCommand(TestIamCmd) + IamCmd.AddCommand(GetIamCmd) + IamCmd.AddCommand(SetAxCmd) + IamCmd.AddCommand(SetDepCmd) + IamCmd.AddCommand(SetSyncCmd) + IamCmd.AddCommand(TestIamCmd) } diff --git a/cmd/env/iam/setax.go b/cmd/env/setax.go similarity index 94% rename from cmd/env/iam/setax.go rename to cmd/env/setax.go index 82c036d9..3a7bab2f 100644 --- a/cmd/env/iam/setax.go +++ b/cmd/env/setax.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package iam +package env import ( "github.com/spf13/cobra" @@ -26,7 +26,8 @@ var SetAxCmd = &cobra.Command{ Short: "Set Analytics Agent role for a SA on an environment", Long: "Set Analytics Agent role for a SA an Environment", Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetApigeeEnv(env) + apiclient.SetApigeeOrg(org) + apiclient.SetApigeeEnv(environment) return nil }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/env/debugmask/setdebugmask.go b/cmd/env/setdebugmask.go similarity index 91% rename from cmd/env/debugmask/setdebugmask.go rename to cmd/env/setdebugmask.go index 083efb4d..3f9023f4 100644 --- a/cmd/env/debugmask/setdebugmask.go +++ b/cmd/env/setdebugmask.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package debugmask +package env import ( "github.com/spf13/cobra" @@ -21,12 +21,13 @@ import ( ) //Cmd to manage tracing of apis -var SetCmd = &cobra.Command{ +var SetDebugCmd = &cobra.Command{ Use: "set", Short: "Set debugmasks for an Environment", Long: "Set debugmasks for an Environment", Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetApigeeEnv(env) + apiclient.SetApigeeOrg(org) + apiclient.SetApigeeEnv(environment) return nil }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/env/iam/setdeploy.go b/cmd/env/setdeploy.go similarity index 94% rename from cmd/env/iam/setdeploy.go rename to cmd/env/setdeploy.go index 3b286b6a..e2b61285 100644 --- a/cmd/env/iam/setdeploy.go +++ b/cmd/env/setdeploy.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package iam +package env import ( "github.com/spf13/cobra" @@ -26,7 +26,8 @@ var SetDepCmd = &cobra.Command{ Short: "Set Apigee Deployer role for a SA on an environment", Long: "Set Apigee Deployer role for a SA on an environment", Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetApigeeEnv(env) + apiclient.SetApigeeOrg(org) + apiclient.SetApigeeEnv(environment) return nil }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/env/iam/setsync.go b/cmd/env/setsync.go similarity index 94% rename from cmd/env/iam/setsync.go rename to cmd/env/setsync.go index 9ea4cba4..3cf3c6c9 100644 --- a/cmd/env/iam/setsync.go +++ b/cmd/env/setsync.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package iam +package env import ( "github.com/spf13/cobra" @@ -26,7 +26,8 @@ var SetSyncCmd = &cobra.Command{ Short: "Set Synchronization Manager role for a SA on an environment", Long: "Set Synchronization Manager role for a SA on an environment", Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetApigeeEnv(env) + apiclient.SetApigeeOrg(org) + apiclient.SetApigeeEnv(environment) return nil }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/env/iam/testiam.go b/cmd/env/testiam.go similarity index 93% rename from cmd/env/iam/testiam.go rename to cmd/env/testiam.go index d7f2cdb2..a3809100 100644 --- a/cmd/env/iam/testiam.go +++ b/cmd/env/testiam.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package iam +package env import ( "github.com/spf13/cobra" @@ -26,7 +26,8 @@ var TestIamCmd = &cobra.Command{ Short: "Test IAM policy for an Environment", Long: "Test IAM policy for an Environment", Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetApigeeEnv(env) + apiclient.SetApigeeOrg(org) + apiclient.SetApigeeEnv(environment) return nil }, RunE: func(cmd *cobra.Command, args []string) (err error) {