diff --git a/.tekton/create-ci-image-pipelinerun.yaml b/.tekton/create-ci-image-pipelinerun.yaml index 62151069..ff5bac15 100644 --- a/.tekton/create-ci-image-pipelinerun.yaml +++ b/.tekton/create-ci-image-pipelinerun.yaml @@ -102,6 +102,8 @@ spec: value: $(tasks.generate-image-name.results.image-name) - name: DOCKERFILE value: ./Dockerfile.CI + - name: TLSVERIFY + value: 'true' runAfter: - generate-image-name workspaces: @@ -129,11 +131,15 @@ spec: value: $(tasks.generate-image-name.results.image-name) - name: DOCKERFILE value: ./Dockerfile.CI + - name: TLSVERIFY + value: 'true' runAfter: - generate-image-name workspaces: - name: source workspace: source + - name: dockerconfig + workspace: dockerconfig when: - input: "{{ event_type }}" operator: in @@ -157,6 +163,10 @@ spec: value: docker://$(tasks.generate-image-name.results.image-name) - name: DESTINATION_IMAGE_URL value: docker://$(tasks.generate-image-name.results.image-name-timestamp) + - name: SRC_TLS_VERIFY + value: 'false' + - name: DEST_TLS_VERIFY + value: 'true' runAfter: - buildah-push - buildah-pull-request diff --git a/Dockerfile.CI b/Dockerfile.CI index 3e67c2ff..e592b740 100644 --- a/Dockerfile.CI +++ b/Dockerfile.CI @@ -10,10 +10,10 @@ RUN wget https://certs.corp.redhat.com/certs/Current-IT-Root-CAs.pem \ -O /etc/pki/ca-trust/source/anchors/Current-IT-Root-CAs.pem && \ update-ca-trust extract -RUN wget https://github.com/mikefarah/yq/releases/download/v4.45.1/yq_linux_amd64 -O /usr/bin/yq &&\ +RUN wget https://github.com/mikefarah/yq/releases/download/v4.50.1/yq_linux_amd64 -O /usr/bin/yq &&\ chmod +x /usr/bin/yq -ENV OC_VERSION=4.18 +ENV OC_VERSION=4.19 RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/fast-${OC_VERSION}/openshift-client-linux.tar.gz \ -O /tmp/openshift-client.tar.gz &&\ tar xzf /tmp/openshift-client.tar.gz -C /usr/bin oc &&\ @@ -37,7 +37,7 @@ RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/rosa/latest/rosa- tar xzf /tmp/rosa.tar.gz -C /usr/bin --no-same-owner rosa &&\ rm /tmp/rosa.tar.gz -ENV TKN_VERSION=1.18.0 +ENV TKN_VERSION=1.20.0 RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/pipelines/${TKN_VERSION}/tkn-linux-amd64.tar.gz \ -O /tmp/tkn.tar.gz &&\ tar xzf /tmp/tkn.tar.gz -C /usr/bin --no-same-owner tkn tkn-pac opc &&\ @@ -46,7 +46,7 @@ RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/pipelines/${TKN_V RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc -O /usr/bin/mc &&\ chmod u+x /usr/bin/mc -ENV GAUGE_VERSION=1.6.16 +ENV GAUGE_VERSION=1.6.20 RUN wget https://github.com/getgauge/gauge/releases/download/v${GAUGE_VERSION}/gauge-${GAUGE_VERSION}-linux.x86_64.zip \ -O /tmp/gauge.zip &&\ unzip /tmp/gauge.zip gauge -d /usr/bin &&\ @@ -54,7 +54,8 @@ RUN wget https://github.com/getgauge/gauge/releases/download/v${GAUGE_VERSION}/g ln -s /usr/bin/oc /usr/bin/kubectl &&\ gauge install go &&\ gauge install html-report &&\ - gauge install xml-report &&\ + gauge uninstall xml-report &&\ + gauge install xml-report -v 0.5.3 &&\ gauge install reportportal -v 1.16.2 &&\ gauge config check_updates false &&\ gauge config runner_connection_timeout 600000 && \ @@ -62,13 +63,13 @@ RUN wget https://github.com/getgauge/gauge/releases/download/v${GAUGE_VERSION}/g go env -w GOPROXY="https://proxy.golang.org,direct" &&\ gauge version -RUN wget https://github.com/sigstore/cosign/releases/download/v2.5.0/cosign-linux-amd64 -O /usr/bin/cosign && \ +RUN wget https://github.com/sigstore/cosign/releases/download/v3.0.3/cosign-linux-amd64 -O /usr/bin/cosign && \ chmod a+x /usr/bin/cosign -RUN wget https://github.com/sigstore/rekor/releases/download/v1.3.10/rekor-cli-linux-amd64 -O /usr/bin/rekor-cli && \ +RUN wget https://github.com/sigstore/rekor/releases/download/v1.4.3/rekor-cli-linux-amd64 -O /usr/bin/rekor-cli && \ chmod u+x /usr/bin/rekor-cli -ENV GOLANGCI_LINT_VERSION=2.1.5 +ENV GOLANGCI_LINT_VERSION=2.7.2 RUN wget -O /tmp/golangci-lint.tar.gz https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz \ && tar --strip-components=1 -C /usr/bin -xzf /tmp/golangci-lint.tar.gz golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64/golangci-lint \ && rm -f /tmp/golangci-lint.tar.gz diff --git a/env/default/default.properties b/env/default/default.properties index a4a29761..26542607 100644 --- a/env/default/default.properties +++ b/env/default/default.properties @@ -43,14 +43,14 @@ CATALOG_SOURCE = redhat-operators SUBSCRIPTION_NAME = openshift-pipelines-operator-rh CHAINS_VERSION = v0.25 -HUB_VERSION = v1.21 -MANUAL_APPROVAL_VERSION = v0.6 -OPERATOR_VERSION = devel -OSP_VERSION = 5.0.5 -OSP_TUTORIAL_BRANCH = master -PAC_VERSION = 0.35 -PIPELINE_VERSION = v1.0 -RESULTS_VERSION = v0.15 +HUB_VERSION = v1.22 +MANUAL_APPROVAL_VERSION = v0.7 +OPERATOR_VERSION = 0.77 +OSP_VERSION = 1.20 +OSP_TUTORIAL_BRANCH = pipelines-1.20 +PAC_VERSION = 0.37 +PIPELINE_VERSION = v1.3 +RESULTS_VERSION = v0.16 TARGET = openshift -TKN_CLIENT_VERSION = 0.41 -TRIGGERS_VERSION = v0.32 +TKN_CLIENT_VERSION = 0.42 +TRIGGERS_VERSION = v0.33 diff --git a/manifest.json b/manifest.json index 336257ae..7fcddbda 100644 --- a/manifest.json +++ b/manifest.json @@ -3,5 +3,6 @@ "Plugins": [ "html-report", "xml-report" - ] -} \ No newline at end of file + ], + "EnvironmentDir": "" +} diff --git a/pkg/oc/oc.go b/pkg/oc/oc.go index 01fdf269..bd98fa97 100644 --- a/pkg/oc/oc.go +++ b/pkg/oc/oc.go @@ -127,6 +127,10 @@ func CreateSecretForGitResolver(secretData string) { cmd.MustSucceed("oc", "create", "secret", "generic", "github-auth-secret", "--from-literal", "github-auth-key="+secretData, "-n", "openshift-pipelines") } +func CreateSecretInNamespace(secretData, secretName, namespace string) { + cmd.MustSucceed("oc", "create", "secret", "generic", secretName, "--from-literal", "private-repo-token="+secretData, "-n", namespace) +} + func CreateSecretForWebhook(tokenSecretData, webhookSecretData, namespace string) { cmd.MustSucceed("oc", "create", "secret", "generic", "gitlab-webhook-config", "--from-literal", "provider.token="+tokenSecretData, "--from-literal", "webhook.secret="+webhookSecretData, "-n", namespace) } @@ -168,4 +172,4 @@ func CopySecret(secretName string, sourceNamespace string, destNamespace string) cmdOutput := cmd.MustSucceed("bash", "-c", fmt.Sprintf(`echo '%s' | jq 'del(.metadata["namespace", "creationTimestamp", "resourceVersion", "selfLink", "uid", "annotations"]) | .data |= with_entries(if .key == "github-auth-key" then .key = "token" else . end)'`, secretJson)).Stdout() cmd.MustSucceed("bash", "-c", fmt.Sprintf(`echo '%s' | kubectl apply -n %s -f -`, cmdOutput, destNamespace)) log.Printf("Successfully copied secret %s from %s to %s", secretName, sourceNamespace, destNamespace) -} +} \ No newline at end of file diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go index c57b20ea..e2c75eb2 100644 --- a/pkg/operator/operator.go +++ b/pkg/operator/operator.go @@ -42,15 +42,20 @@ func ValidateRBACAfterDisable(cs *clients.Clients, rnames utils.ResourceNames) { AssertServiceAccountPresent(cs, store.Namespace(), "pipeline") // Verify clusterrole does not create AssertClusterRoleNotPresent(cs, "pipelines-scc-clusterrole") - // Verify configmaps is not created in any namespace - AssertConfigMapNotPresent(cs, store.Namespace(), "config-service-cabundle") - AssertConfigMapNotPresent(cs, store.Namespace(), "config-trusted-cabundle") // Verify roleBindings is not created in any namespace AssertRoleBindingNotPresent(cs, store.Namespace(), "edit") AssertRoleBindingNotPresent(cs, store.Namespace(), "pipelines-scc-rolebinding") AssertSCCNotPresent(cs, "pipelines-scc") } +func ValidateCABundleConfigMaps(cs *clients.Clients, rnames utils.ResourceNames) { + log.Printf("Verifying that TektonConfig status is \"installed\"\n") + EnsureTektonConfigStatusInstalled(cs.TektonConfig(), rnames) + // Verify CA Bundle ConfigMaps are created + AssertConfigMapPresent(cs, store.Namespace(), "config-service-cabundle") + AssertConfigMapPresent(cs, store.Namespace(), "config-trusted-cabundle") +} + func ValidatePipelineDeployments(cs *clients.Clients, rnames utils.ResourceNames) { if _, err := EnsureTektonPipelineExists(cs.TektonPipeline(), rnames); err != nil { testsuit.T.Fail(fmt.Errorf("TektonPipelines doesn't exists\n %v", err)) diff --git a/pkg/pac/pac.go b/pkg/pac/pac.go index 8c231006..5a40de04 100644 --- a/pkg/pac/pac.go +++ b/pkg/pac/pac.go @@ -3,8 +3,10 @@ package pac import ( "bytes" "context" + "crypto/rand" "fmt" "log" + "math/big" "net/url" "os" "os/exec" @@ -39,6 +41,8 @@ const ( maxRetriesPipelineStatus = 10 targetURL = "http://pipelines-as-code-controller.openshift-pipelines:8080" webhookConfigName = "gitlab-webhook-config" + pullRequestFileName = "/tmp/pull_request.yaml" + pushFileName = "/tmp/push.yaml" ) var client *gitlab.Client @@ -57,60 +61,55 @@ func InitGitLabClient() *gitlab.Client { if !oc.SecretExists(webhookConfigName, store.Namespace()) { oc.CreateSecretForWebhook(tokenSecretData, webhookSecretData, store.Namespace()) } else { - log.Printf("Secret \"%s\" already exists", webhookConfigName) + log.Printf("Secret %q already exists", webhookConfigName) } } client, err := gitlab.NewClient(tokenSecretData) if err != nil { testsuit.T.Fail(fmt.Errorf("failed to initialize GitLab client: %v", err)) } - return client } func getNewSmeeURL() (string, error) { // CURL cmd to retrieve a new smeeURL curlCommand := `curl -Ls -o /dev/null -w %{url_effective} https://smee.io/new` - cmd := exec.Command("sh", "-c", curlCommand) output, err := cmd.Output() if err != nil { return "", fmt.Errorf("failed to create SmeeURL: %v", err) } - smeeURL := strings.TrimSpace(string(output)) - if smeeURL == "" { return "", fmt.Errorf("failed to retrieve Smee URL: no URL found") } - return smeeURL, nil } func createSmeeDeployment(c *clients.Clients, namespace, smeeURL string) error { - /* - Reference for gosmee.yaml - https://github.com/openshift-pipelines/pipelines-as-code - /blob/main/pkg/cmd/tknpac/bootstrap/templates/gosmee.yaml - */ + kc := c.KubeClient.Kube + deploymentsClient := kc.AppsV1().Deployments(namespace) + existing, err := deploymentsClient.Get(context.TODO(), "gosmee-client", metav1.GetOptions{}) + if err == nil && existing != nil { + log.Printf("Deployment %q already present in %q; leaving as-is", "gosmee-client", namespace) + return nil + } + replicas := int32(1) deployment := &v1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: "gosmee-client", + Labels: map[string]string{ + "app": "gosmee-client", + }, }, Spec: v1.DeploymentSpec{ Replicas: &replicas, Selector: &metav1.LabelSelector{ - MatchLabels: map[string]string{ - "app": "gosmee-client", - }, + MatchLabels: map[string]string{"app": "gosmee-client"}, }, Template: corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: map[string]string{ - "app": "gosmee-client", - }, - }, + ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{"app": "gosmee-client"}}, Spec: corev1.PodSpec{ Containers: []corev1.Container{ { @@ -123,14 +122,8 @@ func createSmeeDeployment(c *clients.Clients, namespace, smeeURL string) error { targetURL, }, Env: []corev1.EnvVar{ - { - Name: "SMEE_URL", - Value: smeeURL, - }, - { - Name: "TARGET_URL", - Value: targetURL, - }, + {Name: "SMEE_URL", Value: smeeURL}, + {Name: "TARGET_URL", Value: targetURL}, }, }, }, @@ -139,13 +132,10 @@ func createSmeeDeployment(c *clients.Clients, namespace, smeeURL string) error { }, } - kc := c.KubeClient.Kube - deploymentsClient := kc.AppsV1().Deployments(namespace) result, err := deploymentsClient.Create(context.TODO(), deployment, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("failed to create deployment: %v", err) } - log.Printf("Created deployment %q in namespace %q.\n", result.GetObjectMeta().GetName(), namespace) return nil } @@ -240,7 +230,7 @@ func createNewRepository(c *clients.Clients, projectName, targetGroupNamespace, return fmt.Errorf("failed to create repository: %v", err) } - log.Printf("Repository '%s' created successfully in namespace '%s'", repo.GetName(), repo.GetNamespace()) + log.Printf("Repository %q created successfully in namespace %q", repo.GetName(), repo.GetNamespace()) return nil } @@ -251,10 +241,9 @@ func addLabelToProject(projectID int, labelName, color, description string) erro if err != nil { return fmt.Errorf("failed to fetch project labels: %w", err) } - for _, label := range labels { if label.Name == labelName { - log.Printf("Label '%s' already exists in project ID %d\n", labelName, projectID) + log.Printf("Label %q already exists in project ID %d\n", labelName, projectID) return nil } } @@ -265,12 +254,10 @@ func addLabelToProject(projectID int, labelName, color, description string) erro Color: gitlab.Ptr(color), Description: gitlab.Ptr(description), }) - if err != nil { - return fmt.Errorf("failed to create label '%s': %w", labelName, err) + return fmt.Errorf("failed to create label %q: %w", labelName, err) } - - log.Printf("Successfully added label '%s' to project ID %d\n", labelName, projectID) + log.Printf("Successfully added label %q to project ID %d\n", labelName, projectID) return nil } @@ -306,7 +293,6 @@ func SetupGitLabProject() *gitlab.Project { // adds a comment to the specified merge request. func AddComment(comment string) { - projectID, _ := strconv.Atoi(store.GetScenarioData("projectID")) mrID, _ := strconv.Atoi(store.GetScenarioData("mrID")) opts := &gitlab.CreateMergeRequestNoteOptions{ @@ -321,7 +307,6 @@ func AddComment(comment string) { } func AddLabel(label, color, description string) { - projectID, _ := strconv.Atoi(store.GetScenarioData("projectID")) mrID, _ := strconv.Atoi(store.GetScenarioData("mrID")) @@ -340,7 +325,6 @@ func AddLabel(label, color, description string) { if err != nil { testsuit.T.Fail(fmt.Errorf("failed to update merge request with label 'bug': %w", err)) } - log.Printf("Successfully added label %s to merge request %d\n", label, mrID) } @@ -363,7 +347,6 @@ func createPacGenerateOpts(eventType, branch, fileName string) *pacgenerate.Opts BaseBranch: branch, } // Set Project URL and Branch name to GitInfo - // ProjectURL is used as PipelineRun name with suffix opts.GitInfo = &git.Info{ URL: store.GetScenarioData("PROJECT_URL"), Branch: branch, @@ -381,27 +364,24 @@ func createPacGenerateOpts(eventType, branch, fileName string) *pacgenerate.Opts return opts } -// Generate sample PipelineRun, pull-request.yaml +// Generate sample PipelineRun, pull-request.yaml or push.yaml func generatePipelineRun(eventType, branch, fileName string) error { + if _, err := os.Stat(fileName); err == nil { + _ = os.Remove(fileName) + } opts := createPacGenerateOpts(eventType, branch, fileName) - - err := pacgenerate.Generate(opts, true) - if err != nil { + if err := pacgenerate.Generate(opts, true); err != nil { return fmt.Errorf("failed to generate PipelineRun: %v", err) } - return nil } // Validate generated yaml file from pac generate cmd func validateYAML(yamlContent []byte) error { - var content map[string]interface{} - - err := yaml.Unmarshal(yamlContent, &content) - if err != nil { + var content map[string]any + if err := yaml.Unmarshal(yamlContent, &content); err != nil { return fmt.Errorf("invalid YAML format: %v", err) } - return nil } @@ -421,27 +401,36 @@ func GeneratePipelineRunYaml(eventType, branch string) { if err := validateYAML(fileContent); err != nil { testsuit.T.Fail(fmt.Errorf("invalid YAML content: %v", err)) } - store.PutScenarioData("fileContent", string(fileContent)) - store.PutScenarioData("branch", string(branch)) - store.PutScenarioData("fileName", string(fileName)) + var destPath string + switch eventType { + case "pull_request": + destPath = pullRequestFileName + case "push": + destPath = pushFileName + default: + testsuit.T.Fail(fmt.Errorf("unknown eventType: %s", eventType)) + } + if err := os.WriteFile(destPath, fileContent, 0600); err != nil { + testsuit.T.Fail(fmt.Errorf("failed to write %s: %v", destPath, err)) + } } // updateAnnotation updates the specified annotation in the pull-request.yaml file func UpdateAnnotation(annotationKey, annotationValue string) { - fileName := store.GetScenarioData("fileName") + fileName := pullRequestFileName data, err := os.ReadFile(filepath.Clean(fileName)) if err != nil { testsuit.T.Fail(fmt.Errorf("failed to read YAML file: %v", err)) } - var content map[string]interface{} + var content map[string]any if err := yaml.Unmarshal(data, &content); err != nil { testsuit.T.Fail(fmt.Errorf("failed to unmarshal YAML: %v", err)) } - meta := content["metadata"].(map[interface{}]interface{}) - anns := meta["annotations"].(map[interface{}]interface{}) + meta := content["metadata"].(map[any]any) + anns := meta["annotations"].(map[any]any) // If the annotation exists, append the new value; otherwise, set it. if currValue, exists := anns[annotationKey].(string); exists { @@ -464,24 +453,45 @@ func UpdateAnnotation(annotationKey, annotationValue string) { } store.PutScenarioData("fileContent", string(out)) - log.Println("Annotation updated successfully") } -func createCommit(projectID int, branch, commitMessage, fileDesPath string) error { - // Commit the PAC generated PLR - fileContent := store.GetScenarioData("fileContent") +// Commit both PR and push files preview branch +func createCommit(projectID int, branch, commitMessage, eventType string) error { action := gitlab.FileCreate + var actions []*gitlab.CommitActionOptions + + switch eventType { + case "pull_request": + data, err := os.ReadFile(pullRequestFileName) + if err != nil { + return fmt.Errorf("read PR file: %v", err) + } + actions = append(actions, &gitlab.CommitActionOptions{ + Action: &action, + FilePath: gitlab.Ptr(".tekton/pull-request.yaml"), + Content: gitlab.Ptr(string(data)), + }) + case "push": + data, err := os.ReadFile(pushFileName) + if err != nil { + return fmt.Errorf("read push file: %v", err) + } + actions = append(actions, &gitlab.CommitActionOptions{ + Action: &action, + FilePath: gitlab.Ptr(".tekton/push.yaml"), + Content: gitlab.Ptr(string(data)), + }) + default: + return fmt.Errorf("unknown eventType %q", eventType) + } + commitOpts := &gitlab.CreateCommitOptions{ Branch: &branch, CommitMessage: &commitMessage, - Actions: []*gitlab.CommitActionOptions{ - {Action: &action, FilePath: gitlab.Ptr(fileDesPath), Content: gitlab.Ptr(fileContent)}, - }, + Actions: actions, } - - _, _, err := client.Commits.CreateCommit(projectID, commitOpts) - if err != nil { + if _, _, err := client.Commits.CreateCommit(projectID, commitOpts); err != nil { return fmt.Errorf("failed to create commit: %v", err) } return nil @@ -521,95 +531,249 @@ func isTerminalStatus(status string) bool { } func checkPipelineStatus(projectID, mergeRequestID int) error { - var retryCount int + retryCount := 0 + delay := initialBackoffDuration + const maxDelay = 60 * time.Second - // Fetch pipelines for the specified MergeRequest ID for { - pipelines, _, err := client.MergeRequests.ListMergeRequestPipelines(projectID, mergeRequestID) + pipelinesList, _, err := client.MergeRequests.ListMergeRequestPipelines(projectID, mergeRequestID) if err != nil { return fmt.Errorf("failed to list merge request pipelines: %w", err) } - // Retry, If no pipelines found - if len(pipelines) == 0 { + if len(pipelinesList) == 0 { if retryCount >= maxRetriesPipelineStatus { log.Printf("No pipelines found for the MR id %d after %d retries\n", mergeRequestID, maxRetriesPipelineStatus) return nil } log.Println("No pipelines found, retrying...") + time.Sleep(delay) retryCount++ - time.Sleep(time.Duration(2^retryCount) * time.Second) + delay *= 2 + if delay > maxDelay { + delay = maxDelay + } continue } - // Check the status of the latest pipeline - latestPipeline := pipelines[0] + latestPipeline := pipelinesList[0] if isTerminalStatus(latestPipeline.Status) { log.Printf("Latest pipeline status for MR #%d: %s\n", mergeRequestID, latestPipeline.Status) return nil - } else { - log.Println("waiting for Pipeline status to be updated...") - time.Sleep(maxRetriesPipelineStatus * time.Second) } + log.Println("waiting for Pipeline status to be updated...") + time.Sleep(10 * time.Second) } } func ConfigurePreviewChanges() { - randomSuffix := strconv.FormatInt(time.Now().UnixNano(), 10)[:8] - branchName := "preview-branch-" + randomSuffix - commitMessage := "Add preview changes for feature" - fileDesPath := ".tekton/pull-request.yaml" - projectID, err := strconv.Atoi(store.GetScenarioData("projectID")) if err != nil { - testsuit.T.Fail(fmt.Errorf("failed to convert project ID to integer: %v", err)) + testsuit.T.Fail(fmt.Errorf("bad projectID: %v", err)) + } + + gen := func(n int) (string, error) { + const abc = "abcdefghijklmnopqrstuvwxyz0123456789" + out := make([]byte, n) + for i := range out { + k, err := rand.Int(rand.Reader, big.NewInt(int64(len(abc)))) + if err != nil { + return "", err + } + out[i] = abc[int(k.Int64())] + } + return string(out), nil + } + branchExists := func(name string) bool { + _, resp, err := client.Branches.GetBranch(projectID, name) + if err != nil { + if resp != nil && resp.StatusCode == 404 { + return false + } + testsuit.T.Fail(fmt.Errorf("GetBranch(%q): %v", name, err)) + } + return true + } + + var branchName string + for range 10 { + suf, err := gen(8) + if err != nil { + testsuit.T.Fail(err) + } + n := "preview-" + suf + if !branchExists(n) { + branchName = n + break + } + } + if branchName == "" { + branchName = "preview-branch-" + strings.ToLower(strconv.FormatInt(time.Now().UnixNano(), 36))[:8] } if err := createBranch(projectID, branchName); err != nil { - testsuit.T.Fail(fmt.Errorf("failed to create branch: %v", err)) + testsuit.T.Fail(fmt.Errorf("createBranch %q: %v", branchName, err)) + } + + prExists := false + pushExists := false + if _, err := os.Stat(pullRequestFileName); err == nil { + prExists = true + } + if _, err := os.Stat(pushFileName); err == nil { + pushExists = true } - if err := createCommit(projectID, branchName, commitMessage, fileDesPath); err != nil { - testsuit.T.Fail(fmt.Errorf("failed to create commit: %v", err)) + if prExists && pushExists { + action := gitlab.FileCreate + prData, err := os.ReadFile(pullRequestFileName) + if err != nil { + testsuit.T.Fail(fmt.Errorf("read PR file: %v", err)) + } + pushData, err := os.ReadFile(pushFileName) + if err != nil { + testsuit.T.Fail(fmt.Errorf("read push file: %v", err)) + } + msg := "ci(pac): add push & pull_request files" + commitOpts := &gitlab.CreateCommitOptions{ + Branch: &branchName, + CommitMessage: &msg, + Actions: []*gitlab.CommitActionOptions{ + {Action: &action, FilePath: gitlab.Ptr(".tekton/pull-request.yaml"), Content: gitlab.Ptr(string(prData))}, + {Action: &action, FilePath: gitlab.Ptr(".tekton/push.yaml"), Content: gitlab.Ptr(string(pushData))}, + }, + } + if _, _, err := client.Commits.CreateCommit(projectID, commitOpts); err != nil { + testsuit.T.Fail(fmt.Errorf("commit both: %v", err)) + } + } else if prExists { + if err := createCommit(projectID, branchName, "ci(pac): add pull_request file", "pull_request"); err != nil { + testsuit.T.Fail(fmt.Errorf("commit pull_request: %v", err)) + } + } else if pushExists { + if err := createCommit(projectID, branchName, "ci(pac): add push file", "push"); err != nil { + testsuit.T.Fail(fmt.Errorf("commit push: %v", err)) + } + } else { + testsuit.T.Fail(fmt.Errorf("no pipeline files found to commit in /tmp")) } mrURL, err := createMergeRequest(projectID, branchName, "main", "Add preview changes for feature") if err != nil { - testsuit.T.Fail(fmt.Errorf("failed to create merge request: %v", err)) + testsuit.T.Fail(fmt.Errorf("createMergeRequest: %v", err)) } - log.Printf("Merge Request Created: %s\n", mrURL) mrID, err := extractMergeRequestID(mrURL) if err != nil { - testsuit.T.Fail(fmt.Errorf("failed to extract merge request ID: %v", err)) + testsuit.T.Fail(fmt.Errorf("extract MR ID: %v", err)) } - store.PutScenarioData("mrID", strconv.Itoa(mrID)) } -func GetPipelineNameFromMR() (pipelineName string) { +// repoFileExists checks if file exists at path on the given branch. +func repoFileExists(projectID int, branch, path string) (bool, error) { + f, resp, err := client.RepositoryFiles.GetFile(projectID, path, &gitlab.GetFileOptions{Ref: gitlab.Ptr(branch)}) + if err != nil { + // If the API returns 404, it's simply absent; any other error is real + if resp != nil && resp.StatusCode == 404 { + return false, nil + } + return false, fmt.Errorf("GetFile failed for %s on %s: %w", path, branch, err) + } + return f != nil, nil +} + +func TriggerPushOnForkMain() { projectID, err := strconv.Atoi(store.GetScenarioData("projectID")) if err != nil { testsuit.T.Fail(fmt.Errorf("failed to convert project ID to integer: %v", err)) } - mrID, err := strconv.Atoi(store.GetScenarioData("mrID")) + + data, err := os.ReadFile("/tmp/push.yaml") if err != nil { - testsuit.T.Fail(fmt.Errorf("failed to convert project ID to integer: %v", err)) + testsuit.T.Fail(fmt.Errorf("failed to read /tmp/push.yaml: %v", err)) } + pushFileContent := string(data) - err = checkPipelineStatus(projectID, mrID) + branch := "main" + pushYamlPath := ".tekton/push.yaml" + triggerPath := fmt.Sprintf("ci/push-trigger-%d.txt", time.Now().Unix()) + + exists, err := repoFileExists(projectID, branch, pushYamlPath) if err != nil { - testsuit.T.Fail(fmt.Errorf("failed to check pipeline status: %v", err)) + testsuit.T.Fail(err) } - pipelineName, err = pipelines.GetLatestPipelinerun(store.Clients(), store.Namespace()) + var actionPushYaml gitlab.FileActionValue + if exists { + actionPushYaml = gitlab.FileUpdate + } else { + actionPushYaml = gitlab.FileCreate + } + + createAction := gitlab.FileCreate + + commitMsg := "ci(pac): add push.yaml on main and trigger push pipeline" + actions := []*gitlab.CommitActionOptions{ + { + Action: &actionPushYaml, + FilePath: gitlab.Ptr(pushYamlPath), + Content: gitlab.Ptr(pushFileContent), + }, + { + Action: &createAction, + FilePath: gitlab.Ptr(triggerPath), + Content: gitlab.Ptr("push-trigger"), + }, + } + + commitOpts := &gitlab.CreateCommitOptions{ + Branch: &branch, + CommitMessage: &commitMsg, + Actions: actions, + } + + if _, _, err := client.Commits.CreateCommit(projectID, commitOpts); err != nil { + testsuit.T.Fail(fmt.Errorf("failed to commit push.yaml+trigger to main: %v", err)) + } +} + +// GetPipelineName gets the latest pipeline run +func GetPipelineName(validateMR bool) (pipelineName string) { + if validateMR { + projectID, err := strconv.Atoi(store.GetScenarioData("projectID")) + if err != nil { + testsuit.T.Fail(fmt.Errorf("failed to convert project ID to integer: %v", err)) + } + mrID, err := strconv.Atoi(store.GetScenarioData("mrID")) + if err != nil { + testsuit.T.Fail(fmt.Errorf("failed to convert MR ID to integer: %v", err)) + } + + err = checkPipelineStatus(projectID, mrID) + if err != nil { + testsuit.T.Fail(fmt.Errorf("failed to check pipeline status: %v", err)) + } + } else { + time.Sleep(10 * time.Second) + } + + pipelineName, err := pipelines.GetLatestPipelinerun(store.Clients(), store.Namespace()) if err != nil { testsuit.T.Fail(fmt.Errorf("failed to get the latest Pipelinerun: %v", err)) } return pipelineName } +func GetPipelineNameFromMR() (pipelineName string) { + return GetPipelineName(true) +} + +func GetPushPipelineNameFromMain() (pipelineName string) { + return GetPipelineName(false) +} + func AssertPACInfoInstall() { pacInfo, err := opc.GetOpcPacInfoInstall() if err != nil { @@ -637,13 +801,9 @@ func deleteGitlabProject(projectID int) error { } func CleanupPAC(c *clients.Clients, smeeDeploymentName, namespace string) { - // Remove the generated PipelineRun YAML file - fileName := store.GetScenarioData("fileName") - if fileName != "" { - if err := os.Remove(fileName); err != nil { - testsuit.T.Fail(fmt.Errorf("failed to remove file %s: %v", fileName, err)) - } - } + // Remove the generated PipelineRun YAML files + os.Remove(pullRequestFileName) + os.Remove(pushFileName) projectID, err := strconv.Atoi(store.GetScenarioData("projectID")) if err != nil { @@ -655,8 +815,7 @@ func CleanupPAC(c *clients.Clients, smeeDeploymentName, namespace string) { } // Delete Smee Deployment - err = k8s.DeleteDeployment(c, namespace, smeeDeploymentName) - if err != nil { + if err = k8s.DeleteDeployment(c, namespace, smeeDeploymentName); err != nil { testsuit.T.Fail(fmt.Errorf("failed to Delete Smee Deployment: %v", err)) } } diff --git a/specs/ecosystem/ecosystem.spec b/specs/ecosystem/ecosystem.spec index a047f841..22f41ef8 100644 --- a/specs/ecosystem/ecosystem.spec +++ b/specs/ecosystem/ecosystem.spec @@ -42,6 +42,25 @@ Steps: |----|------------------------|----------| |1 |buildah-disconnected-run|successful| +## buildah-ns pipelinerun: PIPELINES-29-TC20 +Tags: e2e, ecosystem, tasks, non-admin, buildah-ns, sanity +Component: Pipelines +Level: Integration +Type: Functional +Importance: Critical + +Steps: + * Create + |S.NO|resource_dir | + |----|-------------------------------------------------| + |1 |testdata/ecosystem/pipelines/buildah-ns.yaml | + |2 |testdata/pvc/pvc.yaml | + |3 |testdata/ecosystem/pipelineruns/buildah-ns.yaml | + * Verify pipelinerun + |S.NO|pipeline_run_name|status | + |----|-----------------|----------| + |1 |buildah-ns-run |successful| + ## git-cli pipelinerun: PIPELINES-29-TC03 Tags: e2e, ecosystem, tasks, non-admin, git-cli Component: Pipelines diff --git a/specs/operator/rbac.spec b/specs/operator/rbac.spec index 7781e1c2..f9cad938 100644 --- a/specs/operator/rbac.spec +++ b/specs/operator/rbac.spec @@ -1,5 +1,5 @@ PIPELINES-11 -# Verify RBAC Resources +# Verify RBAC Resources and CA Bundle Configuration Pre condition: * Validate Operator should be installed @@ -14,9 +14,28 @@ Importance: High This scenario helps you to disable creation of RBAC resources at cluster level. Steps: - * Update TektonConfig CR to use param with name createRbacResource and value "true" to "enable" auto creation of RBAC resources + * Update TektonConfig CR to use param with name "createRbacResource" and value "true" to "enable" auto creation of "RBAC resources" * Verify RBAC resources are auto created successfully - * Update TektonConfig CR to use param with name createRbacResource and value "false" to "disable" auto creation of RBAC resources + * Update TektonConfig CR to use param with name "createRbacResource" and value "false" to "disable" auto creation of "RBAC resources" * Verify RBAC resources disabled successfully - * Update TektonConfig CR to use param with name createRbacResource and value "true" to "enable" auto creation of RBAC resources + * Update TektonConfig CR to use param with name "createRbacResource" and value "true" to "enable" auto creation of "RBAC resources" * Verify RBAC resources are auto created successfully + +## Independent CA Bundle ConfigMap creation control: PIPELINES-11-TC02 +Tags: e2e, cabundle-control, admin, sanity +Component: Operator +Level: Integration +Type: Functional +Importance: High + +This scenario helps you to enable CA Bundle ConfigMap creation at cluster level. + +Steps: + * Update TektonConfig CR to use param with name "createCABundleConfigMaps" and value "true" to "enable" auto creation of "CA Bundle ConfigMaps" + * Verify CA Bundle ConfigMaps are auto created successfully + * Update TektonConfig CR to use param with name "createCABundleConfigMaps" and value "false" to "disable" auto creation of "CA Bundle ConfigMaps" + * Verify CA Bundle ConfigMaps still exist + +Teardown: + * Update TektonConfig CR to use param with name "createRbacResource" and value "true" to "enable" auto creation of "RBAC resources" + * Update TektonConfig CR to use param with name "createCABundleConfigMaps" and value "true" to "enable" auto creation of "CA Bundle ConfigMaps" \ No newline at end of file diff --git a/specs/pac/pac-gitlab.spec b/specs/pac/pac-gitlab.spec index b6a8db90..56b706ff 100644 --- a/specs/pac/pac-gitlab.spec +++ b/specs/pac/pac-gitlab.spec @@ -8,15 +8,18 @@ Level: Integration Type: Functional Importance: Critical -This scenario tests configuring PAC in Public GitLab project +This scenario tests configuring PAC with push and pull_request events Steps: - * Setup Gitlab Client * Validate PAC Info Install + * Setup Gitlab Client * Create Smee deployment * Configure GitLab repo for "pull_request" in "main" + * Configure GitLab repo for "push" in "main" * Configure PipelineRun - * Validate PipelineRun for "success" + * Validate "pull_request" PipelineRun for "success" + * Trigger push event on main branch + * Validate "push" PipelineRun for "success" * Cleanup PAC ## Configure PAC in GitLab Project: PIPELINES-30-TC02 @@ -36,7 +39,7 @@ Steps: * Configure PipelineRun * "0" pipelinerun(s) should be present within "10" seconds * Add Label Name "bug" with "red" color with description "Identify a Issue" - * Validate PipelineRun for "success" + * Validate "pull_request" PipelineRun for "success" * Cleanup PAC ## Configure PAC in GitLab Project: PIPELINES-30-TC03 @@ -54,8 +57,8 @@ Steps: * Configure GitLab repo for "pull_request" in "main" * Update Annotation "pipelinesascode.tekton.dev/on-comment" with "^/hello-world" * Configure PipelineRun - * Validate PipelineRun for "success" + * Validate "pull_request" PipelineRun for "success" * Add Comment "/hello-world" in MR * "2" pipelinerun(s) should be present within "10" seconds - * Validate PipelineRun for "success" + * Validate "pull_request" PipelineRun for "success" * Cleanup PAC diff --git a/specs/pipelines/git-resolvers.spec b/specs/pipelines/git-resolvers.spec index cdab1cb1..b4803290 100644 --- a/specs/pipelines/git-resolvers.spec +++ b/specs/pipelines/git-resolvers.spec @@ -20,7 +20,7 @@ Steps: |----|-----------------------------------|------------| |1 |git-resolver-pipelinerun |successful | -## Test the functionality of git resolvers with authentication: PIPELINES-24-TC01 +## Test the functionality of git resolvers with authentication and token: PIPELINES-24-TC02 Tags: e2e Component: Resolvers Level: Integration @@ -28,11 +28,16 @@ Type: Functional Importance: High Steps: + * Create secret "private-repo-auth-secret" in autogenerated namespace with GitHub token * Create - |S.NO|resource_dir | - |----|-----------------------------------------------------------------| - |1 |testdata/resolvers/pipelineruns/git-resolver-pipelinerun-private.yaml | + |S.NO|resource_dir | + |----|---------------------------------------------------------------------------------| + |1 |testdata/resolvers/pipelineruns/git-resolver-pipelinerun-private.yaml | + |2 |testdata/resolvers/pipelineruns/git-resolver-pipelinerun-private-token-auth.yaml | + |3 |testdata/resolvers/pipelineruns/git-resolver-pipelinerun-private-url.yaml | * Verify pipelinerun |S.NO|pipeline_run_name |status | |----|-----------------------------------|------------| - |1 |git-resolver-pipelinerun-private |successful | \ No newline at end of file + |1 |git-resolver-pipelinerun-private |successful | + |2 |git-resolver-pipelinerun-private-token-auth |successful | + |3 |git-resolver-pipelinerun-private-url |successful | diff --git a/steps/cli/oc.go b/steps/cli/oc.go index 57c6c720..95489859 100644 --- a/steps/cli/oc.go +++ b/steps/cli/oc.go @@ -230,6 +230,15 @@ var _ = gauge.Step("Configure GitHub token for git resolver in TektonConfig", fu } }) +var _ = gauge.Step("Create secret in autogenerated namespace with GitHub token", func(secretName string) { + if os.Getenv("GITHUB_TOKEN") == "" { + log.Printf("Token for authorization to the GitHub repository was not exported as a system variable") + } else { + secretData := os.Getenv("GITHUB_TOKEN") + oc.CreateSecretInNamespace(secretData, secretName, store.Namespace()) + } +}) + var _ = gauge.Step("Configure the bundles resolver", func() { patch_data := "{\"spec\":{\"pipeline\":{\"bundles-resolver-config\":{\"default-kind\":\"task\", \"defaut-service-account\":\"pipelines\"}}}}" oc.UpdateTektonConfig(patch_data) diff --git a/steps/operator/operator.go b/steps/operator/operator.go index 7c924d53..34745f16 100644 --- a/steps/operator/operator.go +++ b/steps/operator/operator.go @@ -10,9 +10,9 @@ import ( "github.com/openshift-pipelines/release-tests/pkg/store" ) -var _ = gauge.Step("Update TektonConfig CR to use param with name createRbacResource and value to auto creation of RBAC resources", func(value, action string) { - patchData := fmt.Sprintf("{\"spec\":{\"params\":[{\"name\":\"createRbacResource\",\"value\":\"%s\"}]}}", value) - log.Println(action, "auto creation of RBAC resources") +var _ = gauge.Step("Update TektonConfig CR to use param with name and value to auto creation of ", func(paramName, value, action, resourceType string) { + patchData := fmt.Sprintf("{\"spec\":{\"params\":[{\"name\":\"%s\",\"value\":\"%s\"}]}}", paramName, value) + log.Println(action, "auto creation of", resourceType) log.Printf("output: %s\n", cmd.MustSucceed("oc", "patch", "TektonConfig", "config", "--type=merge", "-p", patchData).Stdout()) }) @@ -23,3 +23,11 @@ var _ = gauge.Step("Verify RBAC resources disabled successfully", func() { var _ = gauge.Step("Verify RBAC resources are auto created successfully", func() { operator.ValidateRBAC(store.Clients(), store.GetCRNames()) }) + +var _ = gauge.Step("Verify CA Bundle ConfigMaps are auto created successfully", func() { + operator.ValidateCABundleConfigMaps(store.Clients(), store.GetCRNames()) +}) + +var _ = gauge.Step("Verify CA Bundle ConfigMaps still exist", func() { + operator.ValidateCABundleConfigMaps(store.Clients(), store.GetCRNames()) +}) diff --git a/steps/pac/pac.go b/steps/pac/pac.go index 64b333e1..eeb99ccc 100644 --- a/steps/pac/pac.go +++ b/steps/pac/pac.go @@ -1,7 +1,10 @@ package pac import ( + "fmt" + "github.com/getgauge-contrib/gauge-go/gauge" + "github.com/getgauge-contrib/gauge-go/testsuit" "github.com/openshift-pipelines/release-tests/pkg/k8s" "github.com/openshift-pipelines/release-tests/pkg/pac" "github.com/openshift-pipelines/release-tests/pkg/pipelines" @@ -16,10 +19,10 @@ var _ = gauge.Step("Setup Gitlab Client", func() { var _ = gauge.Step("Create Smee deployment", func() { pac.SetupSmeeDeployment() k8s.ValidateDeployments(store.Clients(), store.Namespace(), store.GetScenarioData("smeeDeploymentName")) + pac.SetupGitLabProject() }) var _ = gauge.Step("Configure GitLab repo for in ", func(eventType, branch string) { - pac.SetupGitLabProject() pac.GeneratePipelineRunYaml(eventType, branch) }) @@ -27,11 +30,28 @@ var _ = gauge.Step("Configure PipelineRun", func() { pac.ConfigurePreviewChanges() }) +var _ = gauge.Step("Trigger push event on main branch", func() { + pac.TriggerPushOnForkMain() +}) + var _ = gauge.Step("Validate PipelineRun for ", func(state string) { pipelineName := pac.GetPipelineNameFromMR() pipelines.ValidatePipelineRun(store.Clients(), pipelineName, state, store.Namespace()) }) +var _ = gauge.Step("Validate PipelineRun for ", func(event_type, state string) { + switch event_type { + case "pull_request": + pipelineName := pac.GetPipelineNameFromMR() + pipelines.ValidatePipelineRun(store.Clients(), pipelineName, state, store.Namespace()) + case "push": + pipelineName := pac.GetPushPipelineNameFromMain() + pipelines.ValidatePipelineRun(store.Clients(), pipelineName, state, store.Namespace()) + default: + testsuit.T.Fail(fmt.Errorf("invalid event type: %s", event_type)) + } +}) + var _ = gauge.Step("Validate PAC Info Install", func() { pac.AssertPACInfoInstall() }) diff --git a/testdata/ecosystem/pipelineruns/buildah-ns.yaml b/testdata/ecosystem/pipelineruns/buildah-ns.yaml new file mode 100644 index 00000000..151cebf7 --- /dev/null +++ b/testdata/ecosystem/pipelineruns/buildah-ns.yaml @@ -0,0 +1,13 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + name: buildah-ns-run +spec: + pipelineRef: + name: buildah-ns-pipeline + timeouts: + pipeline: 10m + workspaces: + - name: source + persistentVolumeClaim: + claimName: shared-pvc \ No newline at end of file diff --git a/testdata/ecosystem/pipelineruns/helm-upgrade-from-repo.yaml b/testdata/ecosystem/pipelineruns/helm-upgrade-from-repo.yaml index da36b77c..00778761 100644 --- a/testdata/ecosystem/pipelineruns/helm-upgrade-from-repo.yaml +++ b/testdata/ecosystem/pipelineruns/helm-upgrade-from-repo.yaml @@ -2,15 +2,19 @@ apiVersion: tekton.dev/v1 kind: PipelineRun metadata: name: helm-upgrade-from-repo-run -spec: +spec: pipelineRef: name: helm-upgrade-from-repo params: - - name: helm_repo - value: https://helm.github.io/examples - - name: overwrite_values - value: image.repository=quay.io/lib/nginx,image.tag=stable,serviceAccount.create=false,serviceAccount.name=pipeline - timeouts: + - name: helm_repo + value: https://helm.github.io/examples + - name: chart_name + value: examples/hello-world + - name: release_name + value: test + - name: overwrite_values + value: image.repository=nginx,image.tag=latest,serviceAccount.create=false,serviceAccount.name=pipeline + timeouts: pipeline: 10m workspaces: - name: source diff --git a/testdata/ecosystem/pipelineruns/helm-upgrade-from-source.yaml b/testdata/ecosystem/pipelineruns/helm-upgrade-from-source.yaml index ec9c3543..85d84560 100644 --- a/testdata/ecosystem/pipelineruns/helm-upgrade-from-source.yaml +++ b/testdata/ecosystem/pipelineruns/helm-upgrade-from-source.yaml @@ -2,15 +2,19 @@ apiVersion: tekton.dev/v1 kind: PipelineRun metadata: name: helm-upgrade-from-source-run -spec: +spec: pipelineRef: name: helm-upgrade-from-source params: - - name: git_repo - value: https://github.com/helm/examples - - name: overwrite_values - value: image.repository=quay.io/lib/nginx,image.tag=stable,serviceAccount.create=false,serviceAccount.name=pipeline - timeouts: + - name: git_repo + value: https://github.com/helm/examples + - name: charts_dir + value: charts/hello-world + - name: release_name + value: test + - name: overwrite_values + value: image.repository=nginx,image.tag=latest,serviceAccount.create=false,serviceAccount.name=pipeline + timeouts: pipeline: 10m workspaces: - name: source diff --git a/testdata/ecosystem/pipelines/buildah-ns.yaml b/testdata/ecosystem/pipelines/buildah-ns.yaml new file mode 100644 index 00000000..5d985f90 --- /dev/null +++ b/testdata/ecosystem/pipelines/buildah-ns.yaml @@ -0,0 +1,60 @@ +apiVersion: tekton.dev/v1 +kind: Pipeline +metadata: + name: buildah-ns-pipeline +spec: + params: + - name: REVISION + default: fedora-38 + - name: SUBDIR + description: where to clone the git repo + default: buildah + workspaces: + - name: source + tasks: + - name: clone-git-repo + taskRef: + resolver: cluster + params: + - name: kind + value: task + - name: name + value: git-clone + - name: namespace + value: openshift-pipelines + workspaces: + - name: output + workspace: source + params: + - name: URL + value: https://github.com/ppitonak/nocode + - name: SUBDIRECTORY + value: $(params.SUBDIR) + - name: DELETE_EXISTING + value: "true" + - name: REVISION + value: $(params.REVISION) + - name: run-buildah + taskRef: + resolver: cluster + params: + - name: kind + value: task + - name: name + value: buildah-ns + - name: namespace + value: openshift-pipelines + runAfter: + - clone-git-repo + workspaces: + - name: source + workspace: source + params: + - name: IMAGE + value: image-registry.openshift-image-registry.svc:5000/$(context.pipelineRun.namespace)/$(params.SUBDIR) + - name: CONTEXT + value: $(params.SUBDIR) + - name: DOCKERFILE + value: $(params.SUBDIR)/Dockerfile + - name: TLSVERIFY + value: "true" \ No newline at end of file diff --git a/testdata/ecosystem/pipelines/helm-upgrade-from-repo.yaml b/testdata/ecosystem/pipelines/helm-upgrade-from-repo.yaml index f59236fd..32756f2a 100644 --- a/testdata/ecosystem/pipelines/helm-upgrade-from-repo.yaml +++ b/testdata/ecosystem/pipelines/helm-upgrade-from-repo.yaml @@ -4,36 +4,39 @@ metadata: name: helm-upgrade-from-repo spec: params: - - name: helm_repo - default: https://helm.github.io/examples - - name: chart_name - default: charts/hello-world - - name: release_version - default: 0.1.0 - - name: release_name - default: test - - name: overwrite_values - workspaces: - - name: source - tasks: - - name: helm-upgrade-from-repo - taskRef: - resolver: cluster - params: - - name: kind - value: task - - name: name - value: helm-upgrade-from-repo - - name: namespace - value: openshift-pipelines - params: - name: helm_repo - value: $(params.helm_repo) + type: string + default: https://helm.github.io/examples - name: chart_name - value: $(params.chart_name) - - name: release_version - value: $(params.release_version) + type: string + default: examples/hello-world - name: release_name - value: $(params.release_name) + type: string + default: test - name: overwrite_values - value: $(params.overwrite_values) \ No newline at end of file + type: string + default: "" + workspaces: + - name: source + tasks: + - name: helm-upgrade-from-repo + taskRef: + resolver: cluster + params: + - name: kind + value: task + - name: name + value: helm-upgrade-from-repo + - name: namespace + value: openshift-pipelines + params: + - name: helm_repo + value: $(params.helm_repo) + - name: chart_name + value: $(params.chart_name) + - name: release_name + value: $(params.release_name) + - name: release_namespace + value: $(context.pipelineRun.namespace) + - name: overwrite_values + value: $(params.overwrite_values) diff --git a/testdata/ecosystem/pipelines/helm-upgrade-from-source.yaml b/testdata/ecosystem/pipelines/helm-upgrade-from-source.yaml index 9ea781c4..45f8dfdd 100644 --- a/testdata/ecosystem/pipelines/helm-upgrade-from-source.yaml +++ b/testdata/ecosystem/pipelines/helm-upgrade-from-source.yaml @@ -4,59 +4,67 @@ metadata: name: helm-upgrade-from-source spec: params: - - name: git_repo - default: https://github.com/helm/examples - - name: charts_dir - default: charts/hello-world - - name: release_version - default: 0.1.0 - - name: release_name - default: test - - name: overwrite_values - workspaces: - - name: source - tasks: - - name: clone-git-repo - taskRef: - resolver: cluster - params: - - name: kind - value: task - - name: name - value: git-clone - - name: namespace - value: openshift-pipelines - workspaces: - - name: output - workspace: source - params: - - name: URL - value: $(params.git_repo) - - name: SUBDIRECTORY - value: "" - - name: DELETE_EXISTING - value: "true" - - name: helm-upgrade-from-source - taskRef: - resolver: cluster - params: - - name: kind - value: task - - name: name - value: helm-upgrade-from-source - - name: namespace - value: openshift-pipelines - workspaces: - - name: source - workspace: source - params: + - name: git_repo + type: string + default: https://github.com/helm/examples - name: charts_dir - value: $(params.charts_dir) + type: string + default: charts/hello-world - name: release_version - value: $(params.release_version) + type: string + default: "0.1.0" - name: release_name - value: $(params.release_name) + type: string + default: test - name: overwrite_values - value: $(params.overwrite_values) - runAfter: - - clone-git-repo + type: string + default: "" + workspaces: + - name: source + tasks: + - name: clone-git-repo + taskRef: + resolver: cluster + params: + - name: kind + value: task + - name: name + value: git-clone + - name: namespace + value: openshift-pipelines + workspaces: + - name: output + workspace: source + params: + - name: URL + value: $(params.git_repo) + - name: SUBDIRECTORY + value: "" + - name: DELETE_EXISTING + value: "true" + - name: helm-upgrade-from-source + taskRef: + resolver: cluster + params: + - name: kind + value: task + - name: name + value: helm-upgrade-from-source + - name: namespace + value: openshift-pipelines + workspaces: + - name: source + workspace: source + params: + - name: charts_dir + value: $(params.charts_dir) + - name: release_version + value: $(params.release_version) + - name: release_name + value: $(params.release_name) + - name: release_namespace + value: $(context.pipelineRun.namespace) + - name: overwrite_values + value: $(params.overwrite_values) + runAfter: + - clone-git-repo diff --git a/testdata/resolvers/pipelineruns/git-resolver-pipelinerun-private-token-auth.yaml b/testdata/resolvers/pipelineruns/git-resolver-pipelinerun-private-token-auth.yaml new file mode 100644 index 00000000..ce3a44bf --- /dev/null +++ b/testdata/resolvers/pipelineruns/git-resolver-pipelinerun-private-token-auth.yaml @@ -0,0 +1,22 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + name: git-resolver-pipelinerun-private-token-auth +spec: + pipelineRef: + resolver: git + params: + - name: name + value: resolver-pipeline + - name: repo + value: test-private + - name: org + value: openshift-pipelines + - name: revision + value: main + - name: pathInRepo + value: resolver-pipeline.yaml + - name: gitToken + value: "private-repo-auth-secret" + - name: gitTokenKey + value: "private-repo-token" \ No newline at end of file diff --git a/testdata/resolvers/pipelineruns/git-resolver-pipelinerun-private-url.yaml b/testdata/resolvers/pipelineruns/git-resolver-pipelinerun-private-url.yaml new file mode 100644 index 00000000..8956e2d6 --- /dev/null +++ b/testdata/resolvers/pipelineruns/git-resolver-pipelinerun-private-url.yaml @@ -0,0 +1,20 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + name: git-resolver-pipelinerun-private-url +spec: + pipelineRef: + resolver: git + params: + - name: name + value: resolver-pipeline + - name: url + value: https://github.com/openshift-pipelines/test-private + - name: revision + value: main + - name: pathInRepo + value: resolver-pipeline.yaml + - name: gitToken + value: "private-repo-auth-secret" + - name: gitTokenKey + value: "private-repo-token" \ No newline at end of file