Skip to content

Commit 46808fe

Browse files
authored
fix: Use tlsVerify param in PipelineRun template for pack too (#3575)
* Use tlsVerify param in Pipeline template for pack too * Use CNB_INSECURE_REGISTRIES in buildpack create task when TLSVERIFY is set to false * Remove create task script and set CNB_INSECURE_REGISTRIES conditionally in template parsing * Update createPipelineTemplatePAC to provision tlsVerify too
1 parent 2925849 commit 46808fe

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

pkg/pipelines/tekton/task-buildpack.yaml.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ spec:
6161
- name: PLATFORM_DIR
6262
description: The name of the platform directory.
6363
default: empty-dir
64+
- name: INSECURE_REGISTRIES
65+
description: Registries to access without TLS verification
66+
default: ""
6467
stepTemplate:
6568
env:
6669
- name: CNB_PLATFORM_API
@@ -199,6 +202,8 @@ spec:
199202
env:
200203
- name: DOCKER_CONFIG
201204
value: $(workspaces.dockerconfig.path)
205+
- name: CNB_INSECURE_REGISTRIES
206+
value: $(params.INSECURE_REGISTRIES)
202207
args:
203208
- "-app=$(workspaces.source.path)/$(params.SOURCE_SUBPATH)"
204209
- "-cache-dir=$(workspaces.cache.path)"

pkg/pipelines/tekton/templates.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,19 @@ type templateData struct {
9595
// createPipelineTemplatePAC creates a Pipeline template used for PAC on-cluster build
9696
// it creates the resource in the project directory
9797
func createPipelineTemplatePAC(f fn.Function, labels map[string]string) error {
98+
// Determine if TLS verification should be skipped
99+
tlsVerify := "true"
100+
if f.RegistryInsecure || isInsecureRegistry(f.Registry) {
101+
tlsVerify = "false"
102+
}
103+
98104
data := templateData{
99105
FunctionName: f.Name,
100106
Annotations: f.Deploy.Annotations,
101107
Labels: labels,
102108
PipelineName: getPipelineName(f),
109+
TlsVerify: tlsVerify,
110+
Registry: f.Registry,
103111
}
104112

105113
for _, val := range []struct {
@@ -294,11 +302,19 @@ func createAndApplyPipelineTemplate(f fn.Function, namespace string, labels map[
294302
// If Git is set up create fetch task and reference it from build task,
295303
// otherwise sources have been already uploaded to workspace PVC.
296304

305+
// Determine if TLS verification should be skipped
306+
tlsVerify := "true"
307+
if f.RegistryInsecure || isInsecureRegistry(f.Registry) {
308+
tlsVerify = "false"
309+
}
310+
297311
data := templateData{
298312
FunctionName: f.Name,
299313
Annotations: f.Deploy.Annotations,
300314
Labels: labels,
301315
PipelineName: getPipelineName(f),
316+
Registry: f.Registry,
317+
TlsVerify: tlsVerify,
302318
}
303319

304320
for _, val := range []struct {

pkg/pipelines/tekton/templates_pack.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ spec:
5858
- name: ENV_VARS
5959
value:
6060
- '$(params.buildEnvs[*])'
61+
{{- if eq .TlsVerify "false"}}
62+
- name: INSECURE_REGISTRIES
63+
value: $(params.registry)
64+
{{- end}}
6165
{{.FuncBuildpacksTaskRef}}
6266
workspaces:
6367
- name: source

0 commit comments

Comments
 (0)