Skip to content

Commit

Permalink
Push global resources only to hack repo (#541)
Browse files Browse the repository at this point in the history
Push applications and tests only to hack for all repos.

Signed-off-by: Pierangelo Di Pilato <[email protected]>
  • Loading branch information
pierDipi authored Jan 30, 2025
1 parent 7eab7df commit 0069428
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
5 changes: 3 additions & 2 deletions pkg/konfluxgen/konfluxgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type Config struct {

ResourcesOutputPathSkipRemove bool
ResourcesOutputPath string
GlobalResourcesOutputPath string

PipelinesOutputPathSkipRemove bool
PipelinesOutputPath string
Expand Down Expand Up @@ -357,7 +358,7 @@ func Generate(cfg Config) error {
for componentKey, config := range components {
buf := &bytes.Buffer{}

appPath := filepath.Join(cfg.ResourcesOutputPath, ApplicationsDirectoryName, appKey, fmt.Sprintf("%s.yaml", appKey))
appPath := filepath.Join(cfg.GlobalResourcesOutputPath, ApplicationsDirectoryName, appKey, fmt.Sprintf("%s.yaml", appKey))
if err := os.MkdirAll(filepath.Dir(appPath), 0777); err != nil {
return fmt.Errorf("failed to create directory for %q: %w", appPath, err)
}
Expand Down Expand Up @@ -465,7 +466,7 @@ func Generate(cfg Config) error {
config.ECPolicyConfiguration = "rhtap-releng-tenant/registry-standard-stage"
}

ecTestDir := filepath.Join(cfg.ResourcesOutputPath, ApplicationsDirectoryName, appKey, "tests")
ecTestDir := filepath.Join(cfg.GlobalResourcesOutputPath, ApplicationsDirectoryName, appKey, "tests")
if err := os.MkdirAll(ecTestDir, 0777); err != nil {
return fmt.Errorf("failed to create directory for %q: %w", appKey, err)
}
Expand Down
41 changes: 22 additions & 19 deletions pkg/prowgen/prowgen_konflux.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,22 @@ const (
NudgeFilesAnnotationName = "build.appstudio.openshift.io/build-nudge-files"
)

var hackRepo = Repository{Org: "openshift-knative", Repo: "hack"}

func GenerateKonflux(ctx context.Context, openshiftRelease Repository, configs []*Config) error {

operatorVersions, err := ServerlessOperatorKonfluxVersions(ctx)
if err != nil {
return fmt.Errorf("failed to get konflux versions for serverless-operator: %w", err)
}

if err := GitMirror(ctx, hackRepo); err != nil {
return err
}
if err := GitCheckout(ctx, hackRepo, "main"); err != nil {
return err
}

for _, config := range configs {
for _, r := range config.Repositories {

Expand Down Expand Up @@ -176,12 +185,13 @@ func GenerateKonflux(ctx context.Context, openshiftRelease Repository, configs [
Includes: []string{
fmt.Sprintf("ci-operator/config/%s/.*%s.*.yaml", r.RepositoryDirectory(), branchName),
},
Excludes: b.Konflux.Excludes,
ExcludesImages: b.Konflux.ExcludesImages,
JavaImages: b.Konflux.JavaImages,
ResourcesOutputPath: fmt.Sprintf("%s/.konflux", r.RepositoryDirectory()),
PipelinesOutputPath: fmt.Sprintf("%s/.tekton", r.RepositoryDirectory()),
Nudges: nudges,
Excludes: b.Konflux.Excludes,
ExcludesImages: b.Konflux.ExcludesImages,
JavaImages: b.Konflux.JavaImages,
ResourcesOutputPath: fmt.Sprintf("%s/.konflux", r.RepositoryDirectory()),
GlobalResourcesOutputPath: fmt.Sprintf("%s/.konflux", hackRepo.RepositoryDirectory()),
PipelinesOutputPath: fmt.Sprintf("%s/.tekton", r.RepositoryDirectory()),
Nudges: nudges,
// Preserve the version tag as first tag in any instance since SO, when bumping the patch version
// will change it before merging the PR.
// See `openshift-knative/serverless-operator/hack/generate/update-pipelines.sh` for more details.
Expand Down Expand Up @@ -217,6 +227,11 @@ func GenerateKonflux(ctx context.Context, openshiftRelease Repository, configs [
}
}

commitMsg := fmt.Sprintf("Sync Konflux configurations for serverless operator")
if err := PushBranch(ctx, hackRepo, nil, fmt.Sprintf("%s%s", KonfluxBranchPrefix, "main"), commitMsg); err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -290,14 +305,6 @@ func GenerateKonfluxServerlessOperator(ctx context.Context, openshiftRelease Rep
if err != nil {
return fmt.Errorf("failed to get Konflux versions for serverless operator: %w", err)
}

hackRepo := Repository{Org: "openshift-knative", Repo: "hack"}
if err := GitMirror(ctx, hackRepo); err != nil {
return err
}
if err := GitCheckout(ctx, hackRepo, "main"); err != nil {
return err
}
log.Println("Recreating konflux configurations for serverless operator")

resourceOutputPath := fmt.Sprintf("%s/.konflux", hackRepo.RepositoryDirectory())
Expand Down Expand Up @@ -387,6 +394,7 @@ func GenerateKonfluxServerlessOperator(ctx context.Context, openshiftRelease Rep
// main with the same name but different "revision" (branch).
ResourcesOutputPathSkipRemove: true,
ResourcesOutputPath: resourceOutputPath,
GlobalResourcesOutputPath: resourceOutputPath,
PipelinesOutputPath: fmt.Sprintf("%s/.tekton", r.RepositoryDirectory()),
Nudges: b.Konflux.Nudges,
NudgesFunc: func(cfg cioperatorapi.ReleaseBuildConfiguration, ib cioperatorapi.ProjectDirectoryImageBuildStepConfiguration) []string {
Expand Down Expand Up @@ -448,11 +456,6 @@ func GenerateKonfluxServerlessOperator(ctx context.Context, openshiftRelease Rep
log.Printf("::endgroup::\n\n")
}

commitMsg := fmt.Sprintf("Sync Konflux configurations for serverless operator")
if err := PushBranch(ctx, hackRepo, nil, fmt.Sprintf("%s%s", KonfluxBranchPrefix, "main"), commitMsg); err != nil {
return err
}

if err := writeDependabotConfig(ctx, dependabotConfig, r); err != nil {
return err
}
Expand Down

0 comments on commit 0069428

Please sign in to comment.