Skip to content

Commit

Permalink
Changes to param names to make datastores and securityprofiles work
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtkanaskie committed Dec 1, 2023
1 parent 3241919 commit c90226c
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/datastores/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ var ListCmd = &cobra.Command{
}

func init() {
ListCmd.Flags().StringVarP(&targetType, "name", "n",
ListCmd.Flags().StringVarP(&targetType, "targettype", "",
"", "TargetType is used to fetch datastores of matching type; default is fetch all")
}
2 changes: 0 additions & 2 deletions cmd/datastores/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ var TestCmd = &cobra.Command{
var id string

func init() {
TestCmd.Flags().StringVarP(&id, "id", "i",
"", "Data store id")
TestCmd.Flags().StringVarP(&name, "name", "n",
"", "Display name for the data store")
TestCmd.Flags().StringVarP(&targetType, "target", "",
Expand Down
3 changes: 3 additions & 0 deletions cmd/securityprofiles/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ func init() {
"", "Apigee environment name")
AttachCmd.Flags().StringVarP(&revision, "rev", "r",
"", "Security Profile revision id")
_ = AttachCmd.MarkFlagRequired("name")
_ = AttachCmd.MarkFlagRequired("env")
_ = AttachCmd.MarkFlagRequired("rev")
}
2 changes: 1 addition & 1 deletion cmd/securityprofiles/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var securityActionFile string

func init() {
CreateCmd.Flags().StringVarP(&name, "name", "n",
"", "Security Action name")
"", "Name of the security profile")
CreateCmd.Flags().StringVarP(&securityActionFile, "file", "f",
"", "Path to a file containing Security Profile content")
_ = CreateCmd.MarkFlagRequired("name")
Expand Down
1 change: 1 addition & 0 deletions cmd/securityprofiles/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ var DeleteCmd = &cobra.Command{
func init() {
DeleteCmd.Flags().StringVarP(&name, "name", "n",
"", "Name of the security profile")
_ = DeleteCmd.MarkFlagRequired("name")
}
8 changes: 5 additions & 3 deletions cmd/securityprofiles/detach.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (

// DetachCmd to list catalog items
var DetachCmd = &cobra.Command{
Use: "get",
Short: "Returns a security profile by name",
Long: "Returns a security profile by name",
Use: "detach",
Short: "Detach a security profile from an environment",
Long: "Detach a security profile from an environment",
Args: func(cmd *cobra.Command, args []string) (err error) {
apiclient.SetApigeeEnv(environment)
return apiclient.SetApigeeOrg(org)
Expand All @@ -41,4 +41,6 @@ func init() {
"", "Name of the security profile")
DetachCmd.Flags().StringVarP(&environment, "env", "e",
"", "Apigee environment name")
_ = DetachCmd.MarkFlagRequired("name")
_ = DetachCmd.MarkFlagRequired("env")
}
1 change: 1 addition & 0 deletions cmd/securityprofiles/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ var name string
func init() {
GetCmd.Flags().StringVarP(&name, "name", "n",
"", "Name of the security profile")
_ = GetCmd.MarkFlagRequired("name")
}
5 changes: 3 additions & 2 deletions cmd/securityprofiles/listrevisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ import (

// ListRevisionsCmd to list catalog items
var ListRevisionsCmd = &cobra.Command{
Use: "listversions",
Use: "listrevisions",
Short: "Returns the revisions of a security profile",
Long: "Returns the revisions of a security profile",
Args: func(cmd *cobra.Command, args []string) (err error) {
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
_, err = securityprofiles.ListVersions(name)
_, err = securityprofiles.ListRevisions(name)
return
},
}

func init() {
ListRevisionsCmd.Flags().StringVarP(&name, "name", "n",
"", "Name of the security profile")
_ = ListRevisionsCmd.MarkFlagRequired("name")
}
1 change: 1 addition & 0 deletions cmd/securityprofiles/securityprofiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func init() {
Cmd.AddCommand(AttachCmd)
Cmd.AddCommand(DetachCmd)
Cmd.AddCommand(CreateCmd)
Cmd.AddCommand(ListRevisionsCmd)

_ = Cmd.MarkFlagRequired("org")
}
2 changes: 1 addition & 1 deletion internal/client/datastores/datastores.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func GetVersion(name string) (version string, err error) {
func List(targetType string) (respBody []byte, err error) {
u, _ := url.Parse(apiclient.BaseURL)
u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "analytics", "datastores")
if (targetType != "") && (targetType != "gcs" || targetType != "bigquery") {
if (targetType != "") && (targetType != "gcs" && targetType != "bigquery") {
return nil, fmt.Errorf("invalid targetType. Must be gcs or bigquery")
}
q := u.Query()
Expand Down
2 changes: 1 addition & 1 deletion internal/client/securityprofiles/securityprofiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func Get(name string) (respBody []byte, err error) {
}

// ListVersions
func ListVersions(name string) (respBody []byte, err error) {
func ListRevisions(name string) (respBody []byte, err error) {
u, _ := url.Parse(apiclient.BaseURL)
u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "securityProfiles", name+":listRevisions")
respBody, err = apiclient.HttpClient(u.String())
Expand Down

0 comments on commit c90226c

Please sign in to comment.