From 3f51d077ace829e13f58dfbbbd3729f13d745d55 Mon Sep 17 00:00:00 2001 From: Rex Wang <109048808+RexWangPT@users.noreply.github.com> Date: Thu, 20 Oct 2022 16:42:49 +0800 Subject: [PATCH] fix(docker): create custom template [EE-4114] (#7812) * EE-4114 fix(docker): create custom template * Update customtemplate_create.go remove white space --- .../handler/customtemplates/customtemplate_create.go | 12 +++++++----- .../createCustomTemplateView.html | 3 --- 2 files changed, 7 insertions(+), 8 deletions(-) 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 }} - - -