mirror of https://github.com/portainer/portainer
fix(helm): allow settings to be saved offline EE-1907 (#5908)
* skip validating default helm repo to allow offline saving of settings. Default repo is hardcoded and correct. * dont validate the helm repo if the repo hasn't changed or is the default * fix logicpull/5921/head
parent
9dcd5651e8
commit
006634e007
|
@ -54,11 +54,8 @@ func (payload *settingsUpdatePayload) Validate(r *http.Request) error {
|
||||||
if payload.TemplatesURL != nil && *payload.TemplatesURL != "" && !govalidator.IsURL(*payload.TemplatesURL) {
|
if payload.TemplatesURL != nil && *payload.TemplatesURL != "" && !govalidator.IsURL(*payload.TemplatesURL) {
|
||||||
return errors.New("Invalid external templates URL. Must correspond to a valid URL format")
|
return errors.New("Invalid external templates URL. Must correspond to a valid URL format")
|
||||||
}
|
}
|
||||||
if payload.HelmRepositoryURL != nil && *payload.HelmRepositoryURL != "" {
|
if payload.HelmRepositoryURL != nil && *payload.HelmRepositoryURL != "" && !govalidator.IsURL(*payload.HelmRepositoryURL) {
|
||||||
err := libhelm.ValidateHelmRepositoryURL(*payload.HelmRepositoryURL)
|
return errors.New("Invalid Helm repository URL. Must correspond to a valid URL format")
|
||||||
if err != nil {
|
|
||||||
return errors.Wrap(err, "Invalid Helm repository URL. Must correspond to a valid URL format")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if payload.UserSessionTimeout != nil {
|
if payload.UserSessionTimeout != nil {
|
||||||
_, err := time.ParseDuration(*payload.UserSessionTimeout)
|
_, err := time.ParseDuration(*payload.UserSessionTimeout)
|
||||||
|
@ -114,7 +111,16 @@ func (handler *Handler) settingsUpdate(w http.ResponseWriter, r *http.Request) *
|
||||||
}
|
}
|
||||||
|
|
||||||
if payload.HelmRepositoryURL != nil {
|
if payload.HelmRepositoryURL != nil {
|
||||||
settings.HelmRepositoryURL = strings.TrimSuffix(strings.ToLower(*payload.HelmRepositoryURL), "/")
|
newHelmRepo := strings.TrimSuffix(strings.ToLower(*payload.HelmRepositoryURL), "/")
|
||||||
|
|
||||||
|
if newHelmRepo != settings.HelmRepositoryURL && newHelmRepo != portainer.DefaultHelmRepositoryURL {
|
||||||
|
err := libhelm.ValidateHelmRepositoryURL(*payload.HelmRepositoryURL)
|
||||||
|
if err != nil {
|
||||||
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid Helm repository URL. Must correspond to a valid URL format", err}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.HelmRepositoryURL = newHelmRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
if payload.BlackListedLabels != nil {
|
if payload.BlackListedLabels != nil {
|
||||||
|
|
Loading…
Reference in New Issue