-
Notifications
You must be signed in to change notification settings - Fork 428
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): support manual approvals in pipeline manifest. #1273
Conversation
When a production environment is added via pipeline init, copilot adds the requires_approval: true line in pipeline.yml. When requires_approval: true line exists in pipeline.yml, manual approval action is added into the pipeline via pipeline update.
Hi reviewers. I'm not sure we need to update the version of pipeline manifest. copilot-cli/internal/pkg/manifest/pipeline.go Lines 75 to 78 in a145f22
copilot-cli/internal/pkg/manifest/pipeline.go Line 119 in a145f22
If we need to increment the version, please tell me that. |
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.
😍 Thank you so much!
It looks good, mostly a comment about decoupling the manifest
pkg from config
.
internal/pkg/manifest/pipeline.go
Outdated
} | ||
|
||
// CreatePipeline returns a pipeline manifest object. | ||
func CreatePipeline(pipelineName string, provider Provider, stageNames []string) (*PipelineManifest, error) { | ||
func CreatePipeline(pipelineName string, provider Provider, envs []*config.Environment) (*PipelineManifest, 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.
nit: Would you mind renaming this function to NewPipelineManifest
?
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 addressed.
internal/pkg/cli/pipeline_init.go
Outdated
environments = append(environments, env) | ||
} | ||
|
||
manifest, err := manifest.CreatePipeline(pipelineName, provider, environments) |
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 []*config.Environment
as input to this function, what do you think of passing []manifest.PipelineStage
? so this method would transform []*config.Environment -> []manifest.PipelineStage
.
Since the function is in the manifest
pkg, accepting []manifest.PipelineStage
will make it more flexible. The PipelineStage
can be created from a config.Environment
object or some other way.
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 addressed. However, now TestNewPipelineManifest just become meaningless because this test expects PipelineStage. I plan to change this test such as it expects PipelineManifest. If you have any opinion, please give me a feedback!
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.
hmm yeah I agree, the only behavior that might be interesting to test in TestNewPipelineManifest
is checking if an error is returned if the list is empty and that's it
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.
Oh, does it mean we simply need to remove happy case and retain only error case? I just modified happy case with PipelineManifest
as expected by imitating backend_svc_test.go. If I need to remove happy case, please point out!
internal/pkg/cli/pipeline_init.go
Outdated
@@ -247,14 +247,36 @@ func (o *initPipelineOpts) createPipelineProvider() (manifest.Provider, error) { | |||
return manifest.NewProvider(config) | |||
} | |||
|
|||
func (o *initPipelineOpts) getEnvFromCache(environmentName string) (*config.Environment, 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.
nit: Can we rename this method to getEnvConfig
?
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 addressed.
internal/pkg/cli/pipeline_init.go
Outdated
var environment *config.Environment | ||
for _, env := range o.envs { | ||
if env.Name == environmentName { | ||
environment = 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.
nit: break
after this statement so that we don't continue looping.
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 addressed.
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.
nit: oh my bad, instead of breaking we should just return instead :)
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.
and then outside of the for-loop we wouldn't need to check if it's equal to nil and return also an error immediately
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.
Totally agree! I addressed.
👋 @git823
We can keep it as is. We don't do anything with the version atm, so it should be fine :) |
This will be a breaking-change for customers that have a pipeline with environments that are initialized with I think this is fine though, we'll explicitly call it out in our release notes as this change gives the customers power to control the manual approvals :) |
Rename getEnvFromCache -> getEnvConfig. Add break statement.
Rename CreatePipeline -> NewPipelineManifest. Instead of passing []*config.Environment as input to NewPipelineManifest, passing []manifest.PipelineStage.
internal/pkg/cli/pipeline_init.go
Outdated
var environment *config.Environment | ||
for _, env := range o.envs { | ||
if env.Name == environmentName { | ||
environment = 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.
nit: oh my bad, instead of breaking we should just return instead :)
templates/cicd/pipeline.yml
Outdated
@@ -21,6 +21,8 @@ source: | |||
stages:{{range .Stages}} | |||
- # The name of the environment to deploy to. | |||
name: {{.Name}} | |||
# Optional: flag for manual approval action before deployment. | |||
requires_approval: {{.RequiresApproval}} |
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.
What do you think of having this commented out, by default (like the test commands)? It will be false by default. and folks can uncomment it if they want it!
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 nice! I addressed.
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 great! Thank you
related aws#1179 When a production environment is added via `pipeline init`, copilot adds the requires_approval: true line in pipeline.yml. When requires_approval: true line exists in pipeline.yml, manual approval action is added into the pipeline via `pipeline update`. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
related #1179
When a production environment is added via
pipeline init
, copilot adds the requires_approval: true line in pipeline.yml.When requires_approval: true line exists in pipeline.yml, manual approval action is added into the pipeline via
pipeline update
.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.