Skip to content

Commit

Permalink
fix: apply default revision when creating debugsession (#419)
Browse files Browse the repository at this point in the history
* fix: apply default revision when creating debugsession

* fix: also use latest revision when getting a debugsession

* fix: tweak help message for --msg param in gettrcapi

* fix: also support default revision in apis/undeploy
  • Loading branch information
DinoChiesa authored Mar 3, 2024
1 parent 1bb1229 commit 0289868
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 7 additions & 3 deletions internal/cmd/apis/crttrcapi.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2020,2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,11 @@ var CreateTrcCmd = &cobra.Command{
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
if revision == -1 {
if revision, err = apis.GetHighestProxyRevision(name); err != nil {
return err
}
}
_, err = apis.CreateTraceSession(name, revision, filter)
return
},
Expand All @@ -44,10 +49,9 @@ func init() {
CreateTrcCmd.Flags().StringVarP(&name, "name", "n",
"", "API proxy name")
CreateTrcCmd.Flags().IntVarP(&revision, "rev", "v",
-1, "API Proxy revision")
-1, "API Proxy revision. If not set, the highest revision is used")
CreateTrcCmd.Flags().StringToStringVar(&filter, "filter",
nil, "Filter Conditions; format is name1=value1,name2=value2...")

_ = CreateTrcCmd.MarkFlagRequired("name")
_ = CreateTrcCmd.MarkFlagRequired("rev")
}
12 changes: 8 additions & 4 deletions internal/cmd/apis/gettrcapi.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2020-2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,11 @@ var GetTrcCmd = &cobra.Command{
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
if revision == -1 {
if revision, err = apis.GetHighestProxyRevision(name); err != nil {
return err
}
}
_, err = apis.GetTraceSession(name, revision, sessionID, messageID)
return
},
Expand All @@ -44,13 +49,12 @@ func init() {
GetTrcCmd.Flags().StringVarP(&name, "name", "n",
"", "API proxy name")
GetTrcCmd.Flags().IntVarP(&revision, "rev", "v",
-1, "API Proxy revision")
-1, "API Proxy revision. If not set, the highest revision is used")
GetTrcCmd.Flags().StringVarP(&sessionID, "ses", "s",
"", "Debug session Id")
GetTrcCmd.Flags().StringVarP(&messageID, "msg", "m",
"", "Debug session Id")
"", "Debug transaction Id")

_ = GetTrcCmd.MarkFlagRequired("name")
_ = GetTrcCmd.MarkFlagRequired("rev")
_ = GetTrcCmd.MarkFlagRequired("ses")
}
5 changes: 2 additions & 3 deletions internal/cmd/apis/undepapi.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2020,2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,11 +51,10 @@ func init() {
UndepCmd.Flags().StringVarP(&env, "env", "e",
"", "Apigee environment name")
UndepCmd.Flags().IntVarP(&revision, "rev", "v",
-1, "API Proxy revision")
-1, "API Proxy revision. If not set, the highest revision is used")
UndepCmd.Flags().BoolVarP(&safeUndeploy, "safeundeploy", "",
true, deploymentMsg)

_ = UndepCmd.MarkFlagRequired("env")
_ = UndepCmd.MarkFlagRequired("name")
_ = UndepCmd.MarkFlagRequired("rev")
}

0 comments on commit 0289868

Please sign in to comment.