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
|
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
|
// Config represents a Portainer client configuration
|
||||||
type Config struct {
|
type Config struct {
|
||||||
URL *url.URL
|
URL *url.URL
|
||||||
@ -61,7 +69,7 @@ type PortainerClient interface {
|
|||||||
StackCreateSwarm(options StackCreateSwarmOptions) (stack portainer.Stack, err error)
|
StackCreateSwarm(options StackCreateSwarmOptions) (stack portainer.Stack, err error)
|
||||||
|
|
||||||
// Create compose stack
|
// 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
|
// Update stack
|
||||||
StackUpdate(stack portainer.Stack, environmentVariables []portainer.Pair, stackFileContent string, prune bool, endpointID portainer.EndpointID) error
|
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
|
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{
|
reqBody := StackCreateRequest{
|
||||||
Name: stackName,
|
Name: options.StackName,
|
||||||
Env: environmentVariables,
|
Env: options.EnvironmentVariables,
|
||||||
StackFileContent: stackFileContent,
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,12 @@ var stackDeployCmd = &cobra.Command{
|
|||||||
"stack": stackName,
|
"stack": stackName,
|
||||||
"endpoint": endpoint.Name,
|
"endpoint": endpoint.Name,
|
||||||
}).Info("Creating stack")
|
}).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)
|
common.CheckError(deploymentErr)
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"stack": stack.Name,
|
"stack": stack.Name,
|
||||||
|
Loading…
Reference in New Issue
Block a user