Add hideFields()

pull/2972/head
ssbkang 2019-06-28 22:45:34 +12:00
parent 1732548e59
commit adf8846c28
4 changed files with 12 additions and 0 deletions

View File

@ -49,5 +49,7 @@ func (handler *Handler) deploymentkeyCreate(w http.ResponseWriter, r *http.Reque
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist the deployment key inside the database", err} return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist the deployment key inside the database", err}
} }
hideFields(deploymentkey)
return response.JSON(w, deploymentkey) return response.JSON(w, deploymentkey)
} }

View File

@ -23,5 +23,7 @@ func (handler *Handler) deploymentkeyInspect(w http.ResponseWriter, r *http.Requ
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to find a deployment key with the specified identifier inside the database", err} return &httperror.HandlerError{http.StatusInternalServerError, "Unable to find a deployment key with the specified identifier inside the database", err}
} }
hideFields(deploymentkey)
return response.JSON(w, deploymentkey) return response.JSON(w, deploymentkey)
} }

View File

@ -14,5 +14,9 @@ func (handler *Handler) deploymentkeyList(w http.ResponseWriter, r *http.Request
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve deploymentkeys from the database", err} return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve deploymentkeys from the database", err}
} }
for idx := range deploymentkeys {
hideFields(&deploymentkeys[idx])
}
return response.JSON(w, deploymentkeys) return response.JSON(w, deploymentkeys)
} }

View File

@ -15,6 +15,10 @@ type Handler struct {
DeploymentKeyService portainer.DeploymentKeyService DeploymentKeyService portainer.DeploymentKeyService
} }
func hideFields(deploymentkey *portainer.DeploymentKey) {
deploymentkey.PrivateKey = ""
}
// NewHandler creates a handler to manage settings operations. // NewHandler creates a handler to manage settings operations.
func NewHandler(bouncer *security.RequestBouncer) *Handler { func NewHandler(bouncer *security.RequestBouncer) *Handler {
h := &Handler{ h := &Handler{