diff --git a/api/http/handler/customtemplates/customtemplate_create.go b/api/http/handler/customtemplates/customtemplate_create.go index 34a291fb5..d8fdb3865 100644 --- a/api/http/handler/customtemplates/customtemplate_create.go +++ b/api/http/handler/customtemplates/customtemplate_create.go @@ -380,12 +380,14 @@ func (payload *customTemplateFromFileUploadPayload) Validate(r *http.Request) er payload.FileContent = composeFileContent varsString, _ := request.RetrieveMultiPartFormValue(r, "Variables", true) - err = json.Unmarshal([]byte(varsString), &payload.Variables) - if err != nil { - return errors.New("Invalid variables. Ensure that the variables are valid JSON") + if varsString != "" { + err = json.Unmarshal([]byte(varsString), &payload.Variables) + if err != nil { + return errors.New("Invalid variables. Ensure that the variables are valid JSON") + } + return validateVariablesDefinitions(payload.Variables) } - - return validateVariablesDefinitions(payload.Variables) + return nil } func (handler *Handler) createCustomTemplateFromFileUpload(r *http.Request) (*portainer.CustomTemplate, error) { diff --git a/app/portainer/views/custom-templates/create-custom-template-view/createCustomTemplateView.html b/app/portainer/views/custom-templates/create-custom-template-view/createCustomTemplateView.html index 0c9643c9a..625d5ac1e 100644 --- a/app/portainer/views/custom-templates/create-custom-template-view/createCustomTemplateView.html +++ b/app/portainer/views/custom-templates/create-custom-template-view/createCustomTemplateView.html @@ -83,9 +83,6 @@ {{ $ctrl.formValues.File.name }} - - -