Skip to content

feat(cicd): allow CodeCommit as pipeline source#1808

Merged
mergify[bot] merged 25 commits intoaws:mainlinefrom
huanjani:pipeline-update
Jan 14, 2021
Merged

feat(cicd): allow CodeCommit as pipeline source#1808
mergify[bot] merged 25 commits intoaws:mainlinefrom
huanjani:pipeline-update

Conversation

@huanjani
Copy link
Copy Markdown
Contributor

@huanjani huanjani commented Jan 6, 2021

This PR enables CodeCommit as a pipeline source through execution
Screen Shot 2021-01-06 at 11 29 36 AM

(while still allowing GitHub as a source).
Screen Shot 2021-01-06 at 11 32 20 AM

Resolves #781
Related #1339

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@huanjani huanjani requested a review from a team as a code owner January 6, 2021 19:34
@huanjani huanjani requested a review from uttarasridhar January 6, 2021 19:34
@huanjani huanjani removed the request for review from uttarasridhar January 6, 2021 19:34
Copy link
Copy Markdown
Contributor

@iamhopaul123 iamhopaul123 left a comment

Choose a reason for hiding this comment

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

This is awesome! Thank you so much. Can we also make sure that integ test works well for this change?

Comment thread internal/pkg/deploy/pipeline.go Outdated
Comment thread templates/cicd/pipeline_cfn.yml Outdated
Comment thread internal/pkg/deploy/pipeline.go Outdated
Comment thread internal/pkg/deploy/pipeline.go Outdated
Comment thread internal/pkg/cli/pipeline_update.go
Comment thread internal/pkg/deploy/pipeline.go Outdated
Comment thread site/content/docs/concepts/pipelines.md Outdated
Comment thread templates/cicd/pipeline_cfn.yml Outdated
Comment thread templates/cicd/pipeline_cfn.yml Outdated
Comment thread internal/pkg/cli/pipeline_update.go Outdated
Comment thread internal/pkg/deploy/pipeline.go Outdated
Comment thread internal/pkg/deploy/pipeline.go Outdated
Comment thread internal/pkg/deploy/pipeline.go Outdated
Comment thread templates/cicd/pipeline_cfn.yml Outdated
Copy link
Copy Markdown
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.

🚀

Comment thread internal/pkg/cli/pipeline_init.go Outdated
Comment thread internal/pkg/cli/pipeline_init.go Outdated
Comment thread internal/pkg/deploy/pipeline.go Outdated
Comment thread internal/pkg/cli/pipeline_init.go Outdated
Comment thread internal/pkg/cli/pipeline_init.go Outdated
# TODO: #273 For now this set of configurations is GitHub-specific,
# change it to be more generic
Owner: {{$.Source.Owner}}
Repo: {{$.Source.Repository}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do these fields come from deploy.GithubSource or manifest.GithubProperties, or somewhere else? In those structs the field is RepositoryURL, not Repository--is that correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question-- this is confusing.
Repository is the method (func (s *GitHubSource) Repository() (string, error)) in the deploy package that returns the repo of a GitHubSource. For this field, we want just the repo name, not the whole url.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting, so Go will call the method named there. I talked about this in another comment where I think we can combine a base struct with a public ProviderName method and generator function. It's not super necessary though so if you think it's too much bother feel free to 🚀

ProviderName string
// GitHubSource defines the (GH) source of the artifacts to be built and deployed.
type GitHubSource struct {
ProviderName string
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this the same struct which determines the values that get injected into CFN? Is that why we need the ProviderName struct member?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah--I had taken it out because it seemed redundant, but this seemed to be the most straightforward way to determine which chunk of the yaml should get applied to the template.

I may change this when I introduce other sources and partials. Let me know if you have ideas!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could create a base pipelineSource struct which has a ProviderName() method and include that as a member of both GithubSource and CodeCommitSource, as something like

type pipelineSource struct {
    providerName string
}

func (s *pipelineSource) ProviderName() string {
    return s.providerName
}

type GithubSource struct {
    *pipelineSource
    // other GH specific members
}

func NewGithubSource(url, branch, secretID string) GithubSource {
    return GithubSource{
        pipelineSource: &pipelineSource{
            providerName: manifest.GithubProviderName
        },
        // other members
    }
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is cool! I implemented it locally but didn't commit because it may overcomplicate things at this point (unless there's a benefit to the cfn template calling a method rather than a struct field). I'll keep this in mind, though, if we have more functionality to add to this set-up with more sources.

Copy link
Copy Markdown
Contributor

@bvtujo bvtujo Jan 14, 2021

Choose a reason for hiding this comment

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

There's no particular benefit except
a) limiting code redeclaration in the various pipeline providers
b) making it harder to incorrectly initialize GithubSource or CodeCommitSource with the wrong provider name.

If the struct becomes more complicated then I think it would be worth it to move to the constructor pattern above but for the time being it's totally fine to leave as is.

@bvtujo bvtujo added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Jan 13, 2021
Comment thread internal/pkg/deploy/pipeline.go Outdated
Comment thread internal/pkg/deploy/pipeline.go Outdated
@huanjani huanjani removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Jan 14, 2021
@mergify mergify Bot merged commit 7568859 into aws:mainline Jan 14, 2021
@huanjani huanjani deleted the pipeline-update branch January 15, 2021 22:38
thrau pushed a commit to localstack/copilot-cli-local that referenced this pull request Dec 9, 2022
This PR enables CodeCommit as a pipeline source through execution
![Screen Shot 2021-01-06 at 11 29 36 AM](https://user-images.githubusercontent.com/60631893/103811877-79524400-5012-11eb-915f-917a53c5ca7e.png)

(while still allowing GitHub as a source).
![Screen Shot 2021-01-06 at 11 32 20 AM](https://user-images.githubusercontent.com/60631893/103812145-e6fe7000-5012-11eb-85d5-363d22a877c1.png)


Resolves aws#781
Related aws#1339

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.

Support for CodeCommit pipeline triggers

5 participants