Skip to content

Commit

Permalink
fix(relative-path): not deploy git stack via unpacker EE-6043 (#10194)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmenginnz committed Aug 28, 2023
1 parent adcfcdd commit 1e24451
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions api/http/handler/stacks/stack_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (handler *Handler) deleteStack(userID portainer.UserID, stack *portainer.St
if stack.Type == portainer.DockerSwarmStack {
stack.Name = handler.SwarmStackManager.NormalizeStackName(stack.Name)

if stackutils.IsGitStack(stack) {
if stackutils.IsRelativePathStack(stack) {
return handler.StackDeployer.UndeployRemoteSwarmStack(stack, endpoint)
}

Expand All @@ -200,7 +200,7 @@ func (handler *Handler) deleteStack(userID portainer.UserID, stack *portainer.St
if stack.Type == portainer.DockerComposeStack {
stack.Name = handler.ComposeStackManager.NormalizeStackName(stack.Name)

if stackutils.IsGitStack(stack) {
if stackutils.IsRelativePathStack(stack) {
return handler.StackDeployer.UndeployRemoteComposeStack(stack, endpoint)
}

Expand Down
4 changes: 2 additions & 2 deletions api/http/handler/stacks/stack_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ func (handler *Handler) startStack(
case portainer.DockerComposeStack:
stack.Name = handler.ComposeStackManager.NormalizeStackName(stack.Name)

if stackutils.IsGitStack(stack) {
if stackutils.IsRelativePathStack(stack) {
return handler.StackDeployer.StartRemoteComposeStack(stack, endpoint)
}

return handler.ComposeStackManager.Up(context.TODO(), stack, endpoint, false)
case portainer.DockerSwarmStack:
stack.Name = handler.SwarmStackManager.NormalizeStackName(stack.Name)

if stackutils.IsGitStack(stack) {
if stackutils.IsRelativePathStack(stack) {
return handler.StackDeployer.StartRemoteSwarmStack(stack, endpoint)
}

Expand Down
4 changes: 2 additions & 2 deletions api/http/handler/stacks/stack_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ func (handler *Handler) stopStack(stack *portainer.Stack, endpoint *portainer.En
case portainer.DockerComposeStack:
stack.Name = handler.ComposeStackManager.NormalizeStackName(stack.Name)

if stackutils.IsGitStack(stack) {
if stackutils.IsRelativePathStack(stack) {
return handler.StackDeployer.StopRemoteComposeStack(stack, endpoint)
}

return handler.ComposeStackManager.Down(context.TODO(), stack, endpoint)
case portainer.DockerSwarmStack:
stack.Name = handler.SwarmStackManager.NormalizeStackName(stack.Name)

if stackutils.IsGitStack(stack) {
if stackutils.IsRelativePathStack(stack) {
return handler.StackDeployer.StopRemoteSwarmStack(stack, endpoint)
}

Expand Down
4 changes: 2 additions & 2 deletions api/stacks/deployments/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func RedeployWhenChanged(stackID portainer.StackID, deployer StackDeployer, data
switch stack.Type {
case portainer.DockerComposeStack:

if stackutils.IsGitStack(stack) {
if stackutils.IsRelativePathStack(stack) {
err = deployer.DeployRemoteComposeStack(stack, endpoint, registries, true, false)
} else {
err = deployer.DeployComposeStack(stack, endpoint, registries, true, false)
Expand All @@ -95,7 +95,7 @@ func RedeployWhenChanged(stackID portainer.StackID, deployer StackDeployer, data
return errors.WithMessagef(err, "failed to deploy a docker compose stack %v", stackID)
}
case portainer.DockerSwarmStack:
if stackutils.IsGitStack(stack) {
if stackutils.IsRelativePathStack(stack) {
err = deployer.DeployRemoteSwarmStack(stack, endpoint, registries, true, true)
} else {
err = deployer.DeploySwarmStack(stack, endpoint, registries, true, true)
Expand Down
2 changes: 1 addition & 1 deletion api/stacks/deployments/deployment_compose_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (config *ComposeStackDeploymentConfig) Deploy() error {
return err
}
}
if stackutils.IsGitStack(config.stack) {
if stackutils.IsRelativePathStack(config.stack) {
return config.StackDeployer.DeployRemoteComposeStack(config.stack, config.endpoint, config.registries, config.forcePullImage, config.ForceCreate)
}

Expand Down
2 changes: 1 addition & 1 deletion api/stacks/deployments/deployment_swarm_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (config *SwarmStackDeploymentConfig) Deploy() error {
}
}

if stackutils.IsGitStack(config.stack) {
if stackutils.IsRelativePathStack(config.stack) {
return config.StackDeployer.DeployRemoteSwarmStack(config.stack, config.endpoint, config.registries, config.prune, config.pullImage)
}

Expand Down
7 changes: 7 additions & 0 deletions api/stacks/stackutils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ func SanitizeLabel(value string) string {
func IsGitStack(stack *portainer.Stack) bool {
return stack.GitConfig != nil && len(stack.GitConfig.URL) != 0
}

// IsRelativePathStack checks if the stack is a git stack or not
func IsRelativePathStack(stack *portainer.Stack) bool {
// Always return false in CE
// This function is only for code consistency with EE
return false
}

0 comments on commit 1e24451

Please sign in to comment.