Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 34 additions & 25 deletions pkg/konfluxgen/fbc-builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ spec:
description: Additional image tags
name: additional-tags
type: array
- default: []
description: Array of opm command arguments
name: opm-args
type: array
- default: ""
description: OPM output path
name: opm-output-path
type: string
- description: Source Repository URL
name: git-url
type: string
Expand Down Expand Up @@ -115,6 +123,32 @@ spec:
- name: kind
value: task
resolver: bundles
- name: run-opm-command
params:
- name: OPM_ARGS
value:
- $(params.opm-args[*])
- name: OPM_OUTPUT_PATH
value: $(params.opm-output-path)
- name: SOURCE_ARTIFACT
value: $(tasks.clone-repository.results.SOURCE_ARTIFACT)
- name: ociStorage
value: $(params.output-image).opm
- name: ociArtifactExpiresAfter
value: $(params.image-expires-after)
- name: IDMS_PATH
value: ""
runAfter:
- clone-repository
taskRef:
params:
- name: name
value: run-opm-command-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-run-opm-command-oci-ta:0.1@sha256:c79858b867713e44927438f6193c49004bf40bfd9248682f20c5a83ea2a9d2f1
- name: kind
value: task
resolver: bundles
- name: init
params:
- name: enable-cache-proxy
Expand Down Expand Up @@ -152,31 +186,6 @@ spec:
workspaces:
- name: basic-auth
workspace: git-auth
- name: run-opm-command
params:
- name: SOURCE_ARTIFACT
value: $(tasks.clone-repository.results.SOURCE_ARTIFACT)
- name: ociStorage
value: $(params.output-image).opm
- name: ociArtifactExpiresAfter
value: $(params.image-expires-after)
- name: OPM_ARGS
value: []
- name: OPM_OUTPUT_PATH
value: ""
- name: IDMS_PATH
value: ""
runAfter:
- clone-repository
taskRef:
params:
- name: name
value: run-opm-command-oci-ta
- name: bundle
value: quay.io/konflux-ci/tekton-catalog/task-run-opm-command-oci-ta:0.1@sha256:c79858b867713e44927438f6193c49004bf40bfd9248682f20c5a83ea2a9d2f1
- name: kind
value: task
resolver: bundles
- name: prefetch-dependencies
params:
- name: input
Expand Down
16 changes: 13 additions & 3 deletions pkg/konfluxgen/konfluxgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ type Config struct {
Excludes []string
ExcludesImages []string

FBCImages []string
JavaImages []string
BundleImage string
FBCImages []string
OpmArgs []string
OpmOutputPath string
JavaImages []string
BundleImage string

ResourcesOutputPathSkipRemove bool
ResourcesOutputPath string
Expand Down Expand Up @@ -383,6 +385,11 @@ func Generate(cfg Config) error {
PipelineRunAnnotations: cfg.PipelineRunAnnotationsFunc(c.ReleaseBuildConfiguration, ib),
}

if pipeline == FBCBuild {
r.OpmArgs = cfg.OpmArgs
r.OpmOutputPath = cfg.OpmOutputPath
}

// TODO REVIEW: Remove special case once all hermetic builds are moved to docker-java-build pipeline With actual hermetic builds
if cfg.IsHermetic(c.ReleaseBuildConfiguration, ib) && pipeline != "docker-java-build" {
r.Hermetic = "true"
Expand Down Expand Up @@ -686,6 +693,9 @@ type DockerfileApplicationConfig struct {

DockerfilePath string

OpmArgs []string
OpmOutputPath string

PipelineRunAnnotations map[string]string
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ patches:
- path: ../patch_additional_tags.patch.yaml
target:
kind: Pipeline
- path: patch_opm_params.patch.yaml
target:
kind: Pipeline
- path: ../patch_source_image.patch.yaml
target:
kind: Pipeline
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: fbc-builder
spec:
params:
- name: opm-args
description: Array of opm command arguments
type: array
default: []
- name: opm-output-path
description: OPM output path
type: string
default: ""
tasks:
- name: run-opm-command
params:
- name: OPM_ARGS
value:
- $(params.opm-args[*])
- name: OPM_OUTPUT_PATH
value: $(params.opm-output-path)
11 changes: 11 additions & 0 deletions pkg/konfluxgen/pipeline-run.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ spec:
- name: prefetch-input-dev-package-managers
value: '{{{ .PrefetchDeps.DevPackageManagers }}}'
{{{- end }}}
{{{- if gt (len .OpmArgs) 0 }}}
- name: opm-args
value:
{{{- range $arg := .OpmArgs }}}
- {{{ $arg }}}
{{{- end }}}
{{{- end }}}
{{{- if .OpmOutputPath }}}
- name: opm-output-path
value: {{{ .OpmOutputPath }}}
{{{- end }}}
{{{- if or (eq .Pipeline "docker-build") (eq .Pipeline "docker-java-build") (eq .Pipeline "bundle-build")}}}
taskRunSpecs:
- pipelineTaskName: sast-shell-check
Expand Down
23 changes: 18 additions & 5 deletions pkg/prowgen/prowgen_konflux.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,20 @@ func generateFBCApplications(soMetadata *project.Metadata, openshiftRelease Repo

for _, ocpVersion := range soMetadata.Requirements.OcpVersion.List {

opmImage, err := getOPMImage(ocpVersion)
ocpMinorVersion, err := extractMinor(ocpVersion)
if err != nil {
return fmt.Errorf("failed to get OCP minor version %q: %w", ocpVersion, err)
}
opmImage, err := getOPMImage(ocpMinorVersion)
if err != nil {
return fmt.Errorf("failed to get OPM image ref for OCP %q: %w", ocpVersion, err)
}
buildArgs := append(buildArgs, fmt.Sprintf("OPM_IMAGE=%s", opmImage))

opmArgs := []string{"alpha", "render-template", "basic",
fmt.Sprintf("\"olm-catalog/serverless-operator-index/v%s/catalog-template.yaml\"", ocpVersion)}
if ocpMinorVersion >= 17 { // OCP 4.17+ OLM fix format flag
opmArgs = append(opmArgs, "--migrate-level=bundle-object-to-csv-metadata")
}
fbcAppName := konfluxgen.FBCAppName(release, ocpVersion)

c := konfluxgen.Config{
Expand All @@ -574,6 +582,8 @@ func generateFBCApplications(soMetadata *project.Metadata, openshiftRelease Repo
" files.all.exists(x, x.matches('^.tekton/'))"+
" )", ocpVersion)
},
OpmArgs: opmArgs,
OpmOutputPath: fmt.Sprintf("olm-catalog/serverless-operator-index/v%s/catalog/serverless-operator/catalog.yaml", ocpVersion),
AdditionalComponentConfigs: []konfluxgen.TemplateConfig{
{
ReleaseBuildConfiguration: cioperatorapi.ReleaseBuildConfiguration{
Expand Down Expand Up @@ -629,17 +639,20 @@ func generateFBCApplications(soMetadata *project.Metadata, openshiftRelease Repo
return nil
}

func getOPMImage(v string) (string, error) {
func extractMinor(v string) (int, error) {
parts := strings.SplitN(v, ".", 2)
if len(parts) != 2 {
return "", fmt.Errorf("invalid OCP version: %s", v)
return 0, fmt.Errorf("invalid OCP version: %s", v)
}

minor, err := strconv.Atoi(parts[1])
if err != nil {
return "", fmt.Errorf("could not convert OCP minor to int (%q): %w", v, err)
return 0, fmt.Errorf("could not convert OCP minor to int (%q): %w", v, err)
}
return minor, nil
}

func getOPMImage(minor int) (string, error) {
if minor <= 14 {
return fmt.Sprintf("registry.redhat.io/openshift4/ose-operator-registry:v4.%d", minor), nil
} else {
Expand Down
Loading