From fbe2e5215bcd051f5da043fa66bf48881926b29e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 12:23:07 +0000 Subject: [PATCH] Bump github.com/openshift-pipelines/pipelines-as-code Bumps [github.com/openshift-pipelines/pipelines-as-code](https://github.com/openshift-pipelines/pipelines-as-code) from 0.21.4 to 0.21.5. - [Release notes](https://github.com/openshift-pipelines/pipelines-as-code/releases) - [Changelog](https://github.com/openshift-pipelines/pipelines-as-code/blob/main/.goreleaser.yml) - [Commits](https://github.com/openshift-pipelines/pipelines-as-code/compare/v0.21.4...v0.21.5) --- updated-dependencies: - dependency-name: github.com/openshift-pipelines/pipelines-as-code dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- .../pkg/cmd/tknpac/create/repository.go | 2 +- .../pkg/cmd/tknpac/generate/generate.go | 11 +++++---- .../pkg/cmd/tknpac/generate/template.go | 5 ++++ .../tknpac/generate/templates/generic.yaml | 1 - .../pkg/formatting/k8names.go | 23 +++++++++++++++++++ .../pkg/kubeinteraction/cleanups.go | 6 ++--- .../pkg/params/version/version.txt | 2 +- vendor/modules.txt | 2 +- 10 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/formatting/k8names.go diff --git a/go.mod b/go.mod index 359712ac9..b21e01f36 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( ) require ( - github.com/openshift-pipelines/pipelines-as-code v0.21.4 + github.com/openshift-pipelines/pipelines-as-code v0.21.5 github.com/spf13/cobra v1.7.0 github.com/tektoncd/cli v0.32.2 github.com/tektoncd/results/tools/tkn-results v0.0.0-20230922135423-d93166e0e127 diff --git a/go.sum b/go.sum index d8a3a685f..221926dd3 100644 --- a/go.sum +++ b/go.sum @@ -2228,8 +2228,8 @@ github.com/opencontainers/selinux v1.6.0/go.mod h1:VVGKuOLlE7v4PJyT6h7mNWvq1rzqi github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3ogry1nUQF8Evvo= github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8= github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= -github.com/openshift-pipelines/pipelines-as-code v0.21.4 h1:7QOlLWMArhsPJu2oPhpRSvTC0E553CoZ6BhN10vkytQ= -github.com/openshift-pipelines/pipelines-as-code v0.21.4/go.mod h1:Zg2pBr2y/XwLIpiFTlG71g3oORIMb8+7sCQaDJ7Jfss= +github.com/openshift-pipelines/pipelines-as-code v0.21.5 h1:jbKUUuidD6n78EI/Ibdb44BnlKImkcNttPGjcgyK0uQ= +github.com/openshift-pipelines/pipelines-as-code v0.21.5/go.mod h1:Zg2pBr2y/XwLIpiFTlG71g3oORIMb8+7sCQaDJ7Jfss= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= diff --git a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/create/repository.go b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/create/repository.go index c9002c535..c203b896a 100644 --- a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/create/repository.go +++ b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/create/repository.go @@ -252,7 +252,7 @@ func createRepoCRD(ctx context.Context, opts *RepoOptions) (string, string, erro if err != nil { return "", "", fmt.Errorf("invalid git URL: %s, it should be of format: https://gitprovider/project/repository", opts.Event.URL) } - repositoryName := strings.ReplaceAll(repoOwner, "/", "-") + repositoryName := formatting.CleanKubernetesName(repoOwner) opts.Repository, err = opts.Run.Clients.PipelineAsCode.PipelinesascodeV1alpha1().Repositories(opts.Repository.Namespace).Create( ctx, &apipac.Repository{ diff --git a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/generate.go b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/generate.go index 33cdb931b..64693b7a9 100644 --- a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/generate.go +++ b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/generate.go @@ -62,17 +62,20 @@ func Command(run *params.Run, ioStreams *cli.IOStreams) *cobra.Command { gopt.CLIOpts = cli.NewCliOptions() gopt.IOStreams.SetColorEnabled(!gopt.CLIOpts.NoColoring) - if !gopt.generateWithClusterTask { + if gopt.generateWithClusterTask { if err := run.Clients.NewClients(ctx, &run.Info); err != nil { // if we don't have access to the cluster we can't do much about it gopt.generateWithClusterTask = false } else { // NOTE(chmou): This is for v1beta1, we need to figure out how to do this for v1. // Trying to find resolver with that same name? - _, err := run.Clients.Tekton.TektonV1beta1().ClusterTasks().Get(ctx, gitCloneClusterTaskName, + _, err := run.Clients.Tekton.TektonV1beta1().ClusterTasks().Get(ctx, + gitCloneClusterTaskName, metav1.GetOptions{}) if err == nil { gopt.generateWithClusterTask = true + } else { + gopt.generateWithClusterTask = false } } } @@ -99,8 +102,8 @@ func Command(run *params.Run, ioStreams *cli.IOStreams) *cobra.Command { "Whether to overwrite the file if it exist") cmd.PersistentFlags().StringVarP(&gopt.language, "language", "l", "", "Generate for this programming language") - cmd.PersistentFlags().BoolVarP(&gopt.generateWithClusterTask, "use-clustertasks", "", false, - "By default we will generate the pipeline using task from hub. If you want to use cluster tasks, set this flag") + cmd.PersistentFlags().BoolVarP(&gopt.generateWithClusterTask, "use-clustertasks", "", true, + "By default we try to use the clustertasks unless not available") return cmd } diff --git a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/template.go b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/template.go index fdd93b466..4ba026666 100644 --- a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/template.go +++ b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/template.go @@ -94,5 +94,10 @@ func (o *Opts) genTmpl() (*bytes.Buffer, error) { tmplB = bytes.ReplaceAll(tmplB, []byte(fmt.Sprintf("name: pipelinerun-%s", lang)), []byte(fmt.Sprintf("name: %s", prName))) + if o.generateWithClusterTask { + tmplB = bytes.ReplaceAll(tmplB, []byte(fmt.Sprintf("name: %s", gitCloneClusterTaskName)), + []byte(fmt.Sprintf("name: %s\n kind: ClusterTask", gitCloneClusterTaskName))) + } + return bytes.NewBuffer(tmplB), nil } diff --git a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/templates/generic.yaml b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/templates/generic.yaml index d3382dc01..50f2d4093 100644 --- a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/templates/generic.yaml +++ b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/tknpac/generate/templates/generic.yaml @@ -45,7 +45,6 @@ spec: - name: fetch-repository taskRef: name: git-clone - kind: ClusterTask workspaces: - name: output workspace: source diff --git a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/formatting/k8names.go b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/formatting/k8names.go new file mode 100644 index 000000000..e1a497a8d --- /dev/null +++ b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/formatting/k8names.go @@ -0,0 +1,23 @@ +package formatting + +import ( + "regexp" + "strings" +) + +// CleanKubernetesName takes a string and performs the following actions to make it a valid +// Kubernetes resource name: +// +// 1. Converts the string to lowercase. +// 2. Trims leading and trailing whitespace. +// 3. Replaces any characters that are not lowercase alphanumeric characters, '-', or '.' with '-'. +// +// The resulting string is a valid Kubernetes resource name. +// Reference https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names + +func CleanKubernetesName(s string) string { + regex := regexp.MustCompile(`[^a-z0-9\.-]`) + s = strings.TrimSpace(strings.ToLower(s)) + replaced := regex.ReplaceAllString(s, "-") + return replaced +} diff --git a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/kubeinteraction/cleanups.go b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/kubeinteraction/cleanups.go index f11f09515..544ae9276 100644 --- a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/kubeinteraction/cleanups.go +++ b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/kubeinteraction/cleanups.go @@ -44,9 +44,9 @@ func (k Interaction) CleanupPipelines(ctx context.Context, logger *zap.SugaredLo return err } - // Try to Delete the secret created for git-clone basic-auth, it should have been created with a owneref on the pipelinerun and due being deleted when the pipelinerun is deleted - // but in some cases of conflicts and the ownerRef not being set, the secret is not deleted and we need to delete it manually. - if secretName, ok := pr.GetAnnotations()[keys.GitAuthSecret]; ok { + // Try to Delete the secret created for git-clone basic-auth, it should have been created with a ownerRef on the pipelinerun and due being deleted when the pipelinerun is deleted + // but in some cases of conflicts and the ownerRef not being set, the secret is not deleted, and we need to delete it manually. + if secretName, ok := prun.GetAnnotations()[keys.GitAuthSecret]; ok { err = k.Run.Clients.Kube.CoreV1().Secrets(repo.GetNamespace()).Delete(ctx, secretName, metav1.DeleteOptions{}) if err == nil { logger.Infof("secret %s attached to pipelinerun %s has been deleted", secretName, prun.GetName()) diff --git a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/params/version/version.txt b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/params/version/version.txt index 3b8e435d3..e124b614e 100644 --- a/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/params/version/version.txt +++ b/vendor/github.com/openshift-pipelines/pipelines-as-code/pkg/params/version/version.txt @@ -1 +1 @@ -v0.21.3 +v0.21.4 diff --git a/vendor/modules.txt b/vendor/modules.txt index 7bc86721f..927f6fe41 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1069,7 +1069,7 @@ github.com/opencontainers/go-digest ## explicit; go 1.18 github.com/opencontainers/image-spec/specs-go github.com/opencontainers/image-spec/specs-go/v1 -# github.com/openshift-pipelines/pipelines-as-code v0.21.4 +# github.com/openshift-pipelines/pipelines-as-code v0.21.5 ## explicit; go 1.19 github.com/openshift-pipelines/pipelines-as-code/pkg/acl github.com/openshift-pipelines/pipelines-as-code/pkg/action