Skip to content
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

Merged
merged 9 commits into from
Apr 14, 2021

Conversation

tam0ri
Copy link
Contributor

@tam0ri tam0ri commented Apr 1, 2021

Addresses #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.

tam0ri added 4 commits March 31, 2021 15:09
* 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
@tam0ri tam0ri requested a review from a team as a code owner April 1, 2021 15:46
@tam0ri tam0ri requested a review from iamhopaul123 April 1, 2021 15:46
Copy link
Contributor

@efekarakus efekarakus left a 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

@@ -272,6 +274,7 @@ func (o *updatePipelineOpts) Execute() error {
AppName: o.appName,
Name: pipeline.Name,
Source: source,
Build: build,
Copy link
Contributor

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

Suggested change
Build: build,
Build: deploy.PipelineBuildFromManifest(pipeline.Build),

@@ -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"`
Copy link
Contributor

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?

Comment on lines 23 to 26
# This section defines the build project.
build:
# The URI that identifies the Docker image to use for this build project.
image: {{.Build.Image}}
Copy link
Contributor

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 🙏

@@ -17,6 +17,7 @@ const (
GithubV1ProviderName = "GitHubV1"
CodeCommitProviderName = "CodeCommit"
BitbucketProviderName = "Bitbucket"
DefaultImage = "aws/codebuild/amazonlinux2-x86_64-standard:3.0"
Copy link
Contributor

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

Comment on lines 200 to 202
Build: &Build{
Image: DefaultImage,
},
Copy link
Contributor

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

Comment on lines 186 to 194
var imageURI string
if (mfBuild == nil || mfBuild.Image == "") {
imageURI = manifest.DefaultImage
} else {
imageURI = mfBuild.Image
}
return &Build{
Image: imageURI,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
}

@tam0ri
Copy link
Contributor Author

tam0ri commented Apr 2, 2021

Thank you for your review and feedback. It was very helpful! I totally agreed your suggestions.

Copy link
Contributor

@efekarakus efekarakus left a 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"
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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`.
Copy link
Contributor

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

Copy link
Contributor Author

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!

Copy link
Contributor

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 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pushed it🚀

@efekarakus efekarakus added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Apr 5, 2021
Copy link
Contributor

@Lou1415926 Lou1415926 left a 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": {
Copy link
Contributor

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.

@efekarakus efekarakus removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Apr 6, 2021
@efekarakus efekarakus added do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. and removed do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. labels Apr 13, 2021
@mergify mergify bot merged commit 2a8458b into aws:mainline Apr 14, 2021
efekarakus added a commit to efekarakus/copilot-cli that referenced this pull request Apr 15, 2021
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.
Lou1415926 pushed a commit to Lou1415926/copilot-cli that referenced this pull request Apr 20, 2021
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.
Lou1415926 pushed a commit to Lou1415926/copilot-cli that referenced this pull request Apr 20, 2021
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.
thrau pushed a commit to localstack/copilot-cli-local that referenced this pull request Dec 9, 2022
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants