Просмотр исходного кода

delete basic auth when updating helm repo

Mohammed Nafees 3 лет назад
Родитель
Сommit
bbee5854a8
1 измененных файлов с 18 добавлено и 0 удалено
  1. 18 0
      api/server/handlers/helmrepo/update.go

+ 18 - 0
api/server/handlers/helmrepo/update.go

@@ -51,6 +51,24 @@ func (p *HelmRepoUpdateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
 		return
 	}
 
+	if helmRepo.BasicAuthIntegrationID != 0 {
+		bi, err := p.Repo().BasicIntegration().ReadBasicIntegration(proj.ID, helmRepo.BasicAuthIntegrationID)
+
+		if err != nil {
+			if !errors.Is(err, gorm.ErrRecordNotFound) {
+				p.HandleAPIError(w, r, apierrors.NewErrInternal(err))
+				return
+			}
+		} else {
+			_, err = p.Repo().BasicIntegration().DeleteBasicIntegration(bi)
+
+			if err != nil {
+				p.HandleAPIError(w, r, apierrors.NewErrInternal(err))
+				return
+			}
+		}
+	}
+
 	request := &types.CreateUpdateHelmRepoRequest{}
 
 	ok := p.DecodeAndValidate(w, r, request)