Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ecs-run-task: Support task overrides #29

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

EdoFoco
Copy link
Collaborator

@EdoFoco EdoFoco commented Jan 15, 2024

This PR adds support for adding task overrides to ecs-run-task by specifying the path to the overrides JSON file.

@EdoFoco EdoFoco force-pushed the ecs-run-task/support-task-override branch from cfe2d66 to 547fd4b Compare January 15, 2024 11:56
common.FatalOnError(err)
}

func resolveTaskOverride(taskOverridesJSON *string) (*ecs.TaskOverride, error) {

Copy link
Owner

Choose a reason for hiding this comment

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

nitpick can you remove the empty line?


func resolveTaskOverride(taskOverridesJSON *string) (*ecs.TaskOverride, error) {

if *taskOverridesJSON == "" {
Copy link
Owner

Choose a reason for hiding this comment

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

instead of passing the pointer to the function, de-reference it in the main and pass it as string. From the main scope we know it's safe to de-reference it, but from the function itself it's not obvious so that line looks unsafe.

@@ -21,10 +25,36 @@ func main() {

ecsClient := ecs.New(session, conf)

taskOverride, overridesErr := resolveTaskOverride(taskOverrideJSON)
Copy link
Owner

Choose a reason for hiding this comment

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

rename to err and change like 31 to = instead of :=

return nil, err
}

var taskOverride *ecs.TaskOverride
Copy link
Owner

Choose a reason for hiding this comment

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

you can simplify
taskOverride := &ecs.TaskOverride{}


var taskOverride *ecs.TaskOverride
taskOverride = &ecs.TaskOverride{}
err = json.Unmarshal(b, taskOverride)
Copy link
Owner

Choose a reason for hiding this comment

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

if err := err = json.Unmarshal(b, taskOverride); err != nil {
return nil, err
}

@EdoFoco EdoFoco force-pushed the ecs-run-task/support-task-override branch 4 times, most recently from 7101cb9 to dd68fa2 Compare January 23, 2024 08:37
cluster = kingpin.Flag("cluster", "ECS cluster").Required().String()
taskDefinition = kingpin.Flag("task-definition", "ECS task definition").Required().String()
cluster = kingpin.Flag("cluster", "ECS cluster").Required().String()
taskOverrideJSON = kingpin.Flag("task-override-json", "Path to a JSON file with the task override to use").String()
Copy link
Owner

Choose a reason for hiding this comment

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

sorry I missed it in the previous review, can you rename to overrides (with s) to be consistent with the AWS argument?

@@ -21,10 +25,33 @@ func main() {

ecsClient := ecs.New(session, conf)

_, err := ecsClient.RunTask(&ecs.RunTaskInput{
taskOverride, err := resolveTaskOverride(*taskOverrideJSON)
Copy link
Owner

Choose a reason for hiding this comment

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

same as above

@EdoFoco EdoFoco force-pushed the ecs-run-task/support-task-override branch from dd68fa2 to e935af4 Compare January 23, 2024 08:53
@hamstah hamstah merged commit 8321af7 into hamstah:master Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants