1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

fix(code): clean up EE-4432 (#7865)

This commit is contained in:
andres-portainer 2022-10-14 18:09:07 -03:00 committed by GitHub
parent 367f3dd6d4
commit ae2bec4bd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 25 additions and 111 deletions

View file

@ -142,12 +142,7 @@ func (payload *customTemplateFromFileContentPayload) Validate(r *http.Request) e
return errors.New("Invalid note. <img> tag is not supported")
}
err := validateVariablesDefinitions(payload.Variables)
if err != nil {
return err
}
return nil
return validateVariablesDefinitions(payload.Variables)
}
func isValidNote(note string) bool {
@ -251,12 +246,7 @@ func (payload *customTemplateFromGitRepositoryPayload) Validate(r *http.Request)
return errors.New("Invalid note. <img> tag is not supported")
}
err := validateVariablesDefinitions(payload.Variables)
if err != nil {
return err
}
return nil
return validateVariablesDefinitions(payload.Variables)
}
func (handler *Handler) createCustomTemplateFromGitRepository(r *http.Request) (*portainer.CustomTemplate, error) {
@ -395,12 +385,7 @@ func (payload *customTemplateFromFileUploadPayload) Validate(r *http.Request) er
return errors.New("Invalid variables. Ensure that the variables are valid JSON")
}
err = validateVariablesDefinitions(payload.Variables)
if err != nil {
return err
}
return nil
return validateVariablesDefinitions(payload.Variables)
}
func (handler *Handler) createCustomTemplateFromFileUpload(r *http.Request) (*portainer.CustomTemplate, error) {

View file

@ -55,12 +55,7 @@ func (payload *customTemplateUpdatePayload) Validate(r *http.Request) error {
return errors.New("Invalid note. <img> tag is not supported")
}
err := validateVariablesDefinitions(payload.Variables)
if err != nil {
return err
}
return nil
return validateVariablesDefinitions(payload.Variables)
}
// @id CustomTemplateUpdate

View file

@ -190,12 +190,8 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) *
switch *payload.Status {
case 1:
endpoint.Status = portainer.EndpointStatusUp
break
case 2:
endpoint.Status = portainer.EndpointStatusDown
break
default:
break
}
}
@ -328,7 +324,7 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) *
err = handler.SnapshotService.FillSnapshotData(endpoint)
if err != nil {
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to add snapshot data", err}
return httperror.InternalServerError("Unable to add snapshot data", err)
}
return response.JSON(w, endpoint)

View file

@ -128,12 +128,7 @@ func (handler *Handler) addDefaultProfile() error {
profile.FilePath = filePath
profile.DateCreated = time.Now().Unix()
err = handler.DataStore.FDOProfile().Create(profile)
if err != nil {
return err
}
return nil
return handler.DataStore.FDOProfile().Create(profile)
}
const defaultProfileFileContent = `

View file

@ -169,12 +169,8 @@ func (handler *Handler) saveConfiguration(configuration portainer.OpenAMTConfigu
configuration.MPSToken = ""
settings.OpenAMTConfiguration = configuration
err = handler.DataStore.Settings().UpdateSettings(settings)
if err != nil {
return err
}
return nil
return handler.DataStore.Settings().UpdateSettings(settings)
}
func (handler *Handler) disableOpenAMT() error {

View file

@ -295,11 +295,8 @@ func (handler *Handler) activateDevice(endpoint *portainer.Endpoint, settings po
}
_, err := handler.PullAndRunContainer(ctx, endpoint, rpcGoImageName, rpcGoContainerName, cmdLine)
if err != nil {
return err
}
return nil
return err
}
func (handler *Handler) deactivateDevice(endpoint *portainer.Endpoint, settings portainer.Settings) error {
@ -315,9 +312,6 @@ func (handler *Handler) deactivateDevice(endpoint *portainer.Endpoint, settings
}
_, err := handler.PullAndRunContainer(ctx, endpoint, rpcGoImageName, rpcGoContainerName, cmdLine)
if err != nil {
return err
}
return nil
return err
}

View file

@ -328,7 +328,7 @@ PayloadLoop:
updatedClass.GloballyBlocked = existingClass.GloballyBlocked
// Handle "allow"
if p.Availability == true {
if p.Availability {
// remove the namespace from the list of blocked namespaces
// in the existingClass.
for _, blockedNS := range existingClass.BlockedNamespaces {

View file

@ -251,12 +251,7 @@ func (handler *Handler) settingsUpdate(w http.ResponseWriter, r *http.Request) *
func (handler *Handler) updateSnapshotInterval(settings *portainer.Settings, snapshotInterval string) error {
settings.SnapshotInterval = snapshotInterval
err := handler.SnapshotService.SetSnapshotInterval(snapshotInterval)
if err != nil {
return err
}
return nil
return handler.SnapshotService.SetSnapshotInterval(snapshotInterval)
}
func (handler *Handler) updateTLS(settings *portainer.Settings) *httperror.HandlerError {

View file

@ -116,12 +116,7 @@ func hijackAttachStartOperation(websocketConn *websocket.Conn, endpoint *portain
return err
}
err = hijackRequest(websocketConn, httpConn, attachStartRequest)
if err != nil {
return err
}
return nil
return hijackRequest(websocketConn, httpConn, attachStartRequest)
}
func createAttachStartRequest(attachID string) (*http.Request, error) {

View file

@ -121,12 +121,7 @@ func hijackExecStartOperation(websocketConn *websocket.Conn, endpoint *portainer
return err
}
err = hijackRequest(websocketConn, httpConn, execStartRequest)
if err != nil {
return err
}
return nil
return hijackRequest(websocketConn, httpConn, execStartRequest)
}
func createExecStartRequest(execID string) (*http.Request, error) {