1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 15:29:42 +02:00

fix(stack): pass registries to unpacker to start stack EE-4797 (#10095)

This commit is contained in:
cmeng 2023-08-24 13:01:49 +12:00 committed by GitHub
parent 1aae2e27f4
commit 7125ef81f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 27 deletions

View file

@ -141,12 +141,24 @@ func (handler *Handler) startStack(
endpoint *portainer.Endpoint,
securityContext *security.RestrictedRequestContext,
) error {
user, err := handler.DataStore.User().Read(securityContext.UserID)
if err != nil {
return fmt.Errorf("unable to load user information from the database: %w", err)
}
registries, err := handler.DataStore.Registry().ReadAll()
if err != nil {
return fmt.Errorf("unable to retrieve registries from the database: %w", err)
}
filteredRegistries := security.FilterRegistries(registries, user, securityContext.UserMemberships, endpoint.ID)
switch stack.Type {
case portainer.DockerComposeStack:
stack.Name = handler.ComposeStackManager.NormalizeStackName(stack.Name)
if stackutils.IsGitStack(stack) {
return handler.StackDeployer.StartRemoteComposeStack(stack, endpoint)
return handler.StackDeployer.StartRemoteComposeStack(stack, endpoint, filteredRegistries)
}
return handler.ComposeStackManager.Up(context.TODO(), stack, endpoint, false)
@ -154,21 +166,9 @@ func (handler *Handler) startStack(
stack.Name = handler.SwarmStackManager.NormalizeStackName(stack.Name)
if stackutils.IsGitStack(stack) {
return handler.StackDeployer.StartRemoteSwarmStack(stack, endpoint)
return handler.StackDeployer.StartRemoteSwarmStack(stack, endpoint, filteredRegistries)
}
user, err := handler.DataStore.User().Read(securityContext.UserID)
if err != nil {
return fmt.Errorf("unable to load user information from the database: %w", err)
}
registries, err := handler.DataStore.Registry().ReadAll()
if err != nil {
return fmt.Errorf("unable to retrieve registries from the database: %w", err)
}
filteredRegistries := security.FilterRegistries(registries, user, securityContext.UserMemberships, endpoint.ID)
return handler.StackDeployer.DeploySwarmStack(stack, endpoint, filteredRegistries, true, true)
}