feat: allow initializing workloads during copilot deploy#5168
feat: allow initializing workloads during copilot deploy#5168mergify[bot] merged 22 commits intoaws:mainlinefrom
Conversation
Co-authored-by: Penghao He <penghaoh@amazon.com>
|
|
||
| // If init-wkld and no-init-wkld flags aren't set, prompt customer to initialize. | ||
| if !o.yesInitWkld { | ||
| o.yesInitWkld, err = o.prompt.Confirm(fmt.Sprintf("Found manifest for uninitialized %s %q. Initialize it?", workloadType, o.name), "This workload will be initialized, then deployed.", prompt.WithConfirmFinalMessage()) |
| yesInitWorkloadFlag = "init-wkld" | ||
| noInitWorkloadFlag = "no-init-wkld" |
There was a problem hiding this comment.
Just a thought. Should this be a bool instead? I understand wanting consistency with the other flags (deploy/no-deploy). 🤷🏼
There was a problem hiding this comment.
You don't actually get the right amount of granularity if it's just a bool.
For example, if we just use init-wkld and the flag is un-specified, it's false. Then do you prompt for initialization, or do you assume the user's intent is not to init the workload and error out? It leads to problems where there's no way to force the command to exit when the intent is not to init the workload if it doesn't exist, or there's no way to display a prompt when the intent is ambiguous. Perhaps a pointer to a bool would do it, but I don't think there's a way of specifying a bool flag like --init=false in cobra.
Long winded way of saying that as far as I can tell, the best way to specify choices like this where we want to prompt by default but allow customers to specify either a positive or a negative is to use two mutually exclusive bool flags.
There was a problem hiding this comment.
It sounds to be very similar to
copilot-cli/internal/pkg/cli/svc_exec.go
Line 291 in 77c88c2
CaptainCarpensir
left a comment
There was a problem hiding this comment.
Looks cool 👀
Couple nits
|
🍕 Here are the new binary sizes!
|
Codecov Report
@@ Coverage Diff @@
## mainline #5168 +/- ##
============================================
- Coverage 69.52% 69.51% -0.01%
============================================
Files 295 295
Lines 43897 43988 +91
Branches 285 285
============================================
+ Hits 30518 30579 +61
- Misses 11889 11913 +24
- Partials 1490 1496 +6
|
dannyrandall
left a comment
There was a problem hiding this comment.
i'm curious what the difference is between svc init --deploy and svc deploy after these changes?
| if cmd.Flags().Changed(yesInitWorkloadFlag) { | ||
| opts.yesInitWkld = aws.Bool(false) | ||
| if initWorkload { | ||
| opts.yesInitWkld = aws.Bool(true) | ||
| } | ||
| } |
There was a problem hiding this comment.
why this? instead of just setting vars.yesInitWkld down below??
There was a problem hiding this comment.
ah i think sort of answered this below, but +1 to @iamhopaul123's question there - it seems like this is another way of doing the same thing?
There was a problem hiding this comment.
I hadn't seen this way of using a pointer, but using this construct instead of two mutually exclusive flags actually simplifies the logic in a pleasant way. This way the behavior is clear and the user is only prompted if they don't specify the flag one way or another via --init-wkld=false or --init-wkld.
|
This shouldn't affect svc deploy at all; I tried to scope these changes only to When a customer does
With this change to
My next PR will do the same for local environment manifests:
|
iamhopaul123
left a comment
There was a problem hiding this comment.
LGTM overall! just one question.
This is stacked on top of a couple of PRs (like 5128 and 5139). The diff should get smaller over time as those are merged.
Adds a new method to initialize which skips manifest writing.
I think the ideal scenario here is actually to use an initializer option on the workload initializer struct, but I wanted to get this out quickly rather than doing another big 300-line refactor if possible. Happy to do this after release; i actually have started the work.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.