Skip to content

Commit f80a1e3

Browse files
Remove get services calls from active commands (#114)
In this PR, we have removed the usage of the `GetServices()` function in the front client because this endpoint uses a deprecated endpoint, which will be removed soon and will not work with Postman authentication. Changes: * Updated the specs command to take serviceID input as a `--project` flag. * Also updated `GetTraceURIByTags` function to take serviceID as a parameter instead of looking for it from BE. * I have to not removed the `GetServices()` function yet since it is still being used by some deprecated commands, like nginx which will be removed as a part of agent code clean-up.
1 parent 208460a commit f80a1e3

File tree

5 files changed

+17
-51
lines changed

5 files changed

+17
-51
lines changed

cmd/internal/apidump/apidump.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func apidumpRunInternal(cmd *cobra.Command, _ []string) error {
157157
destURI, err := util.GetTraceURIByTags(rest.Domain,
158158
telemetry.GetClientID(),
159159
outFlag.AkitaURI.ServiceName,
160+
serviceID,
160161
traceTags,
161162
"append-by-tag",
162163
)

cmd/internal/legacy/specs.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ You may specify the API spec by version name (e.g. "latest") or an ID (e.g.
4747

4848
// GetSpec flags
4949
var (
50-
getSpecServiceFlag string
50+
getSpecProjectIDFlag string
5151
getSpecOutputFlag string
5252
getSpecTimeoutFlag time.Duration
5353
getSpecWaitFlag bool
@@ -58,10 +58,10 @@ func init() {
5858
SpecsCmd.AddCommand(getSpecCmd)
5959

6060
getSpecCmd.Flags().StringVar(
61-
&getSpecServiceFlag,
62-
"service",
61+
&getSpecProjectIDFlag,
62+
"project",
6363
"",
64-
"Your Akita service.",
64+
"Your Insights project ID.",
6565
)
6666
cobra.MarkFlagRequired(getSpecCmd.Flags(), "service")
6767

@@ -117,14 +117,11 @@ func runGetSpec(specIdentifier string) error {
117117

118118
clientID := akid.GenerateClientID()
119119

120-
frontClient := rest.NewFrontClient(rest.Domain, clientID, nil)
121-
122-
// Convert service name to service ID.
123-
serviceID, err := getServiceIDByName(frontClient, getSpecServiceFlag)
120+
var serviceID akid.ServiceID
121+
err := akid.ParseIDAs(getSpecProjectIDFlag, &serviceID)
124122
if err != nil {
125-
return err
123+
return errors.Wrap(err, "failed to parse project ID")
126124
}
127-
128125
learnClient := rest.NewLearnClient(rest.Domain, clientID, serviceID, nil)
129126

130127
// Check to see if the user specified an AkID or a version name.

cmd/internal/legacy/util.go

Lines changed: 0 additions & 31 deletions
This file was deleted.

data_masks/redactor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func NewRedactor(
9797
)
9898
}()
9999
if err != nil {
100-
printer.Warningf("failed to update redaction configuration for %s: %v", serviceID, err)
100+
printer.Warningf("failed to update redaction configuration for %s: %v\n", serviceID, err)
101101
continue
102102
}
103103

util/util.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,14 @@ func GetLearnSessionByTags(c rest.LearnClient, serviceID akid.ServiceID, tags ma
306306

307307
// Get the most recent trace for a service; helper method for commands to implement the
308308
// --append-by-tag or --trace-tag flags.
309-
func GetTraceURIByTags(domain string, clientID akid.ClientID, serviceName string, tags map[tags.Key]string, flagName string) (akiuri.URI, error) {
309+
func GetTraceURIByTags(
310+
domain string,
311+
clientID akid.ClientID,
312+
serviceName string,
313+
serviceID akid.ServiceID,
314+
tags map[tags.Key]string,
315+
flagName string,
316+
) (akiuri.URI, error) {
310317
if len(tags) == 0 {
311318
return akiuri.URI{}, fmt.Errorf("Must specify a tag to match with %q", flagName)
312319
}
@@ -315,14 +322,6 @@ func GetTraceURIByTags(domain string, clientID akid.ClientID, serviceName string
315322
return akiuri.URI{}, fmt.Errorf("%q currently supports only a single tag", flagName)
316323
}
317324

318-
// Resolve ServiceID
319-
// TODO: find a better way to overlap this with commands that already do the lookup
320-
frontClient := rest.NewFrontClient(domain, clientID, nil)
321-
serviceID, err := GetServiceIDByName(frontClient, serviceName)
322-
if err != nil {
323-
return akiuri.URI{}, errors.Wrapf(err, "failed to resolve project name %q", serviceName)
324-
}
325-
326325
learnClient := rest.NewLearnClient(domain, clientID, serviceID, nil)
327326
learnSession, err := GetLearnSessionByTags(learnClient, serviceID, tags)
328327
if err != nil {

0 commit comments

Comments
 (0)