Skip to content

Commit

Permalink
Merge pull request #340 from GoogleCloudPlatform/issue339
Browse files Browse the repository at this point in the history
chore: adds debug statements to print flags #339
  • Loading branch information
srinandan authored Jan 3, 2025
2 parents c709632 + 8e9e285 commit 3f78e28
Show file tree
Hide file tree
Showing 73 changed files with 361 additions and 6 deletions.
6 changes: 5 additions & 1 deletion internal/cmd/authconfigs/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ import (
"fmt"
"internal/apiclient"
"internal/client/authconfigs"
"internal/clilog"
"internal/cloudkms"
"os"
"path"
"regexp"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// CreateCmd to create authconfigs
Expand All @@ -47,7 +49,9 @@ var CreateCmd = &cobra.Command{
if (encryptedFile != "" && encryptionKey == "") || (encryptedFile == "" && encryptionKey != "") {
return errors.New("encrypted-file and encryption-keyid must both be set")
}

cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(project)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/authconfigs/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ package authconfigs
import (
"internal/apiclient"
"internal/client/authconfigs"
"internal/clilog"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// DelCmd to get integration flow
Expand All @@ -33,6 +35,9 @@ var DelCmd = &cobra.Command{
if err = apiclient.SetRegion(region); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(project)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/authconfigs/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ package authconfigs
import (
"internal/apiclient"
"internal/client/authconfigs"
"internal/clilog"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// ExportCmd to export integrations
Expand All @@ -33,6 +35,9 @@ var ExportCmd = &cobra.Command{
if err = apiclient.SetRegion(region); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(project)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/authconfigs/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import (
"errors"
"internal/apiclient"
"internal/client/authconfigs"
"internal/clilog"
"path"
"strconv"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// GetCmd to get integration flow
Expand All @@ -44,6 +46,9 @@ var GetCmd = &cobra.Command{
if id != "" && name != "" {
return errors.New("id and name both cannot be set")
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(project)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/authconfigs/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ package authconfigs
import (
"internal/apiclient"
"internal/client/authconfigs"
"internal/clilog"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// ListCmd to list Integrations
Expand All @@ -33,6 +35,9 @@ var ListCmd = &cobra.Command{
if err = apiclient.SetRegion(region); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(project)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/authconfigs/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ package authconfigs
import (
"internal/apiclient"
"internal/client/authconfigs"
"internal/clilog"
"os"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// PatchCmd to create a new connection
Expand All @@ -34,6 +36,9 @@ var PatchCmd = &cobra.Command{
if err = apiclient.SetRegion(cmdRegion.Value.String()); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(cmdProject.Value.String())
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/certificates/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import (
"errors"
"internal/apiclient"
"internal/client/certificates"
"internal/clilog"
"os"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// CreateCmd to create authconfigs
Expand All @@ -41,7 +43,9 @@ var CreateCmd = &cobra.Command{
if passphrase != "" && privateKeyFile == "" {
return errors.New("private key must be used with passphrase")
}

cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(project)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/certificates/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ package certificates
import (
"internal/apiclient"
"internal/client/certificates"
"internal/clilog"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// DelCmd to get integration flow
Expand All @@ -33,6 +35,9 @@ var DelCmd = &cobra.Command{
if err = apiclient.SetRegion(region); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(project)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/certificates/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import (
"errors"
"internal/apiclient"
"internal/client/certificates"
"internal/clilog"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// GetCmd to get integration flow
Expand All @@ -42,6 +44,9 @@ var GetCmd = &cobra.Command{
if id != "" && name != "" {
return errors.New("id and name both cannot be set")
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(project)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/certificates/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ package certificates
import (
"internal/apiclient"
"internal/client/certificates"
"internal/clilog"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// ListCmd to list Integrations
Expand All @@ -33,6 +35,9 @@ var ListCmd = &cobra.Command{
if err = apiclient.SetRegion(region); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(project)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/connectors/cancelop.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ package connectors
import (
"internal/apiclient"
"internal/client/connections"
"internal/clilog"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// CancelOperationCmd to get connection
Expand All @@ -33,6 +35,9 @@ var CancelOperationCmd = &cobra.Command{
if err = apiclient.SetRegion(region); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(project)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/connectors/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import (
"fmt"
"internal/apiclient"
"internal/client/connections"
"internal/clilog"
"os"
"regexp"
"strconv"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// CreateCmd to create a new connection
Expand All @@ -37,6 +39,9 @@ var CreateCmd = &cobra.Command{
if err = apiclient.SetRegion(cmdRegion.Value.String()); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(cmdProject.Value.String())
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
11 changes: 9 additions & 2 deletions internal/cmd/connectors/crtcustom.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import (
"fmt"
"internal/apiclient"
"internal/client/connections"
"internal/clilog"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// CrtCustomCmd to create a new connection
Expand All @@ -38,6 +40,9 @@ var CrtCustomCmd = &cobra.Command{
if connType != "OPEN_API" && connType != "PROTO" {
return fmt.Errorf("connection type must be OPEN_API or PROTO")
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(cmdProject.Value.String())
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand All @@ -53,8 +58,10 @@ var CrtCustomCmd = &cobra.Command{
Example: `Create a custom connector for OPEN_API type: ` + GetExample(3),
}

var labels map[string]string
var connType ConnectorType
var (
labels map[string]string
connType ConnectorType
)

func init() {
var name, description, displayName string
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/connectors/crtcustomver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import (
"fmt"
"internal/apiclient"
"internal/client/connections"
"internal/clilog"
"os"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// CrtCustomVerCmd to create a new connection
Expand All @@ -35,6 +37,9 @@ var CrtCustomVerCmd = &cobra.Command{
if err = apiclient.SetRegion(cmdRegion.Value.String()); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(cmdProject.Value.String())
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/connectors/crteventsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import (
"fmt"
"internal/apiclient"
"internal/client/connections"
"internal/clilog"
"os"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// CrtEventSubCmd to create a new connection
Expand All @@ -35,6 +37,9 @@ var CrtEventSubCmd = &cobra.Command{
if err = apiclient.SetRegion(cmdRegion.Value.String()); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(cmdProject.Value.String())
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/connectors/crtzones.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ package connectors
import (
"internal/apiclient"
"internal/client/connections"
"internal/clilog"
"strings"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// CreateManagedZonesCmd to list Connections
Expand All @@ -34,6 +36,9 @@ var CreateManagedZonesCmd = &cobra.Command{
if err = apiclient.SetRegion(cmdRegion.Value.String()); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(cmdProject.Value.String())
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/connectors/delcustom.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ package connectors
import (
"internal/apiclient"
"internal/client/connections"
"internal/clilog"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// DelCustomCmd to get connection
Expand All @@ -33,6 +35,9 @@ var DelCustomCmd = &cobra.Command{
if err = apiclient.SetRegion(cmdRegion.Value.String()); err != nil {
return err
}
cmd.Flags().VisitAll(func(f *pflag.Flag) {
clilog.Debug.Printf("%s: %s\n", f.Name, f.Value)
})
return apiclient.SetProjectID(cmdProject.Value.String())
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand Down
Loading

0 comments on commit 3f78e28

Please sign in to comment.