mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Add options object for PortainerClient.StackCreateCompose()
This commit is contained in:
parent
768410ce20
commit
17b941d108
@ -33,6 +33,14 @@ type StackCreateSwarmOptions struct {
|
||||
EndpointID portainer.EndpointID
|
||||
}
|
||||
|
||||
// StackCreateComposeOptions represents options passed to PortainerClient.StackCreateCompose()
|
||||
type StackCreateComposeOptions struct {
|
||||
StackName string
|
||||
EnvironmentVariables []portainer.Pair
|
||||
StackFileContent string
|
||||
EndpointID portainer.EndpointID
|
||||
}
|
||||
|
||||
// Config represents a Portainer client configuration
|
||||
type Config struct {
|
||||
URL *url.URL
|
||||
@ -61,7 +69,7 @@ type PortainerClient interface {
|
||||
StackCreateSwarm(options StackCreateSwarmOptions) (stack portainer.Stack, err error)
|
||||
|
||||
// Create compose stack
|
||||
StackCreateCompose(stackName string, environmentVariables []portainer.Pair, stackFileContent string, endpointID portainer.EndpointID) (stack portainer.Stack, err error)
|
||||
StackCreateCompose(options StackCreateComposeOptions) (stack portainer.Stack, err error)
|
||||
|
||||
// Update stack
|
||||
StackUpdate(stack portainer.Stack, environmentVariables []portainer.Pair, stackFileContent string, prune bool, endpointID portainer.EndpointID) error
|
||||
@ -265,14 +273,14 @@ func (n *portainerClientImp) StackCreateSwarm(options StackCreateSwarmOptions) (
|
||||
return
|
||||
}
|
||||
|
||||
func (n *portainerClientImp) StackCreateCompose(stackName string, environmentVariables []portainer.Pair, stackFileContent string, endpointID portainer.EndpointID) (stack portainer.Stack, err error) {
|
||||
func (n *portainerClientImp) StackCreateCompose(options StackCreateComposeOptions) (stack portainer.Stack, err error) {
|
||||
reqBody := StackCreateRequest{
|
||||
Name: stackName,
|
||||
Env: environmentVariables,
|
||||
StackFileContent: stackFileContent,
|
||||
Name: options.StackName,
|
||||
Env: options.EnvironmentVariables,
|
||||
StackFileContent: options.StackFileContent,
|
||||
}
|
||||
|
||||
err = n.doJSONWithToken(fmt.Sprintf("stacks?type=%v&method=%s&endpointId=%v", 2, "string", endpointID), http.MethodPost, http.Header{}, &reqBody, &stack)
|
||||
err = n.doJSONWithToken(fmt.Sprintf("stacks?type=%v&method=%s&endpointId=%v", 2, "string", options.EndpointID), http.MethodPost, http.Header{}, &reqBody, &stack)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,12 @@ var stackDeployCmd = &cobra.Command{
|
||||
"stack": stackName,
|
||||
"endpoint": endpoint.Name,
|
||||
}).Info("Creating stack")
|
||||
stack, deploymentErr := portainerClient.StackCreateCompose(stackName, loadedEnvironmentVariables, stackFileContent, endpoint.ID)
|
||||
stack, deploymentErr := portainerClient.StackCreateCompose(client.StackCreateComposeOptions{
|
||||
StackName: stackName,
|
||||
EnvironmentVariables: loadedEnvironmentVariables,
|
||||
StackFileContent: stackFileContent,
|
||||
EndpointID: endpoint.ID,
|
||||
})
|
||||
common.CheckError(deploymentErr)
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"stack": stack.Name,
|
||||
|
Loading…
Reference in New Issue
Block a user