Skip to content

Commit

Permalink
Merge pull request #249 from uselagoon/unauthenticated-registry
Browse files Browse the repository at this point in the history
refactor: add basic unauthenticated registry passthrough
  • Loading branch information
shreddedbacon authored Feb 23, 2024
2 parents 3e7c32f + 842ca82 commit 23db49f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions controllers/v1beta1/build_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type LagoonBuildReconciler struct {
LagoonFeatureFlags map[string]string
LagoonAPIConfiguration helpers.LagoonAPIConfiguration
ProxyConfig ProxyConfig
UnauthenticatedRegistry string
}

// BackupConfig holds all the backup configuration settings
Expand Down
2 changes: 1 addition & 1 deletion controllers/v1beta1/build_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ func (r *LagoonBuildReconciler) processBuild(ctx context.Context, opLog logr.Log
})
podEnvs = append(podEnvs, corev1.EnvVar{
Name: "REGISTRY",
Value: lagoonBuild.Spec.Project.Registry,
Value: r.UnauthenticatedRegistry,
})
// this is enabled by default for now
// eventually will be disabled by default because support for the generation/modification of this will
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ func main() {
var enablePodProxy bool
var podsUseDifferentProxy bool

var unauthenticatedRegistry string

flag.StringVar(&metricsAddr, "metrics-addr", ":8080",
"The address the metric endpoint binds to.")
flag.StringVar(&lagoonTargetName, "lagoon-target-name", "ci-local-control-k8s",
Expand Down Expand Up @@ -334,6 +336,9 @@ func main() {
flag.StringVar(&harborWebhookEventTypes, "harbor-webhook-eventtypes", "SCANNING_FAILED,SCANNING_COMPLETED",
"The event types to use for the Lagoon webhook")

// this is for legacy reasons, and backwards compatability support due to removal of https://github.com/uselagoon/lagoon/pull/3659
flag.StringVar(&unauthenticatedRegistry, "unauthenticated-registry", "registry.lagoon.svc:5000", "An unauthenticated registry URL that could be used for local testing without a harbor")

// NS cleanup configuration
flag.BoolVar(&cleanNamespacesEnabled, "enable-namespace-cleanup", false,
"Tells the controller to remove namespaces marked for deletion with labels (lagoon.sh/expiration=<unixtimestamp>).")
Expand Down Expand Up @@ -407,6 +412,8 @@ func main() {

nativeCronPodMinFrequency = helpers.GetEnvInt("NATIVE_CRON_POD_MINIMUM_FREQUENCY", nativeCronPodMinFrequency)

unauthenticatedRegistry = helpers.GetEnv("UNAUTHENTICATED_REGISTRY", unauthenticatedRegistry)

// harbor envvars
harborURL = helpers.GetEnv("HARBOR_URL", harborURL)
harborAPI = helpers.GetEnv("HARBOR_API", harborAPI)
Expand Down Expand Up @@ -805,6 +812,7 @@ func main() {
HTTPSProxy: httpsProxy,
NoProxy: noProxy,
},
UnauthenticatedRegistry: unauthenticatedRegistry,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "LagoonBuild")
os.Exit(1)
Expand Down

0 comments on commit 23db49f

Please sign in to comment.