Skip to content

Commit

Permalink
Merge pull request #407 from stelligent/issue-406
Browse files Browse the repository at this point in the history
Issue 406
  • Loading branch information
cplee committed Dec 5, 2018
2 parents d29f7ad + 9def66b commit 61dd938
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
20 changes: 19 additions & 1 deletion templates/assets/cloudformation/artifact-pipeline.yml
Expand Up @@ -11,6 +11,16 @@ Parameters:
SourceBranch:
Type: String
Description: Branch to trigger pipeline
{{if eq .SourceProvider "S3" -}}
SourceBucket:
Type: String
Description: Source Bucket
Default: ""
SourceObjectKey:
Type: String
Description: Source Object Key
Default: ""
{{- end}}
{{if eq .SourceProvider "GitHub" -}}
GitHubToken:
NoEcho: true
Expand Down Expand Up @@ -90,6 +100,10 @@ Resources:
CodeDeployBucket: {{ .CodeDeployBucket }}
SourceProvider: {{ .SourceProvider }}
SourceRepo: !Ref SourceRepo
{{if eq .SourceProvider "S3" -}}
SourceBucket: !Ref SourceBucket
SourceObjectKey: !Ref SourceObjectKey
{{- end}}
{{if eq .EnableAcptStage "true" -}}
AcptEnv: {{ .AcptEnv }}
{{- end}}
Expand All @@ -103,7 +117,7 @@ Resources:
AcptCloudFormationRoleArn: {{ .AcptCloudFormationRoleArn }}
{{- end}}
{{if eq .EnableProdStage "true" -}}
ProdCloudFormationRoleArn: {{ .ProdCloudFormationRoleArn }}
ProdCloudFormationRoleArn: {{ .ProdCloudFormationRoleArn }}
{{- end}}
Tags:
- Key: mu:name
Expand All @@ -130,6 +144,10 @@ Resources:
SourceProvider: {{ .SourceProvider }}
SourceRepo: !Ref SourceRepo
SourceBranch: !Ref SourceBranch
{{if eq .SourceProvider "S3" -}}
SourceBucket: !Ref SourceBucket
SourceObjectKey: !Ref SourceObjectKey
{{- end}}
{{if eq .SourceProvider "GitHub" -}}
GitHubToken: !Ref GitHubToken
{{- end}}
Expand Down
18 changes: 16 additions & 2 deletions workflows/pipeline_upsert.go
Expand Up @@ -252,9 +252,23 @@ func (workflow *pipelineWorkflow) pipelineCatalogUpserter(namespace string, pipe

productParams := make(map[string]string)
productParams["ServiceName"] = workflow.serviceName
productParams["SourceBranch"] = workflow.codeBranch
productParams["SourceRepo"] = pipeline.Source.Repo
productParams["GitHubToken"] = params["GitHubToken"]

if workflow.codeBranch != "" {
productParams["SourceBranch"] = workflow.codeBranch
} else {
productParams["SourceBranch"] = pipeline.Source.Branch
}

if pipeline.Source.Provider == "GitHub" {
productParams["GitHubToken"] = params["GitHubToken"]
}

if pipeline.Source.Provider == "S3" {
repoParts := strings.Split(pipeline.Source.Repo, "/")
productParams["SourceBucket"] = repoParts[0]
productParams["SourceObjectKey"] = strings.Join(repoParts[1:], "/")
}

return catalogProvisioner.UpsertProvisionedProduct(stack.Outputs["ProductId"], pipeline.Catalog.Version, fmt.Sprintf("%s-%s", namespace, workflow.serviceName), productParams)
}
Expand Down

0 comments on commit 61dd938

Please sign in to comment.