-
Notifications
You must be signed in to change notification settings - Fork 421
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
feat(cli): implement exec for task run #1077
Conversation
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.
Awesome PR. A great leap from 0 to 1!
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.
Looks really good to me! Could you also add manual tests for this feature? Like doing a deployment with local image and url?
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.
This looks awesome. What a massive effort. Just a few nits from my side but LGTM!
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.
ship it just a few nits and adding the manual test
@@ -168,6 +181,60 @@ func (e *ECS) ServiceTasks(clusterName, serviceName string) ([]*Task, error) { | |||
return tasks, nil | |||
} | |||
|
|||
// DefaultClusters returns the default clusters in the account and region | |||
func (e *ECS) DefaultCluster() (string, error) { | |||
resp, err := e.client.DescribeClusters(&ecs.DescribeClustersInput{}) |
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.
Shouldn't we include the "Default" cluster as an input parameter? Otherwise we're just choosing the "first" cluster - which may not be the default cluster at all.
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.
From DescribeClustersInput it says, If Clusters
is not specified, the default cluster is assumed. Not sure if this answers your concern 👀
clusters, err := o.resourceGetter.GetResourcesByTags(clusterResourceType, map[string]string{ | ||
deploy.AppTagKey: o.AppName(), | ||
deploy.EnvTagKey: o.env, | ||
}) |
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.
I think we should hide this somewhere. Perhaps in the describe package or the ECSGetter?
store store | ||
parser dockerfileParser | ||
sel appEnvWithNoneSelector | ||
fs afero.Fs |
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.
Is this used?
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.
It's used at Validate to determine whether the dockerfile path that user provides is valid
|
||
Cpu int | ||
Memory int | ||
|
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.
We may also need to support EntryPoint, as well.
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.
A new flag🚩 Sounds good! Will do this in a separate PR!
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.
This is a huge amount of work and amazing! However, can we close this PR and create new ones by splitting up this work?
I think for us to be able to give good feedback, we need the PRs to be smaller. I personally struggle digesting all this information. We can take our time slightly more but deliver the right UX for our customers.
What do you think of submitting a PR individually for each one of the packages touched?
-
internal/aws/ec2
pkg -
deploy/cfn/stack
pkg + cf template -
deploy/cfn
pkg withDeployTask
- An
internal/task
pkg with multiple functions likeRunInDefaultVPC
orRunInEnv
that could
abstract away thegetCluster
,getNetworking
methods. - An
internal/repository
pkg to abstractpushToECRRepo()
- The
task_run
file.
Feel free to change the order or add additional/remove item but in general let's try to keep each layer in a separate PR.
Also this is my bad, I'll make sure to provide quick feedback with the PRs to unblock you!
) | ||
|
||
const ( | ||
defaultImageTag = "copilot" |
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.
Can we re-use:
copilot-cli/internal/pkg/cli/git.go
Lines 13 to 21 in 68929f7
func getVersionTag(runner runner) (string, error) { | |
var b bytes.Buffer | |
if err := runner.Run("git", []string{"describe", "--always"}, command.Stdout(&b)); err != nil { | |
return "", err | |
} | |
// NOTE: `git describe` output bytes includes a `\n` character, so we trim it out. | |
return strings.TrimSpace(b.String()), nil |
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.
do you think it makes sense if I first try to getVersionTag
, if it fails (e.g. it is not a git repo), then I use this defaultImageTag
?
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.
I think what we do with svc deploy
is first checking if we can getVersionTag, if that fails we prompt for a tag value
cmd.Flags().StringSliceVar(&vars.securityGroups, securityGroupsFlag, nil, securityGroupsFlagDescription) | ||
|
||
cmd.Flags().StringToStringVar(&vars.envVars, envVarsFlag, nil, envVarsFlagDescription) | ||
cmd.Flags().StringSliceVar(&vars.commands, commandsFlag, nil, commandsFlagDescription) | ||
cmd.Flags().StringVar(&vars.command, commandFlag, "", commandFlagDescription) |
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.
In the style guide for the CLI we decided: https://github.com/aws/copilot-cli/blob/master/STYLE_GUIDE.md#flags
Flags are used when you need more than one required input of different type or if the inputs are optional.
Since the flag is optional and to keep it consistent with the other commands, I think we should have it behind a flag
} | ||
|
||
func (o *runTaskOpts) getCluster() (string, error) { | ||
if o.env == config.EnvNameNone { |
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.
I find the EnvNameNone
a bit confusing, so as a customer do I have to explicitly write "None" to the -e
flag for it to pick up the default cluster?
Why can't we use the default empty string ""
to say that a user hasn't specified an environment?
I'd love for us to think if we can simplify this for our customers since the "None" environment doesn't exist in our other commands.
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.
No, they don't explicitly specify "None". The first time "None" appears is when we ask for an env name during Ask
. We list all the environments of the app, and append to the end an option called "None" which would result in the default cluster and subnets if selected.
We can use "" instead of "None". As a customer the experience would be the same - the "None" would still be a reserved keyword because it's till gonna be there during Ask
, so that the user can opt to use the default cluster/subnet during Ask
.
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.
Gotcha! that's good to know :) ok then I think it's fine but maybe we can move the const out of the config
pkg to the cli
package itself. Since config
pkg itself doesn't use the constant.
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.
Sounds good!!
The PR implements execute for task run command. Specifically, it does the following:
Related #702
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.