-
Notifications
You must be signed in to change notification settings - Fork 6
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
ecs-run-task: Support task overrides #29
Conversation
cfe2d66
to
547fd4b
Compare
ecs/run-task/main.go
Outdated
common.FatalOnError(err) | ||
} | ||
|
||
func resolveTaskOverride(taskOverridesJSON *string) (*ecs.TaskOverride, error) { | ||
|
There was a problem hiding this comment.
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?
ecs/run-task/main.go
Outdated
|
||
func resolveTaskOverride(taskOverridesJSON *string) (*ecs.TaskOverride, error) { | ||
|
||
if *taskOverridesJSON == "" { |
There was a problem hiding this comment.
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.
ecs/run-task/main.go
Outdated
@@ -21,10 +25,36 @@ func main() { | |||
|
|||
ecsClient := ecs.New(session, conf) | |||
|
|||
taskOverride, overridesErr := resolveTaskOverride(taskOverrideJSON) |
There was a problem hiding this comment.
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 :=
ecs/run-task/main.go
Outdated
return nil, err | ||
} | ||
|
||
var taskOverride *ecs.TaskOverride |
There was a problem hiding this comment.
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{}
ecs/run-task/main.go
Outdated
|
||
var taskOverride *ecs.TaskOverride | ||
taskOverride = &ecs.TaskOverride{} | ||
err = json.Unmarshal(b, taskOverride) |
There was a problem hiding this comment.
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
}
7101cb9
to
dd68fa2
Compare
ecs/run-task/main.go
Outdated
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() |
There was a problem hiding this comment.
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?
ecs/run-task/main.go
Outdated
@@ -21,10 +25,33 @@ func main() { | |||
|
|||
ecsClient := ecs.New(session, conf) | |||
|
|||
_, err := ecsClient.RunTask(&ecs.RunTaskInput{ | |||
taskOverride, err := resolveTaskOverride(*taskOverrideJSON) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
dd68fa2
to
e935af4
Compare
This PR adds support for adding task overrides to ecs-run-task by specifying the path to the overrides JSON file.