GeezerVison is showing github.com — Pass --registry-insecure flag to Tekton pipeline tlsVerify parameter … · creydr/knative-func@da21fa2
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: cmd/client.go +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -62,7 +62,7 @@ func NewClient(cfg ClientConfig, options ...fn.Option) (*fn.Client, func()) { | 62 | 62 | t = newTransport(cfg.InsecureSkipVerify) // may provide a custom impl which proxies | 63 | 63 | c = newCredentialsProvider(config.Dir(), t, "") // for accessing registries | 64 | 64 | d = newKnativeDeployer(cfg.Verbose) // default deployer (can be overridden via options) | 65 | | - pp = newTektonPipelinesProvider(c, cfg.Verbose) | | 65 | + pp = newTektonPipelinesProvider(c, cfg.Verbose, cfg.InsecureSkipVerify) | 66 | 66 | o = []fn.Option{ // standard (shared) options for all commands | 67 | 67 | fn.WithVerbose(cfg.Verbose), | 68 | 68 | fn.WithTransport(t), | @@ -143,10 +143,11 @@ func newCredentialsProvider(configPath string, t http.RoundTripper, authFilePath | 143 | 143 | return creds.NewCredentialsProvider(configPath, options...) | 144 | 144 | } | 145 | 145 |
| 146 | | -func newTektonPipelinesProvider(creds oci.CredentialsProvider, verbose bool) *tekton.PipelinesProvider { | | 146 | +func newTektonPipelinesProvider(creds oci.CredentialsProvider, verbose bool, registryInsecure bool) *tekton.PipelinesProvider { | 147 | 147 | options := []tekton.Opt{ | 148 | 148 | tekton.WithCredentialsProvider(creds), | 149 | 149 | tekton.WithVerbose(verbose), | | 150 | + tekton.WithRegistryInsecure(registryInsecure), | 150 | 151 | tekton.WithPipelineDecorator(deployDecorator{}), | 151 | 152 | } | 152 | 153 |
| |
Collapse file Copy file name to clipboardExpand all lines: cmd/deploy.go +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -778,7 +778,7 @@ func (c deployConfig) clientOptions() ([]fn.Option, error) { | 778 | 778 |
| 779 | 779 | // Override the pipelines provider to use custom credentials | 780 | 780 | // This is needed for remote builds (deploy --remote) | 781 | | - o = append(o, fn.WithPipelinesProvider(newTektonPipelinesProvider(creds, c.Verbose))) | | 781 | + o = append(o, fn.WithPipelinesProvider(newTektonPipelinesProvider(creds, c.Verbose, c.RegistryInsecure))) | 782 | 782 |
| 783 | 783 | // Add the appropriate deployer based on deploy type | 784 | 784 | deployer := c.Deployer | |
Collapse file Copy file name to clipboardExpand all lines: pkg/pipelines/tekton/pipelines_pac_provider.go +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -129,7 +129,7 @@ func (pp *PipelinesProvider) createLocalPACResources(ctx context.Context, f fn.F | 129 | 129 | return err | 130 | 130 | } | 131 | 131 |
| 132 | | - err = createPipelineRunTemplatePAC(f, labels) | | 132 | + err = createPipelineRunTemplatePAC(f, labels, pp.registryInsecure) | 133 | 133 | if err != nil { | 134 | 134 | return err | 135 | 135 | } | |
Collapse file Copy file name to clipboardExpand all lines: pkg/pipelines/tekton/pipelines_provider.go +8-1Lines changed: 8 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -52,6 +52,7 @@ type pacURLCallback = func() (string, error) | 52 | 52 |
| 53 | 53 | type PipelinesProvider struct { | 54 | 54 | verbose bool | | 55 | + registryInsecure bool | 55 | 56 | getPacURL pacURLCallback | 56 | 57 | credentialsProvider oci.CredentialsProvider | 57 | 58 | decorator PipelineDecorator | @@ -69,6 +70,12 @@ func WithVerbose(verbose bool) Opt { | 69 | 70 | } | 70 | 71 | } | 71 | 72 |
| | 73 | +func WithRegistryInsecure(insecure bool) Opt { | | 74 | + return func(pp *PipelinesProvider) { | | 75 | + pp.registryInsecure = insecure | | 76 | + } | | 77 | +} | | 78 | + | 72 | 79 | func WithPipelineDecorator(decorator PipelineDecorator) Opt { | 73 | 80 | return func(pp *PipelinesProvider) { | 74 | 81 | pp.decorator = decorator | @@ -203,7 +210,7 @@ func (pp *PipelinesProvider) Run(ctx context.Context, f fn.Function) (string, fn | 203 | 210 | return "", f, fmt.Errorf("problem in creating secret: %v", err) | 204 | 211 | } | 205 | 212 |
| 206 | | - err = createAndApplyPipelineRunTemplate(f, namespace, labels) | | 213 | + err = createAndApplyPipelineRunTemplate(f, namespace, labels, pp.registryInsecure) | 207 | 214 | if err != nil { | 208 | 215 | return "", f, fmt.Errorf("problem in creating pipeline run: %v", err) | 209 | 216 | } | |
Collapse file Copy file name to clipboardExpand all lines: pkg/pipelines/tekton/templates.go +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -131,7 +131,7 @@ func createPipelineTemplatePAC(f fn.Function, labels map[string]string) error { | 131 | 131 |
| 132 | 132 | // createPipelineRunTemplatePAC creates a PipelineRun template used for PAC on-cluster build | 133 | 133 | // it creates the resource in the project directory | 134 | | -func createPipelineRunTemplatePAC(f fn.Function, labels map[string]string) error { | | 134 | +func createPipelineRunTemplatePAC(f fn.Function, labels map[string]string, registryInsecure bool) error { | 135 | 135 | contextDir := f.Build.Git.ContextDir | 136 | 136 | if contextDir == "" && f.Build.Builder == builders.S2I { | 137 | 137 | // TODO(lkingland): could instead update S2I to interpret empty string | @@ -167,7 +167,7 @@ func createPipelineRunTemplatePAC(f fn.Function, labels map[string]string) error | 167 | 167 |
| 168 | 168 | // Determine if TLS verification should be skipped | 169 | 169 | tlsVerify := "true" | 170 | | - if isInsecureRegistry(f.Registry) { | | 170 | + if registryInsecure || isInsecureRegistry(f.Registry) { | 171 | 171 | tlsVerify = "false" | 172 | 172 | } | 173 | 173 |
| @@ -330,7 +330,7 @@ func createAndApplyPipelineTemplate(f fn.Function, namespace string, labels map[ | 330 | 330 |
| 331 | 331 | // createAndApplyPipelineRunTemplate creates and applies PipelineRun template for a standard on-cluster build | 332 | 332 | // all resources are created on the fly, if there's a PipelineRun defined in the project directory, it is used instead | 333 | | -func createAndApplyPipelineRunTemplate(f fn.Function, namespace string, labels map[string]string) error { | | 333 | +func createAndApplyPipelineRunTemplate(f fn.Function, namespace string, labels map[string]string, registryInsecure bool) error { | 334 | 334 | contextDir := f.Build.Git.ContextDir | 335 | 335 | if contextDir == "" && f.Build.Builder == builders.S2I { | 336 | 336 | // TODO(lkingland): could instead update S2I to interpret empty string | @@ -366,7 +366,7 @@ func createAndApplyPipelineRunTemplate(f fn.Function, namespace string, labels m | 366 | 366 |
| 367 | 367 | // Determine if TLS verification should be skipped | 368 | 368 | tlsVerify := "true" | 369 | | - if isInsecureRegistry(f.Registry) { | | 369 | + if registryInsecure || isInsecureRegistry(f.Registry) { | 370 | 370 | tlsVerify = "false" | 371 | 371 | } | 372 | 372 |
| |
Collapse file Copy file name to clipboardExpand all lines: pkg/pipelines/tekton/templates_test.go +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -147,7 +147,7 @@ func Test_createPipelineRunTemplatePAC(t *testing.T) { | 147 | 147 | f.Image = "docker.io/alice/" + f.Name | 148 | 148 | f.Registry = TestRegistry | 149 | 149 |
| 150 | | - err = createPipelineRunTemplatePAC(f, make(map[string]string)) | | 150 | + err = createPipelineRunTemplatePAC(f, make(map[string]string), false) | 151 | 151 |
| 152 | 152 | if (err != nil) != tt.wantErr { | 153 | 153 | t.Errorf("createPipelineRunTemplate() error = %v, wantErr %v", err, tt.wantErr) | @@ -316,7 +316,7 @@ func Test_createAndApplyPipelineRunTemplate(t *testing.T) { | 316 | 316 | f.Image = "docker.io/alice/" + f.Name | 317 | 317 | f.Registry = TestRegistry | 318 | 318 |
| 319 | | - if err := createAndApplyPipelineRunTemplate(f, tt.namespace, tt.labels); (err != nil) != tt.wantErr { | | 319 | + if err := createAndApplyPipelineRunTemplate(f, tt.namespace, tt.labels, false); (err != nil) != tt.wantErr { | 320 | 320 | t.Errorf("createAndApplyPipelineRunTemplate() error = %v, wantErr %v", err, tt.wantErr) | 321 | 321 | } | 322 | 322 | }) | |
|