mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
feat(api): rewrite SwarmInspect operation (#2065)
* feat(api): rewrite SwarmInspect operation * refactor(api): remove useless statements
This commit is contained in:
parent
b1227b17e1
commit
98b0ab50fc
2 changed files with 24 additions and 1 deletions
23
api/http/proxy/swarm.go
Normal file
23
api/http/proxy/swarm.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package proxy
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 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 := getResponseAsJSONOBject(response)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !executor.operationContext.isAdmin {
|
||||
delete(responseObject, "JoinTokens")
|
||||
delete(responseObject, "TLSInfo")
|
||||
}
|
||||
|
||||
return rewriteResponse(response, responseObject, http.StatusOK)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue