Skip to content
Merged
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
11 changes: 8 additions & 3 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
"sync"

"github.com/ory/viper"
Expand Down Expand Up @@ -163,7 +164,7 @@ func handleFuncCreate(w http.ResponseWriter, r *http.Request) {
return
}

if err := generateCIWorkflow(root, cfg.Branch); err != nil {
if err := generateCIWorkflow(root, cfg.Branch, cfg.Registry); err != nil {
http.Error(w, "failed to generate CI workflow: "+err.Error(), http.StatusInternalServerError)
return
}
Expand Down Expand Up @@ -214,10 +215,14 @@ func handleFuncCreate(w http.ResponseWriter, r *http.Request) {
}
}

func generateCIWorkflow(root, branch string) error {
const ocpInternalRegistry = "image-registry.openshift-image-registry.svc:5000/"

func generateCIWorkflow(root, branch, registry string) error {
ciMu.Lock()
defer ciMu.Unlock()

useRegistryLogin := !strings.HasPrefix(registry, ocpInternalRegistry)

viper.Set(ci.PlatformFlag, ci.DefaultPlatform)
viper.Set(ci.PathFlag, root)
viper.Set(ci.BranchFlag, branch)
Expand All @@ -227,7 +232,7 @@ func generateCIWorkflow(root, branch string) error {
viper.Set(ci.RegistryUserVariableNameFlag, ci.DefaultRegistryUserVariableName)
viper.Set(ci.RegistryPassSecretNameFlag, ci.DefaultRegistryPassSecretName)
viper.Set(ci.RegistryUrlVariableNameFlag, ci.DefaultRegistryUrlVariableName)
viper.Set(ci.UseRegistryLoginFlag, ci.DefaultUseRegistryLogin)
viper.Set(ci.UseRegistryLoginFlag, useRegistryLogin)
viper.Set(ci.WorkflowDispatchFlag, ci.DefaultWorkflowDispatch)
viper.Set(ci.UseRemoteBuildFlag, ci.DefaultUseRemoteBuild)
viper.Set(ci.UseSelfHostedRunnerFlag, ci.DefaultUseSelfHostedRunner)
Expand Down