diff --git a/pkg/konfluxgen/konfluxgen.go b/pkg/konfluxgen/konfluxgen.go index 6b63fc63..71dcbe3f 100644 --- a/pkg/konfluxgen/konfluxgen.go +++ b/pkg/konfluxgen/konfluxgen.go @@ -15,8 +15,6 @@ import ( "strings" "text/template" - "github.com/operator-framework/api/pkg/lib/version" - "github.com/openshift-knative/hack/pkg/soversion" "github.com/openshift-knative/hack/pkg/util" @@ -760,6 +758,17 @@ func GenerateFBCReleasePlanAdmission(applications []string, resourceOutputPath s return nil } +type rpaComponentData struct { + Name string + ApplicationName string + Components []ComponentImageRepoRef + + SOVersion string + PyxisSecret string + PyxisServer string + PipelineSA string +} + func GenerateComponentReleasePlanAdmission(csvPath string, resourceOutputPath string, appName string) error { csv, err := loadClusterServiceVerion(csvPath) if err != nil { @@ -778,8 +787,17 @@ func GenerateComponentReleasePlanAdmission(csvPath string, resourceOutputPath st } rpaName := Truncate(Sanitize(fmt.Sprintf("%s-%s-prod", appName, soVersion))) + rpaData := rpaComponentData{ + Name: rpaName, + ApplicationName: appName, + Components: components, + SOVersion: soVersion.String(), + PyxisSecret: "pyxis-prod-secret", + PyxisServer: "production", + PipelineSA: "release-registry-prod", + } outputFilePath := filepath.Join(outputDir, fmt.Sprintf("%s.yaml", rpaName)) - if err := executeComponentReleasePlanAdmissionTemplate(components, outputFilePath, rpaName, appName, soVersion); err != nil { + if err := executeComponentReleasePlanAdmissionTemplate(rpaData, outputFilePath); err != nil { return fmt.Errorf("failed to execute release plan admission template: %w", err) } @@ -793,8 +811,17 @@ func GenerateComponentReleasePlanAdmission(csvPath string, resourceOutputPath st } rpaName = Truncate(Sanitize(fmt.Sprintf("%s-%s-stage", appName, soVersion))) + rpaData = rpaComponentData{ + Name: rpaName, + ApplicationName: appName, + Components: componentWithStageRepoRef, + SOVersion: soVersion.String(), + PyxisSecret: "pyxis-staging-secret", + PyxisServer: "stage", + PipelineSA: "release-registry-staging", + } outputFilePath = filepath.Join(outputDir, fmt.Sprintf("%s.yaml", rpaName)) - if err := executeComponentReleasePlanAdmissionTemplate(componentWithStageRepoRef, outputFilePath, rpaName, appName, soVersion); err != nil { + if err := executeComponentReleasePlanAdmissionTemplate(rpaData, outputFilePath); err != nil { return fmt.Errorf("failed to execute release plan admission template: %w", err) } @@ -824,7 +851,7 @@ func executeFBCReleasePlanAdmissionTemplate(data rpaFBCData, outputFilePath stri return nil } -func executeComponentReleasePlanAdmissionTemplate(components []ComponentImageRepoRef, outputFilePath string, rpaName string, appName string, soVersion version.OperatorVersion) error { +func executeComponentReleasePlanAdmissionTemplate(data rpaComponentData, outputFilePath string) error { funcs := template.FuncMap{ "sanitize": Sanitize, "truncate": Truncate, @@ -836,13 +863,6 @@ func executeComponentReleasePlanAdmissionTemplate(components []ComponentImageRep return fmt.Errorf("failed to parse component RPA template: %w", err) } - data := map[string]interface{}{ - "Name": rpaName, - "ApplicationName": appName, - "Components": components, - "Version": soVersion.String(), - } - buf := &bytes.Buffer{} if err := rpaTemplate.Execute(buf, data); err != nil { return fmt.Errorf("failed to execute template for ReleasePlanAdmission: %w", err) diff --git a/pkg/konfluxgen/releaseplanadmission-component.template.yaml b/pkg/konfluxgen/releaseplanadmission-component.template.yaml index bdfcf49c..ac65253e 100644 --- a/pkg/konfluxgen/releaseplanadmission-component.template.yaml +++ b/pkg/konfluxgen/releaseplanadmission-component.template.yaml @@ -15,8 +15,26 @@ spec: repository: {{{ $component.ImageRepository }}} pushSourceContainer: true {{{- end }}} + pyxis: + secret: {{{ .PyxisSecret }}} + server: {{{ .PyxisServer }}} + sign: + configMapName: "hacbs-signing-pipeline-config-redhatrelease2" defaults: tags: - "{{ git_sha }}" - "{{ git_short_sha }}" - - "{{{ .Version }}}" + - "{{{ .SOVersion }}}" + pipeline: + pipelineRef: + resolver: git + params: + - name: url + value: "https://github.com/konflux-ci/release-service-catalog.git" + - name: revision + value: production + - name: pathInRepo + value: "pipelines/rh-advisories/rh-advisories.yaml" + serviceAccountName: {{{ .PipelineSA }}} + timeouts: + pipeline: "4h0m0s"