2018-06-11 13:13:19 +00:00
|
|
|
package stacks
|
|
|
|
|
|
|
|
import (
|
2019-10-07 03:12:21 +00:00
|
|
|
"errors"
|
2018-06-11 13:13:19 +00:00
|
|
|
"net/http"
|
2019-10-07 03:12:21 +00:00
|
|
|
"path"
|
2019-11-24 01:28:07 +00:00
|
|
|
"regexp"
|
2018-06-20 17:55:00 +00:00
|
|
|
"strconv"
|
2018-06-11 13:13:19 +00:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/asaskevich/govalidator"
|
2018-09-10 10:01:38 +00:00
|
|
|
httperror "github.com/portainer/libhttp/error"
|
|
|
|
"github.com/portainer/libhttp/request"
|
2019-03-21 01:20:14 +00:00
|
|
|
"github.com/portainer/portainer/api"
|
|
|
|
"github.com/portainer/portainer/api/filesystem"
|
|
|
|
"github.com/portainer/portainer/api/http/security"
|
2018-06-11 13:13:19 +00:00
|
|
|
)
|
|
|
|
|
2019-11-24 01:28:07 +00:00
|
|
|
// this is coming from libcompose
|
|
|
|
// https://github.com/portainer/libcompose/blob/master/project/context.go#L117-L120
|
|
|
|
func normalizeStackName(name string) string {
|
|
|
|
r := regexp.MustCompile("[^a-z0-9]+")
|
|
|
|
return r.ReplaceAllString(strings.ToLower(name), "")
|
|
|
|
}
|
|
|
|
|
2018-06-11 13:13:19 +00:00
|
|
|
type composeStackFromFileContentPayload struct {
|
|
|
|
Name string
|
|
|
|
StackFileContent string
|
2018-07-12 07:17:07 +00:00
|
|
|
Env []portainer.Pair
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (payload *composeStackFromFileContentPayload) Validate(r *http.Request) error {
|
|
|
|
if govalidator.IsNull(payload.Name) {
|
2020-07-07 21:57:52 +00:00
|
|
|
return errors.New("Invalid stack name")
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
2019-11-24 01:28:07 +00:00
|
|
|
payload.Name = normalizeStackName(payload.Name)
|
2018-06-11 13:13:19 +00:00
|
|
|
if govalidator.IsNull(payload.StackFileContent) {
|
2020-07-07 21:57:52 +00:00
|
|
|
return errors.New("Invalid stack file content")
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-12 23:41:42 +00:00
|
|
|
func (handler *Handler) createComposeStackFromFileContent(w http.ResponseWriter, r *http.Request, endpoint *portainer.Endpoint, userID portainer.UserID) *httperror.HandlerError {
|
2018-06-11 13:13:19 +00:00
|
|
|
var payload composeStackFromFileContentPayload
|
|
|
|
err := request.DecodeAndValidateJSONPayload(r, &payload)
|
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid request payload", err}
|
|
|
|
}
|
|
|
|
|
2020-05-20 05:23:15 +00:00
|
|
|
stacks, err := handler.DataStore.Stack().Stacks()
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve stacks from the database", err}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, stack := range stacks {
|
|
|
|
if strings.EqualFold(stack.Name, payload.Name) {
|
2020-07-07 21:57:52 +00:00
|
|
|
return &httperror.HandlerError{http.StatusConflict, "A stack with this name already exists", errStackAlreadyExists}
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-20 05:23:15 +00:00
|
|
|
stackID := handler.DataStore.Stack().GetNextIdentifier()
|
2018-06-11 13:13:19 +00:00
|
|
|
stack := &portainer.Stack{
|
2018-06-18 10:07:56 +00:00
|
|
|
ID: portainer.StackID(stackID),
|
2018-06-11 13:13:19 +00:00
|
|
|
Name: payload.Name,
|
|
|
|
Type: portainer.DockerComposeStack,
|
|
|
|
EndpointID: endpoint.ID,
|
|
|
|
EntryPoint: filesystem.ComposeFileDefaultName,
|
2018-07-12 07:17:07 +00:00
|
|
|
Env: payload.Env,
|
2020-08-03 22:18:53 +00:00
|
|
|
Status: portainer.StackStatusActive,
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-20 17:55:00 +00:00
|
|
|
stackFolder := strconv.Itoa(int(stack.ID))
|
|
|
|
projectPath, err := handler.FileService.StoreStackFileFromBytes(stackFolder, stack.EntryPoint, []byte(payload.StackFileContent))
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist Compose file on disk", err}
|
|
|
|
}
|
|
|
|
stack.ProjectPath = projectPath
|
|
|
|
|
|
|
|
doCleanUp := true
|
|
|
|
defer handler.cleanUp(stack, &doCleanUp)
|
|
|
|
|
|
|
|
config, configErr := handler.createComposeDeployConfig(r, stack, endpoint)
|
|
|
|
if configErr != nil {
|
|
|
|
return configErr
|
|
|
|
}
|
|
|
|
|
|
|
|
err = handler.deployComposeStack(config)
|
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, err.Error(), err}
|
|
|
|
}
|
|
|
|
|
2020-05-20 05:23:15 +00:00
|
|
|
err = handler.DataStore.Stack().CreateStack(stack)
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist the stack inside the database", err}
|
|
|
|
}
|
|
|
|
|
|
|
|
doCleanUp = false
|
2019-11-12 23:41:42 +00:00
|
|
|
return handler.decorateStackResponse(w, stack, userID)
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type composeStackFromGitRepositoryPayload struct {
|
|
|
|
Name string
|
|
|
|
RepositoryURL string
|
2018-07-24 14:11:35 +00:00
|
|
|
RepositoryReferenceName string
|
2018-06-11 13:13:19 +00:00
|
|
|
RepositoryAuthentication bool
|
|
|
|
RepositoryUsername string
|
|
|
|
RepositoryPassword string
|
|
|
|
ComposeFilePathInRepository string
|
2018-07-12 07:17:07 +00:00
|
|
|
Env []portainer.Pair
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (payload *composeStackFromGitRepositoryPayload) Validate(r *http.Request) error {
|
|
|
|
if govalidator.IsNull(payload.Name) {
|
2020-07-07 21:57:52 +00:00
|
|
|
return errors.New("Invalid stack name")
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
2019-11-24 01:28:07 +00:00
|
|
|
payload.Name = normalizeStackName(payload.Name)
|
2018-06-11 13:13:19 +00:00
|
|
|
if govalidator.IsNull(payload.RepositoryURL) || !govalidator.IsURL(payload.RepositoryURL) {
|
2020-07-07 21:57:52 +00:00
|
|
|
return errors.New("Invalid repository URL. Must correspond to a valid URL format")
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
if payload.RepositoryAuthentication && (govalidator.IsNull(payload.RepositoryUsername) || govalidator.IsNull(payload.RepositoryPassword)) {
|
2020-07-07 21:57:52 +00:00
|
|
|
return errors.New("Invalid repository credentials. Username and password must be specified when authentication is enabled")
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
if govalidator.IsNull(payload.ComposeFilePathInRepository) {
|
|
|
|
payload.ComposeFilePathInRepository = filesystem.ComposeFileDefaultName
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-12 23:41:42 +00:00
|
|
|
func (handler *Handler) createComposeStackFromGitRepository(w http.ResponseWriter, r *http.Request, endpoint *portainer.Endpoint, userID portainer.UserID) *httperror.HandlerError {
|
2018-06-11 13:13:19 +00:00
|
|
|
var payload composeStackFromGitRepositoryPayload
|
|
|
|
err := request.DecodeAndValidateJSONPayload(r, &payload)
|
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid request payload", err}
|
|
|
|
}
|
|
|
|
|
2020-05-20 05:23:15 +00:00
|
|
|
stacks, err := handler.DataStore.Stack().Stacks()
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve stacks from the database", err}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, stack := range stacks {
|
|
|
|
if strings.EqualFold(stack.Name, payload.Name) {
|
2020-07-07 21:57:52 +00:00
|
|
|
return &httperror.HandlerError{http.StatusConflict, "A stack with this name already exists", errStackAlreadyExists}
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-20 05:23:15 +00:00
|
|
|
stackID := handler.DataStore.Stack().GetNextIdentifier()
|
2018-06-11 13:13:19 +00:00
|
|
|
stack := &portainer.Stack{
|
2018-06-18 10:07:56 +00:00
|
|
|
ID: portainer.StackID(stackID),
|
2018-06-11 13:13:19 +00:00
|
|
|
Name: payload.Name,
|
|
|
|
Type: portainer.DockerComposeStack,
|
|
|
|
EndpointID: endpoint.ID,
|
|
|
|
EntryPoint: payload.ComposeFilePathInRepository,
|
2018-07-12 07:17:07 +00:00
|
|
|
Env: payload.Env,
|
2020-08-03 22:18:53 +00:00
|
|
|
Status: portainer.StackStatusActive,
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-25 11:48:28 +00:00
|
|
|
projectPath := handler.FileService.GetStackProjectPath(strconv.Itoa(int(stack.ID)))
|
2018-06-11 13:13:19 +00:00
|
|
|
stack.ProjectPath = projectPath
|
|
|
|
|
|
|
|
gitCloneParams := &cloneRepositoryParameters{
|
|
|
|
url: payload.RepositoryURL,
|
2018-07-24 14:11:35 +00:00
|
|
|
referenceName: payload.RepositoryReferenceName,
|
2018-06-11 13:13:19 +00:00
|
|
|
path: projectPath,
|
|
|
|
authentication: payload.RepositoryAuthentication,
|
|
|
|
username: payload.RepositoryUsername,
|
|
|
|
password: payload.RepositoryPassword,
|
|
|
|
}
|
2018-07-24 14:11:35 +00:00
|
|
|
|
|
|
|
doCleanUp := true
|
|
|
|
defer handler.cleanUp(stack, &doCleanUp)
|
|
|
|
|
2018-06-11 13:13:19 +00:00
|
|
|
err = handler.cloneGitRepository(gitCloneParams)
|
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to clone git repository", err}
|
|
|
|
}
|
|
|
|
|
|
|
|
config, configErr := handler.createComposeDeployConfig(r, stack, endpoint)
|
|
|
|
if configErr != nil {
|
|
|
|
return configErr
|
|
|
|
}
|
|
|
|
|
|
|
|
err = handler.deployComposeStack(config)
|
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, err.Error(), err}
|
|
|
|
}
|
|
|
|
|
2020-05-20 05:23:15 +00:00
|
|
|
err = handler.DataStore.Stack().CreateStack(stack)
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist the stack inside the database", err}
|
|
|
|
}
|
|
|
|
|
|
|
|
doCleanUp = false
|
2019-11-12 23:41:42 +00:00
|
|
|
return handler.decorateStackResponse(w, stack, userID)
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type composeStackFromFileUploadPayload struct {
|
|
|
|
Name string
|
|
|
|
StackFileContent []byte
|
2018-07-12 07:17:07 +00:00
|
|
|
Env []portainer.Pair
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (payload *composeStackFromFileUploadPayload) Validate(r *http.Request) error {
|
|
|
|
name, err := request.RetrieveMultiPartFormValue(r, "Name", false)
|
|
|
|
if err != nil {
|
2020-07-07 21:57:52 +00:00
|
|
|
return errors.New("Invalid stack name")
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
2019-11-24 01:28:07 +00:00
|
|
|
payload.Name = normalizeStackName(name)
|
2018-06-11 13:13:19 +00:00
|
|
|
|
2018-09-10 10:01:38 +00:00
|
|
|
composeFileContent, _, err := request.RetrieveMultiPartFormFile(r, "file")
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
2020-07-07 21:57:52 +00:00
|
|
|
return errors.New("Invalid Compose file. Ensure that the Compose file is uploaded correctly")
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
payload.StackFileContent = composeFileContent
|
|
|
|
|
2018-07-12 07:17:07 +00:00
|
|
|
var env []portainer.Pair
|
|
|
|
err = request.RetrieveMultiPartFormJSONValue(r, "Env", &env, true)
|
|
|
|
if err != nil {
|
2020-07-07 21:57:52 +00:00
|
|
|
return errors.New("Invalid Env parameter")
|
2018-07-12 07:17:07 +00:00
|
|
|
}
|
|
|
|
payload.Env = env
|
2018-06-11 13:13:19 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-11-12 23:41:42 +00:00
|
|
|
func (handler *Handler) createComposeStackFromFileUpload(w http.ResponseWriter, r *http.Request, endpoint *portainer.Endpoint, userID portainer.UserID) *httperror.HandlerError {
|
2018-06-11 13:13:19 +00:00
|
|
|
payload := &composeStackFromFileUploadPayload{}
|
|
|
|
err := payload.Validate(r)
|
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid request payload", err}
|
|
|
|
}
|
|
|
|
|
2020-05-20 05:23:15 +00:00
|
|
|
stacks, err := handler.DataStore.Stack().Stacks()
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve stacks from the database", err}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, stack := range stacks {
|
|
|
|
if strings.EqualFold(stack.Name, payload.Name) {
|
2020-07-07 21:57:52 +00:00
|
|
|
return &httperror.HandlerError{http.StatusConflict, "A stack with this name already exists", errStackAlreadyExists}
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-20 05:23:15 +00:00
|
|
|
stackID := handler.DataStore.Stack().GetNextIdentifier()
|
2018-06-11 13:13:19 +00:00
|
|
|
stack := &portainer.Stack{
|
2018-06-18 10:07:56 +00:00
|
|
|
ID: portainer.StackID(stackID),
|
2018-06-11 13:13:19 +00:00
|
|
|
Name: payload.Name,
|
|
|
|
Type: portainer.DockerComposeStack,
|
|
|
|
EndpointID: endpoint.ID,
|
|
|
|
EntryPoint: filesystem.ComposeFileDefaultName,
|
2018-07-12 07:17:07 +00:00
|
|
|
Env: payload.Env,
|
2020-08-03 22:18:53 +00:00
|
|
|
Status: portainer.StackStatusActive,
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
2018-06-20 17:55:00 +00:00
|
|
|
stackFolder := strconv.Itoa(int(stack.ID))
|
2019-10-07 03:12:21 +00:00
|
|
|
projectPath, err := handler.FileService.StoreStackFileFromBytes(stackFolder, stack.EntryPoint, payload.StackFileContent)
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist Compose file on disk", err}
|
|
|
|
}
|
|
|
|
stack.ProjectPath = projectPath
|
|
|
|
|
|
|
|
doCleanUp := true
|
|
|
|
defer handler.cleanUp(stack, &doCleanUp)
|
|
|
|
|
|
|
|
config, configErr := handler.createComposeDeployConfig(r, stack, endpoint)
|
|
|
|
if configErr != nil {
|
|
|
|
return configErr
|
|
|
|
}
|
|
|
|
|
|
|
|
err = handler.deployComposeStack(config)
|
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, err.Error(), err}
|
|
|
|
}
|
|
|
|
|
2020-05-20 05:23:15 +00:00
|
|
|
err = handler.DataStore.Stack().CreateStack(stack)
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist the stack inside the database", err}
|
|
|
|
}
|
|
|
|
|
|
|
|
doCleanUp = false
|
2019-11-12 23:41:42 +00:00
|
|
|
return handler.decorateStackResponse(w, stack, userID)
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type composeStackDeploymentConfig struct {
|
|
|
|
stack *portainer.Stack
|
|
|
|
endpoint *portainer.Endpoint
|
|
|
|
dockerhub *portainer.DockerHub
|
|
|
|
registries []portainer.Registry
|
2019-10-07 03:12:21 +00:00
|
|
|
isAdmin bool
|
2020-07-22 18:38:45 +00:00
|
|
|
user *portainer.User
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (handler *Handler) createComposeDeployConfig(r *http.Request, stack *portainer.Stack, endpoint *portainer.Endpoint) (*composeStackDeploymentConfig, *httperror.HandlerError) {
|
|
|
|
securityContext, err := security.RetrieveRestrictedRequestContext(r)
|
|
|
|
if err != nil {
|
|
|
|
return nil, &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve info from request context", err}
|
|
|
|
}
|
|
|
|
|
2020-05-20 05:23:15 +00:00
|
|
|
dockerhub, err := handler.DataStore.DockerHub().DockerHub()
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve DockerHub details from the database", err}
|
|
|
|
}
|
|
|
|
|
2020-05-20 05:23:15 +00:00
|
|
|
registries, err := handler.DataStore.Registry().Registries()
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve registries from the database", err}
|
|
|
|
}
|
|
|
|
filteredRegistries := security.FilterRegistries(registries, securityContext)
|
|
|
|
|
2020-07-22 18:38:45 +00:00
|
|
|
user, err := handler.DataStore.User().User(securityContext.UserID)
|
|
|
|
if err != nil {
|
|
|
|
return nil, &httperror.HandlerError{http.StatusInternalServerError, "Unable to load user information from the database", err}
|
|
|
|
}
|
|
|
|
|
2018-06-11 13:13:19 +00:00
|
|
|
config := &composeStackDeploymentConfig{
|
|
|
|
stack: stack,
|
|
|
|
endpoint: endpoint,
|
|
|
|
dockerhub: dockerhub,
|
|
|
|
registries: filteredRegistries,
|
2019-10-07 03:12:21 +00:00
|
|
|
isAdmin: securityContext.IsAdmin,
|
2020-07-22 18:38:45 +00:00
|
|
|
user: user,
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return config, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: libcompose uses credentials store into a config.json file to pull images from
|
|
|
|
// private registries. Right now the only solution is to re-use the embedded Docker binary
|
|
|
|
// to login/logout, which will generate the required data in the config.json file and then
|
|
|
|
// clean it. Hence the use of the mutex.
|
|
|
|
// We should contribute to libcompose to support authentication without using the config.json file.
|
|
|
|
func (handler *Handler) deployComposeStack(config *composeStackDeploymentConfig) error {
|
2020-05-20 05:23:15 +00:00
|
|
|
settings, err := handler.DataStore.Settings().Settings()
|
2019-10-07 03:12:21 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-07-22 18:38:45 +00:00
|
|
|
isAdminOrEndpointAdmin, err := handler.userIsAdminOrEndpointAdmin(config.user, config.endpoint.ID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-07-24 23:14:46 +00:00
|
|
|
if (!settings.AllowBindMountsForRegularUsers ||
|
|
|
|
!settings.AllowPrivilegedModeForRegularUsers ||
|
2020-07-26 21:31:14 +00:00
|
|
|
!settings.AllowHostNamespaceForRegularUsers ||
|
2020-07-28 07:08:15 +00:00
|
|
|
!settings.AllowDeviceMappingForRegularUsers ||
|
|
|
|
!settings.AllowContainerCapabilitiesForRegularUsers) &&
|
2020-07-24 23:14:46 +00:00
|
|
|
!isAdminOrEndpointAdmin {
|
|
|
|
|
2019-10-07 03:12:21 +00:00
|
|
|
composeFilePath := path.Join(config.stack.ProjectPath, config.stack.EntryPoint)
|
|
|
|
|
|
|
|
stackContent, err := handler.FileService.GetFileContent(composeFilePath)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-07-22 18:38:45 +00:00
|
|
|
err = handler.isValidStackFile(stackContent, settings)
|
2019-10-07 03:12:21 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-11 13:13:19 +00:00
|
|
|
handler.stackCreationMutex.Lock()
|
|
|
|
defer handler.stackCreationMutex.Unlock()
|
|
|
|
|
|
|
|
handler.SwarmStackManager.Login(config.dockerhub, config.registries, config.endpoint)
|
|
|
|
|
2019-10-07 03:12:21 +00:00
|
|
|
err = handler.ComposeStackManager.Up(config.stack, config.endpoint)
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return handler.SwarmStackManager.Logout(config.endpoint)
|
|
|
|
}
|