Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Add collection flag for postman ECS agent #234

Merged
merged 6 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions cmd/internal/ecs/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const (
// Postman Live Collections Agent image locations
akitaECRImage = "public.ecr.aws/akitasoftware/akita-cli"
akitaDockerImage = "akitasoftware/cli"
postmanECRImage = "docker.postman.com/postman-lc-agent"
postmanECRImage = "docker.postman.com/postman-lc-agent"
)

// Run the "add to ECS" workflow until we complete or get an error.
Expand Down Expand Up @@ -841,20 +841,24 @@ func modifyTaskState(wf *AddWorkflow) (nextState optionals.Optional[AddWorkflowS
})

pKey, pEnv := cfg.GetPostmanAPIKeyAndEnvironment()
envs := []types.KeyValuePair{}
if pEnv != "" {
envs = append(envs, []types.KeyValuePair{
{Name: aws.String("POSTMAN_ENV"), Value: &pEnv},
}...)
}
input.ContainerDefinitions = append(input.ContainerDefinitions, types.ContainerDefinition{
Name: aws.String("postman-lc-agent"),
// TODO: Cpu and Memory should be omitted for Fargate; they take their default values for EC2 if omitted.
// For now we can leave the defaults in place, but they might be a bit large for EC2.
EntryPoint: []string{"/postman-lc-agent", "apidump", "--collection", collectionId},
Environment: []types.KeyValuePair{
Environment: append(envs, []types.KeyValuePair{
{Name: aws.String("POSTMAN_API_KEY"), Value: &pKey},
{Name: aws.String("POSTMAN_ENV"), Value: &pEnv},

// Setting these environment variables will cause the traces to be tagged.
{Name: aws.String("AKITA_AWS_REGION"), Value: &wf.awsRegion},
{Name: aws.String("AKITA_ECS_SERVICE"), Value: &wf.ecsService},
{Name: aws.String("AKITA_ECS_TASK"), Value: &wf.ecsTaskDefinitionFamily},
},
{Name: aws.String("POSTMAN_AWS_REGION"), Value: &wf.awsRegion},
{Name: aws.String("POSTMAN_ECS_SERVICE"), Value: &wf.ecsService},
{Name: aws.String("POSTMAN_ECS_TASK"), Value: &wf.ecsTaskDefinitionFamily},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are modified, then the code that reads them back out should also be modified, ideally in a backwards-compatible way. As we discussed, there is some question about their value because tags aren't visible in the Postman UI at all (although they could be -- for example we might start annotating each collection with information about the sources of data.) So I would be OK leaving these as AKITA_ for now, but if they change they should change both places.

https://github.com/akitasoftware/akita-cli/blob/e4b857e27663a0138107eec34c8d4d1ec41e5f58/deployment/deployment.go#L25-L32

}...),
Essential: aws.Bool(false),
Image: aws.String(postmanECRImage),
})
Expand Down
3 changes: 1 addition & 2 deletions cmd/internal/ecs/ecs.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ecs

import (
"context"
"fmt"

"github.com/akitasoftware/akita-cli/cmd/internal/cmderr"
Expand Down Expand Up @@ -41,7 +40,7 @@ var Cmd = &cobra.Command{
RunE: addAgentToECS,
}

// 'akita ecs' should default to 'akita ecs add'
// 'postman-lc-agent ecs' should default to 'postman-lc-agent ecs add'
var AddToECSCmd = &cobra.Command{
Use: "add",
Short: Cmd.Short,
Expand Down