mirror of https://github.com/portainer/portainer
26 lines
821 B
Go
26 lines
821 B
Go
package docker
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/portainer/portainer/api/http/proxy/factory/responseutils"
|
|
)
|
|
|
|
// swarmInspectOperation extracts the response as a JSON object and rewrites the response based
|
|
// on the current user role. Sensitive fields are deleted from the response for non-administrator users.
|
|
func swarmInspectOperation(response *http.Response, executor *operationExecutor) error {
|
|
// SwarmInspect response is a JSON object
|
|
// https://docs.docker.com/engine/api/v1.30/#operation/SwarmInspect
|
|
responseObject, err := responseutils.GetResponseAsJSONOBject(response)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if !executor.operationContext.isAdmin {
|
|
delete(responseObject, "JoinTokens")
|
|
delete(responseObject, "TLSInfo")
|
|
}
|
|
|
|
return responseutils.RewriteResponse(response, responseObject, http.StatusOK)
|
|
}
|