Skip to content

Commit

Permalink
fix: helmrepository creation errors out because it already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
waveywaves committed Jun 30, 2023
1 parent 58f4a50 commit a4542d3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 0.0.16
VERSION ?= 0.0.17

# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
Expand Down
2 changes: 1 addition & 1 deletion chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version: 0.1.2
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.0.16"
appVersion: "v0.0.17"
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
Expand Down
21 changes: 16 additions & 5 deletions controllers/uffizzicluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -88,11 +89,21 @@ const (
func (r *UffizziClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
logger := log.FromContext(ctx)

// create the loft helm repo if it is not already created
err := r.createLoftHelmRepo(ctx, req)
// check if error is because the HelmRepository already exists
if err != nil && !k8serrors.IsAlreadyExists(err) {
logger.Error(err, "error while creating HelmRepository for Loft")
loftHelmRepo := &fluxsourcev1.HelmRepository{}
err := r.Get(ctx, types.NamespacedName{
Name: LOFT_HELM_REPO,
Namespace: req.Namespace,
}, loftHelmRepo)

// check if error is because the HelmRepository does not exist
if err != nil && k8serrors.IsNotFound(err) {
// create the loft helm repo if it is not already created
logger.Info("HelmRepository for Loft created")
err := r.createLoftHelmRepo(ctx, req)
// check if error is because the HelmRepository already exists
if err != nil && !k8serrors.IsAlreadyExists(err) {
logger.Error(err, "error while creating HelmRepository for Loft")
}
}

// Fetch the UffizziCluster instance in question
Expand Down

0 comments on commit a4542d3

Please sign in to comment.