Skip to content

Commit 4c9d59f

Browse files
committed
Add Config for all index images (OSP 4.12 to 4.18)
1 parent 435f469 commit 4c9d59f

22 files changed

+175
-51
lines changed

.github/workflows/generate-konflux.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ jobs:
3131
go run ./cmd/konflux/ config/konflux/openshift-pipelines-core.yaml
3232
go run ./cmd/konflux/ config/konflux/openshift-pipelines-cli.yaml
3333
go run ./cmd/konflux/ config/konflux/openshift-pipelines-operator.yaml
34-
go run ./cmd/konflux/ config/konflux/openshift-pipelines-index.yaml
34+
go run ./cmd/konflux/ config/konflux/openshift-pipelines-index-4.12.yaml
35+
go run ./cmd/konflux/ config/konflux/openshift-pipelines-index-4.13.yaml
36+
go run ./cmd/konflux/ config/konflux/openshift-pipelines-index-4.14.yaml
37+
go run ./cmd/konflux/ config/konflux/openshift-pipelines-index-4.15.yaml
38+
go run ./cmd/konflux/ config/konflux/openshift-pipelines-index-4.16.yaml
39+
go run ./cmd/konflux/ config/konflux/openshift-pipelines-index-4.17.yaml
40+
go run ./cmd/konflux/ config/konflux/openshift-pipelines-index-4.18.yaml
3541
env:
3642
GH_TOKEN: ${{ secrets.OPENSHIFT_PIPELINES_ROBOT }}
3743
GITHUB_TOKEN: ${{ secrets.OPENSHIFT_PIPELINES_ROBOT }}

cmd/konflux/git.go

+15-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
k "github.com/openshift-pipelines/hack/internal/konflux"
78
"io/fs"
89
"log"
910
"os"
1011
"path/filepath"
1112
"strings"
1213
)
1314

14-
func cloneAndCheckout(ctx context.Context, repo, branch, dir string) error {
15+
const baseBranchPrefix = "actions/update/konflux-configuration-"
16+
17+
func cloneAndCheckout(ctx context.Context, repo, branch, dir string, config k.Config) error {
18+
branchPrefix := baseBranchPrefix + config.Name
1519
exists, err := exists(filepath.Join(dir, ".git"))
20+
1621
if err != nil {
1722
return err
1823
}
@@ -27,6 +32,7 @@ func cloneAndCheckout(ctx context.Context, repo, branch, dir string) error {
2732
return fmt.Errorf("failed to clone repository: %s, %s", err, out)
2833
}
2934
}
35+
3036
if out, err := run(ctx, dir, "git", "reset", "--hard", "HEAD", "--"); err != nil {
3137
return fmt.Errorf("failed to reset %s branch: %s, %s", branch, err, out)
3238
}
@@ -47,13 +53,15 @@ func cloneAndCheckout(ctx context.Context, repo, branch, dir string) error {
4753
if out, err := run(ctx, dir, "git", "checkout", "origin/"+branch, "-B", branch); err != nil {
4854
return fmt.Errorf("failed to checkout %s branch: %s, %s", branch, err, out)
4955
}
50-
if out, err := run(ctx, dir, "git", "checkout", "-B", "actions/update/konflux-configuration-"+branch); err != nil {
56+
if out, err := run(ctx, dir, "git", "checkout", "-B", branchPrefix+branch); err != nil {
5157
return fmt.Errorf("failed to checkout branch for PR: %s, %s", err, out)
5258
}
5359
return nil
5460
}
5561

56-
func commitAndPullRequest(ctx context.Context, dir, branch string) error {
62+
func commitAndPullRequest(ctx context.Context, dir, branch string, config k.Config) error {
63+
branchPrefix := baseBranchPrefix + config.Name
64+
5765
if out, err := run(ctx, dir, "git", "status", "--porcelain"); err != nil {
5866
return fmt.Errorf("failed to check git status: %s, %s", err, out)
5967
} else if string(out) == "" {
@@ -69,17 +77,17 @@ func commitAndPullRequest(ctx context.Context, dir, branch string) error {
6977
if out, err := run(ctx, dir, "git", "commit", "-m", fmt.Sprintf("[bot:%s] update konflux configuration", branch)); err != nil {
7078
return fmt.Errorf("failed to commit: %s, %s", err, out)
7179
}
72-
if out, err := run(ctx, dir, "git", "push", "-f", "origin", "actions/update/konflux-configuration-"+branch); err != nil {
80+
if out, err := run(ctx, dir, "git", "push", "-f", "origin", branchPrefix+branch); err != nil {
7381
return fmt.Errorf("failed to push: %s, %s", err, out)
7482
}
75-
if out, err := run(ctx, dir, "bash", "-c", "gh pr list --base "+branch+" --head actions/update/konflux-configuration-"+branch+" --json url --jq 'length'"); err != nil {
83+
if out, err := run(ctx, dir, "bash", "-c", "gh pr list --base "+branch+" --head "+branchPrefix+branch+" --json url --jq 'length'"); err != nil {
7684
return fmt.Errorf("failed to check if a pr exists: %s, %s", err, out)
7785
} else if strings.TrimSpace(string(out)) == "0" {
7886
if out, err := run(ctx, dir, "gh", "pr", "create",
7987
"--base", branch,
80-
"--head", "actions/update/konflux-configuration-"+branch,
88+
"--head", branchPrefix+branch,
8189
"--label=hack", "--label=automated",
82-
"--title", fmt.Sprintf("[bot:%s] update konflux configuration", branch),
90+
"--title", fmt.Sprintf("[bot:%s:%s] update konflux configuration", config.Name, branch),
8391
"--body", "This PR was automatically generated by the konflux command from openshift-pipelines/hack repository"); err != nil {
8492
return fmt.Errorf("failed to create the pr: %s, %s", err, out)
8593
}

cmd/konflux/main.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func generateConfig(ctx context.Context, config k.Config, dir string, dryRun boo
116116
if err := os.MkdirAll(checkoutDirMain, os.ModePerm); err != nil {
117117
return err
118118
}
119-
if err := cloneAndCheckout(ctx, repository, "main", checkoutDirMain); err != nil {
119+
if err := cloneAndCheckout(ctx, repository, "main", checkoutDirMain, config); err != nil {
120120
return err
121121
}
122122
for _, branch := range repo.Branches {
@@ -146,7 +146,7 @@ func generateConfig(ctx context.Context, config k.Config, dir string, dryRun boo
146146
return err
147147
}
148148

149-
if err := cloneAndCheckout(ctx, repository, branch.Name, checkoutDir); err != nil {
149+
if err := cloneAndCheckout(ctx, repository, branch.Name, checkoutDir, config); err != nil {
150150
return err
151151
}
152152
if err := cleanupAutogenerated(ctx, v, filepath.Join(checkoutDir, tektonDir)); err != nil {
@@ -167,14 +167,14 @@ func generateConfig(ctx context.Context, config k.Config, dir string, dryRun boo
167167

168168
}
169169
if !dryRun && branch.Name != "main" {
170-
if err := commitAndPullRequest(ctx, checkoutDir, branch.Name); err != nil {
170+
if err := commitAndPullRequest(ctx, checkoutDir, branch.Name, config); err != nil {
171171
return err
172172
}
173173
}
174174

175175
}
176176
if !dryRun {
177-
if err := commitAndPullRequest(ctx, checkoutDirMain, "main"); err != nil {
177+
if err := commitAndPullRequest(ctx, checkoutDirMain, "main", config); err != nil {
178178
return err
179179
}
180180
}
@@ -240,9 +240,11 @@ func updateComponent(c *k.Component, version k.Version) error {
240240
if c.PrefetchInput == "" {
241241
c.PrefetchInput = "{\"type\": \"rpm\", \"path\": \".konflux/rpms\"}"
242242
}
243-
c.ImageSuffix = version.ImageSuffix
244-
if c.ImageSuffix == "" {
245-
c.ImageSuffix = DefaultImageSuffix
243+
if version.ImageSuffix != "None" {
244+
c.ImageSuffix = version.ImageSuffix
245+
if c.ImageSuffix == "" {
246+
c.ImageSuffix = DefaultImageSuffix
247+
}
246248
}
247249
// This is the case for git-init where we don't require upstream name because comet created is pipelines-git-init-rhel8
248250
if !c.NoImagePrefix && repo.Upstream != "" {

cmd/konflux/templates/tekton/component-pull-request.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by openshift-pipelines/hack. DO NOT EDIT.
1+
# Generated for Release {{.Repository.Application.Version.Version}} by openshift-pipelines/hack. DO NOT EDIT.
22
apiVersion: tekton.dev/v1
33
kind: PipelineRun
44
metadata:

cmd/konflux/templates/tekton/component-push.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by openshift-pipelines/hack. DO NOT EDIT.
1+
# Generated for Release {{.Repository.Application.Version.Version}} by openshift-pipelines/hack. DO NOT EDIT.
22
apiVersion: tekton.dev/v1
33
kind: PipelineRun
44
metadata:

config/konflux/openshift-pipelines-core.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ resources:
1515
- tektoncd-hub
1616
- tektoncd-pipeline
1717
- tektoncd-pruner
18-
- tektoncd-results
19-
- tektoncd-triggers
18+
# - tektoncd-results
19+
# - tektoncd-triggers
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: openshift-pipelines-index-4.12
2+
versions:
3+
next:
4+
image-suffix: "None"
5+
version: next
6+
auto-release: true
7+
resources:
8+
- operator-index-4.12
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: openshift-pipelines-index-4.13
2+
versions:
3+
next:
4+
image-suffix: "None"
5+
version: next
6+
auto-release: true
7+
resources:
8+
- operator-index-4.13
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: openshift-pipelines-index-4.14
2+
versions:
3+
next:
4+
image-suffix: "None"
5+
version: next
6+
auto-release: true
7+
resources:
8+
- operator-index-4.14
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: openshift-pipelines-index-4.15
2+
versions:
3+
next:
4+
image-suffix: "None"
5+
version: next
6+
auto-release: true
7+
resources:
8+
- operator-index-4.15
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: openshift-pipelines-index-4.16
2+
versions:
3+
next:
4+
image-suffix: "None"
5+
version: next
6+
auto-release: true
7+
resources:
8+
- operator-index-4.16
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: openshift-pipelines-index-4.17
2+
versions:
3+
next:
4+
image-suffix: "None"
5+
version: next
6+
auto-release: true
7+
resources:
8+
- operator-index-4.17
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: openshift-pipelines-index-4.18
2+
versions:
3+
next:
4+
image-suffix: "None"
5+
version: next
6+
auto-release: true
7+
resources:
8+
- operator-index-4.18
9+

config/konflux/openshift-pipelines-index.yaml

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: operator
2+
components:
3+
- name: index-4.12
4+
dockerfile: .konflux/olm-catalog/index/v4.12/Dockerfile.catalog
5+
nudges: [ "" ]
6+
tekton:
7+
watched-sources: (".konflux/patches/***".pathChanged() || ".konflux/olm-catalog/index/***".pathChanged())
8+
branches:
9+
- name: next
10+
versions:
11+
- next
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: operator
2+
components:
3+
- name: index-4.13
4+
dockerfile: .konflux/olm-catalog/index/v4.13/Dockerfile.catalog
5+
nudges: [ "" ]
6+
tekton:
7+
watched-sources: (".konflux/patches/***".pathChanged() || ".konflux/olm-catalog/index/***".pathChanged())
8+
branches:
9+
- name: next
10+
versions:
11+
- next
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: operator
2+
components:
3+
- name: index-4.14
4+
dockerfile: .konflux/olm-catalog/index/v4.14/Dockerfile.catalog
5+
nudges: [ "" ]
6+
tekton:
7+
watched-sources: (".konflux/patches/***".pathChanged() || ".konflux/olm-catalog/index/***".pathChanged())
8+
branches:
9+
- name: next
10+
versions:
11+
- next
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: operator
2+
components:
3+
- name: index-4.15
4+
dockerfile: .konflux/olm-catalog/index/v4.15/Dockerfile.catalog
5+
nudges: [ "" ]
6+
tekton:
7+
watched-sources: (".konflux/patches/***".pathChanged() || ".konflux/olm-catalog/index/***".pathChanged())
8+
branches:
9+
- name: next
10+
versions:
11+
- next
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: operator
2+
components:
3+
- name: index-4.16
4+
dockerfile: .konflux/olm-catalog/index/v4.16/Dockerfile.catalog
5+
nudges: [ "" ]
6+
tekton:
7+
watched-sources: (".konflux/patches/***".pathChanged() || ".konflux/olm-catalog/index/***".pathChanged())
8+
branches:
9+
- name: next
10+
versions:
11+
- next
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: operator
2+
components:
3+
- name: index-4.17
4+
dockerfile: .konflux/olm-catalog/index/v4.17/Dockerfile.catalog
5+
nudges: [ "" ]
6+
tekton:
7+
watched-sources: (".konflux/patches/***".pathChanged() || ".konflux/olm-catalog/index/***".pathChanged())
8+
branches:
9+
- name: next
10+
versions:
11+
- next
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: operator
2+
components:
3+
- name: index-4.18
4+
dockerfile: .konflux/olm-catalog/index/v4.18/Dockerfile.catalog
5+
nudges: [ "" ]
6+
tekton:
7+
watched-sources: (".konflux/patches/***".pathChanged() || ".konflux/olm-catalog/index/***".pathChanged())
8+
branches:
9+
- name: next
10+
versions:
11+
- next

config/konflux/repos/operator-index.yaml

-24
This file was deleted.

0 commit comments

Comments
 (0)