Skip to content

Commit

Permalink
Reconcile default helm repo in the release controller
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Pavlov <[email protected]>
  • Loading branch information
Kshatrix committed Oct 7, 2024
1 parent 3ff7029 commit 38da748
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ func main() {
CreateRelease: createRelease,
HMCTemplatesChartName: hmcTemplatesChartName,
SystemNamespace: currentNamespace,
DefaultRegistryConfig: helm.DefaultRegistryConfig{
URL: defaultRegistryURL,
RepoType: determinedRepositoryType,
CredentialsSecret: registryCredentialsSecret,
Insecure: insecureRegistry,
},
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Release")
os.Exit(1)
Expand Down
14 changes: 12 additions & 2 deletions internal/controller/release_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type ReleaseReconciler struct {

HMCTemplatesChartName string
SystemNamespace string

DefaultRegistryConfig helm.DefaultRegistryConfig
}

func (r *ReleaseReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
Expand Down Expand Up @@ -150,8 +152,8 @@ func (r *ReleaseReconciler) ensureManagement(ctx context.Context) error {

func (r *ReleaseReconciler) reconcileHMCTemplates(ctx context.Context, req ctrl.Request) error {
l := ctrl.LoggerFrom(ctx)
if !r.CreateRelease {
l.Info("Reconciling HMC Templates is skipped")
if initialReconcile(req) && !r.CreateRelease {
l.Info("Initial creation of HMC Release is skipped")
return nil
}
name := utils.ReleaseNameFromVersion(build.Version)
Expand All @@ -175,6 +177,14 @@ func (r *ReleaseReconciler) reconcileHMCTemplates(ctx context.Context, req ctrl.
}
}

if initialReconcile(req) {
err := helm.ReconcileHelmRepository(ctx, r.Client, defaultRepoName, r.SystemNamespace, r.DefaultRegistryConfig.HelmRepositorySpec())
if err != nil {
l.Error(err, "Failed to reconcile default HelmRepository", "namespace", r.SystemNamespace)
return err
}
}

helmChart := &sourcev1.HelmChart{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand Down

0 comments on commit 38da748

Please sign in to comment.