psu/client/stack_update.go
Juan Carlos Mejías Rodríguez 63c82efd33 Export doJSONWithToken
2019-11-26 23:27:15 -05:00

36 lines
1012 B
Go

package client
import (
"fmt"
"net/http"
portainer "github.com/portainer/portainer/api"
)
// StackUpdateOptions represents options passed to PortainerClient.StackUpdate()
type StackUpdateOptions struct {
Stack portainer.Stack
EnvironmentVariables []portainer.Pair
StackFileContent string
Prune bool
EndpointID portainer.EndpointID
}
// StackUpdateRequest represents the body of a request to PUT /stacks/{id}
type StackUpdateRequest struct {
StackFileContent string
Env []portainer.Pair `json:",omitempty"`
Prune bool
}
func (n *portainerClientImp) StackUpdate(options StackUpdateOptions) (err error) {
reqBody := StackUpdateRequest{
Env: options.EnvironmentVariables,
StackFileContent: options.StackFileContent,
Prune: options.Prune,
}
err = n.DoJSONWithToken(fmt.Sprintf("stacks/%v?endpointId=%v", options.Stack.ID, options.EndpointID), http.MethodPut, http.Header{}, &reqBody, nil)
return
}