-
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(manifest): support codebuild environment image config #2125
Conversation
* pipeline init generates with build property automatically. * if build property is not specified in pipeline manifest, default image is used. * if build property is specified explicitly in pipeline manifest, specified image is used. * Following images are descoped. ** cross-account ECR repository ** private registry other than ECR
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 for adding this feature! It looks great, just a few recommendations
internal/pkg/cli/pipeline_update.go
Outdated
@@ -272,6 +274,7 @@ func (o *updatePipelineOpts) Execute() error { | |||
AppName: o.appName, | |||
Name: pipeline.Name, | |||
Source: source, | |||
Build: build, |
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: to remove the extra variable
Build: build, | |
Build: deploy.PipelineBuildFromManifest(pipeline.Build), |
internal/pkg/manifest/pipeline.go
Outdated
@@ -168,6 +170,11 @@ type Source struct { | |||
Properties map[string]interface{} `yaml:"properties"` | |||
} | |||
|
|||
// Build defines the build project to build and test image. | |||
type Build struct { | |||
Image string `yaml:"image"` |
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: is this formatted correctly with gofmt
?
templates/cicd/pipeline.yml
Outdated
# This section defines the build project. | ||
build: | ||
# The URI that identifies the Docker image to use for this build project. | ||
image: {{.Build.Image}} |
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 not show this setting by default as it is mostly for advanced users. I expect most folks are satisfied with the default image that we provide.
Can we instead add it as a field in our documentation here? https://github.com/aws/copilot-cli/blob/mainline/site/content/docs/manifest/pipeline.md 🙏
internal/pkg/manifest/pipeline.go
Outdated
@@ -17,6 +17,7 @@ const ( | |||
GithubV1ProviderName = "GitHubV1" | |||
CodeCommitProviderName = "CodeCommit" | |||
BitbucketProviderName = "Bitbucket" | |||
DefaultImage = "aws/codebuild/amazonlinux2-x86_64-standard:3.0" |
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 define this constant in thedeploy
pkg instead? this would allow us to keep it private
internal/pkg/manifest/pipeline.go
Outdated
Build: &Build{ | ||
Image: DefaultImage, | ||
}, |
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 leave the default to be nil
, this allow us to move the constant to the deploy pkg and the translation logic to deploy.PipelineBuildFromManifest
internal/pkg/deploy/pipeline.go
Outdated
var imageURI string | ||
if (mfBuild == nil || mfBuild.Image == "") { | ||
imageURI = manifest.DefaultImage | ||
} else { | ||
imageURI = mfBuild.Image | ||
} | ||
return &Build{ | ||
Image: imageURI, | ||
} |
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.
var imageURI string | |
if (mfBuild == nil || mfBuild.Image == "") { | |
imageURI = manifest.DefaultImage | |
} else { | |
imageURI = mfBuild.Image | |
} | |
return &Build{ | |
Image: imageURI, | |
} | |
image := defaultPipelineBuildImage | |
if mfBuild != nil && mfBuild.Image != "" { | |
image = mfBuild.Image | |
} | |
return &Build{ | |
Image: image, | |
} |
Thank you for your review and feedback. It was very helpful! I totally agreed your suggestions. |
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! Just a small ask to remove the info block, afterwards we can remove the "do-not-merge" label and the PR will auto-merge :D
@@ -15,6 +15,8 @@ import ( | |||
"github.com/stretchr/testify/require" | |||
) | |||
|
|||
const defaultImage = "aws/codebuild/amazonlinux2-x86_64-standard:3.0" |
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 reuse defaultPipelineBuildImage
?
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 want to clarify. Do you mean rename defaultImage
into defaultPipelineBuildImage
? Or, using defaultPipelineBuildImage
in internal/pkg/deploy/pipeline.go? This constant is in deploy pkg, but this test file is in cloudformation pkg. Do you intend to fix not internal/pkg/deploy/cloudformation/pipeline_test.go but l.152 in internal/pkg/deploy/pipeline_test.go?
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 I see sorry that's my bad! you can ignore the comment then, I thought they were in the same pkg :)
The URI that identifies the Docker image to use for this build project. As of now, `aws/codebuild/amazonlinux2-x86_64-standard:3.0` is used by default. | ||
|
||
!!! info | ||
Copilot does not support cross-account ECR repository or private registry other than ECR because [imagePullCredentialsType](https://docs.aws.amazon.com/codebuild/latest/APIReference/API_ProjectEnvironment.html#CodeBuild-Type-ProjectEnvironment-imagePullCredentialsType) is fixed to `CODEBUILD`. |
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 removing this information? I don't think any users asked to push images to a different registry 🤔 or different account
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 build image used for CodeBuild project, so I thought some users might want to specify their own image stored in another account's ECR repo or another private registry. However, it maybe edge case, so I'll remove this block as you suggested. I appreciate your nice 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.
Thanks! let us know, once removed we can merge the 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.
I just pushed 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.
Thank you so much for contributing!! This looks good to me!
@@ -261,6 +261,48 @@ stages: | |||
}, | |||
}, | |||
}, | |||
"valid pipeline.yml with build": { |
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 for writing all these tests! They are really helpful and comprehensive.
With aws#2125 we added a "build" field to pipeline, but forgot to update the integ tests that create the pipeline. This change adds the default build config so that the pipeline is created successfully.
Addresses aws#2106 * pipeline init behavior * generates manifest with build property automatically. * pipeline update behavior * if build property is not specified in pipeline manifest, default image is used. * if build property is specified explicitly in pipeline manifest, specified image is used. * Limitation: following images are descoped. * cross-account ECR repository * private registry other than ECR By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Addresses aws#2106 * pipeline init behavior * generates manifest with build property automatically. * pipeline update behavior * if build property is not specified in pipeline manifest, default image is used. * if build property is specified explicitly in pipeline manifest, specified image is used. * Limitation: following images are descoped. * cross-account ECR repository * private registry other than ECR By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Addresses aws#2106 * pipeline init behavior * generates manifest with build property automatically. * pipeline update behavior * if build property is not specified in pipeline manifest, default image is used. * if build property is specified explicitly in pipeline manifest, specified image is used. * Limitation: following images are descoped. * cross-account ECR repository * private registry other than ECR By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Addresses #2106
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.