diff --git a/Dockerfile b/Dockerfile index eaa5d09f..f2802dd9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,7 @@ RUN go mod download COPY main.go main.go COPY api/ api/ COPY controllers/ controllers/ +COPY internal/ internal/ # build RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o source-controller main.go diff --git a/controllers/helmrepository_controller.go b/controllers/helmrepository_controller.go index 878a8fd3..f2511388 100644 --- a/controllers/helmrepository_controller.go +++ b/controllers/helmrepository_controller.go @@ -209,6 +209,19 @@ func (r *HelmRepositoryReconciler) index(repository sourcev1.HelmRepository) (so }, "", err } + // acquire lock + unlock, err := r.Storage.Lock(artifact) + if err != nil { + err = fmt.Errorf("unable to acquire lock: %w", err) + return sourcev1.SourceCondition{ + Type: sourcev1.ReadyCondition, + Status: corev1.ConditionFalse, + Reason: sourcev1.IndexFetchFailedReason, + Message: err.Error(), + }, "", err + } + defer unlock() + // save artifact to storage err = r.Storage.WriteFile(artifact, index) if err != nil {