瀏覽代碼

delete basic auth when updating helm repo

Mohammed Nafees 3 年之前
父節點
當前提交
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)