Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
flatten structure
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Jan 10, 2020
1 parent a871bd5 commit bbce7e8
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 73 deletions.
3 changes: 1 addition & 2 deletions cmd/apis/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package apis

import (
"github.com/spf13/cobra"
traceapi "github.com/srinandan/apigeecli/cmd/apis/traceapi"
)

//Cmd to manage apis
Expand Down Expand Up @@ -46,5 +45,5 @@ func init() {
Cmd.AddCommand(GetCmd)
Cmd.AddCommand(ImpCmd)
Cmd.AddCommand(UndepCmd)
Cmd.AddCommand(traceapi.Cmd)
Cmd.AddCommand(TraceCmd)
}
15 changes: 8 additions & 7 deletions cmd/apis/traceapi/crttrcapi.go → cmd/apis/crttrcapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
},
Expand All @@ -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")
}
19 changes: 10 additions & 9 deletions cmd/apis/traceapi/gettrcapi.go → cmd/apis/gettrcapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
},
Expand All @@ -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")
}
13 changes: 7 additions & 6 deletions cmd/apis/traceapi/listtrcapi.go → cmd/apis/listtrcapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
},
Expand All @@ -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")

}
13 changes: 5 additions & 8 deletions cmd/apis/traceapi/traceapi.go → cmd/apis/traceapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,27 @@
// 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",
"", "Apigee environment name")

_ = Cmd.MarkPersistentFlagRequired("env")

Cmd.AddCommand(CreateCmd)
Cmd.AddCommand(ListCmd)
Cmd.AddCommand(GetCmd)
TraceCmd.AddCommand(CreateTrcCmd)
TraceCmd.AddCommand(ListTrcCmd)
TraceCmd.AddCommand(GetTrcCmd)
}
14 changes: 6 additions & 8 deletions cmd/env/debugmask/debugmask.go → cmd/env/debugmask.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
8 changes: 3 additions & 5 deletions cmd/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,7 +26,7 @@ var Cmd = &cobra.Command{
Long: "Manage Apigee environments",
}

var org string
var org, environment string

func init() {

Expand All @@ -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)
}
7 changes: 4 additions & 3 deletions cmd/env/debugmask/getdebugmask.go → cmd/env/getdebugmask.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion cmd/env/getenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ var GetCmd = &cobra.Command{
}

var config = false
var environment string

func init() {

Expand Down
7 changes: 4 additions & 3 deletions cmd/env/iam/getiam.go → cmd/env/getiam.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down
20 changes: 10 additions & 10 deletions cmd/env/iam/iam.go → cmd/env/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
5 changes: 3 additions & 2 deletions cmd/env/iam/setax.go → cmd/env/setax.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down
7 changes: 4 additions & 3 deletions cmd/env/debugmask/setdebugmask.go → cmd/env/setdebugmask.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down
Loading

0 comments on commit bbce7e8

Please sign in to comment.