@@ -2,7 +2,6 @@ package ecs
2
2
3
3
import (
4
4
"fmt"
5
- "strings"
6
5
7
6
"github.com/akitasoftware/akita-cli/cmd/internal/cmderr"
8
7
"github.com/akitasoftware/akita-cli/rest"
@@ -13,8 +12,8 @@ import (
13
12
)
14
13
15
14
var (
16
- // Mandatory flag: Akita project name
17
- projectFlag string
15
+ // Mandatory flag: Postman collection id
16
+ collectionId string
18
17
19
18
// Any of these will be interactively prompted if not given on the command line.
20
19
// On the other hand, to run non-interactively then all of them *must* be given.
@@ -34,14 +33,14 @@ var (
34
33
var Cmd = & cobra.Command {
35
34
Use : "ecs" ,
36
35
Short : "Add the Postman Live Collections Agent to AWS ECS." ,
37
- Long : "The CLI will collect information from you and add the Akita container to an ECS Task." ,
36
+ Long : "The CLI will collect information from you and add the Postman Live Collections Agent container to an ECS Task." ,
38
37
// N.B.: this is useless because the root command makes its own determination,
39
38
// need to return AkitaErr to not show the usage.
40
39
SilenceUsage : true ,
41
40
RunE : addAgentToECS ,
42
41
}
43
42
44
- // 'akita ecs' should default to 'akita ecs add'
43
+ // 'postman-lc-agent ecs' should default to 'postman-lc-agent ecs add'
45
44
var AddToECSCmd = & cobra.Command {
46
45
Use : "add" ,
47
46
Short : Cmd .Short ,
@@ -53,7 +52,7 @@ var AddToECSCmd = &cobra.Command{
53
52
var RemoveFromECSCmd = & cobra.Command {
54
53
Use : "remove" ,
55
54
Short : "Remove the Postman Live Collections Agent from AWS ECS." ,
56
- Long : "Remove a previously installed Akita container from an ECS Task." ,
55
+ Long : "Remove a previously installed Postman container from an ECS Task." ,
57
56
SilenceUsage : true ,
58
57
RunE : removeAgentFromECS ,
59
58
@@ -63,7 +62,7 @@ var RemoveFromECSCmd = &cobra.Command{
63
62
64
63
func init () {
65
64
// TODO: add the ability to specify the credentials directly instead of via an AWS profile?
66
- Cmd .PersistentFlags ().StringVar (& projectFlag , "project " , "" , "Your Akita project. " )
65
+ Cmd .PersistentFlags ().StringVar (& collectionId , "collection " , "" , "Your Postman collection ID " )
67
66
Cmd .PersistentFlags ().StringVar (& awsProfileFlag , "profile" , "" , "Which of your AWS profiles to use to access ECS." )
68
67
Cmd .PersistentFlags ().StringVar (& awsRegionFlag , "region" , "" , "The AWS region in which your ECS cluster resides." )
69
68
Cmd .PersistentFlags ().StringVar (& ecsClusterFlag , "cluster" , "" , "The name or ARN of your ECS cluster." )
@@ -91,40 +90,24 @@ func init() {
91
90
92
91
func addAgentToECS (cmd * cobra.Command , args []string ) error {
93
92
// Check for API key
94
- _ , _ , err := cmderr .RequireAkitaAPICredentials ("The Postman Live Collections Agent must have an API key in order to capture traces." )
93
+ _ , err := cmderr .RequirePostmanAPICredentials ("The Postman Live Collections Agent must have an API key in order to capture traces." )
95
94
if err != nil {
96
95
return err
97
96
}
98
97
99
- // Check project 's existence
100
- if projectFlag == "" {
101
- return errors .New ("Must specify the name of your Akita project with the --project flag." )
98
+ // Check collecton Id 's existence
99
+ if collectionId == "" {
100
+ return errors .New ("Must specify the ID of your collection with the --collection flag." )
102
101
}
103
102
frontClient := rest .NewFrontClient (rest .Domain , telemetry .GetClientID ())
104
- _ , err = util .GetServiceIDByName (frontClient , projectFlag )
103
+ _ , err = util .GetOrCreateServiceIDByPostmanCollectionID (frontClient , collectionId )
105
104
if err != nil {
106
- // TODO: we _could_ offer to create it, instead.
107
- if strings .Contains (err .Error (), "cannot determine project ID" ) {
108
- return cmderr.AkitaErr {
109
- Err : fmt .Errorf (
110
- "Could not find the project %q in the Akita cloud. Please create it from the Akita web console before proceeding." ,
111
- projectFlag ,
112
- ),
113
- }
114
- } else {
115
- return cmderr.AkitaErr {
116
- Err : errors .Wrapf (
117
- err ,
118
- "Could not look up the project %q in the Akita cloud" ,
119
- projectFlag ,
120
- ),
121
- }
122
- }
105
+ return err
123
106
}
124
107
125
108
return RunAddWorkflow ()
126
109
}
127
110
128
111
func removeAgentFromECS (cmd * cobra.Command , args []string ) error {
129
- return fmt .Errorf ("This command is not yet implemented" )
112
+ return fmt .Errorf ("this command is not yet implemented" )
130
113
}
0 commit comments