mirror of https://github.com/knative/func.git
feat: PAC - dynamically generate Pipeline target branch (#1636)
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
This commit is contained in:
parent
85d3d0206e
commit
c793fd4c88
|
@ -27,6 +27,9 @@ const (
|
|||
// S2I related properties
|
||||
defaultS2iImageScriptsUrl = "image:///usr/libexec/s2i"
|
||||
quarkusS2iImageScriptsUrl = "image:///usr/local/s2i"
|
||||
|
||||
// The branch or tag we are targeting with Pipelines (ie: main, refs/tags/*)
|
||||
defaultPipelinesTargetBranch = "main"
|
||||
)
|
||||
|
||||
type templateData struct {
|
||||
|
@ -44,6 +47,9 @@ type templateData struct {
|
|||
PvcName string
|
||||
SecretName string
|
||||
|
||||
// The branch or tag we are targeting with Pipelines (ie: main, refs/tags/*)
|
||||
PipelinesTargetBranch string
|
||||
|
||||
// Static entries
|
||||
RepoUrl string
|
||||
Revision string
|
||||
|
@ -85,6 +91,11 @@ func createPipelineRunTemplate(f fn.Function) error {
|
|||
contextDir = "."
|
||||
}
|
||||
|
||||
pipelinesTargetBranch := f.Build.Git.Revision
|
||||
if pipelinesTargetBranch == "" {
|
||||
pipelinesTargetBranch = defaultPipelinesTargetBranch
|
||||
}
|
||||
|
||||
buildEnvs := []string{}
|
||||
if len(f.Build.BuildEnvs) == 0 {
|
||||
buildEnvs = []string{"="}
|
||||
|
@ -114,6 +125,8 @@ func createPipelineRunTemplate(f fn.Function) error {
|
|||
PvcName: getPipelinePvcName(f),
|
||||
SecretName: getPipelineSecretName(f),
|
||||
|
||||
PipelinesTargetBranch: pipelinesTargetBranch,
|
||||
|
||||
GitCloneTaskRef: taskGitCloneRef,
|
||||
FuncBuildpacksTaskRef: taskFuncBuildpacksRef,
|
||||
FuncS2iTaskRef: taskFuncS2iRef,
|
||||
|
|
|
@ -114,7 +114,7 @@ metadata:
|
|||
pipelinesascode.tekton.dev/on-event: "[push]"
|
||||
|
||||
# The branch or tag we are targeting (ie: main, refs/tags/*)
|
||||
pipelinesascode.tekton.dev/on-target-branch: "[main]"
|
||||
pipelinesascode.tekton.dev/on-target-branch: "[{{.PipelinesTargetBranch}}]"
|
||||
|
||||
# Fetch the git-clone task from hub
|
||||
pipelinesascode.tekton.dev/task: {{.GitCloneTaskRef}}
|
||||
|
|
|
@ -122,7 +122,7 @@ metadata:
|
|||
pipelinesascode.tekton.dev/on-event: "[push]"
|
||||
|
||||
# The branch or tag we are targeting (ie: main, refs/tags/*)
|
||||
pipelinesascode.tekton.dev/on-target-branch: "[main]"
|
||||
pipelinesascode.tekton.dev/on-target-branch: "[{{.PipelinesTargetBranch}}]"
|
||||
|
||||
# Fetch the git-clone task from hub
|
||||
pipelinesascode.tekton.dev/task: {{.GitCloneTaskRef}}
|
||||
|
|
Loading…
Reference in New Issue