feat: Retrieves auth token from image #585
@ -17,6 +17,7 @@ import (
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"coopcloud.tech/abra/pkg/ui"
|
||||
"coopcloud.tech/abra/pkg/upstream/convert"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/stack/formatter"
|
||||
composetypes "github.com/docker/cli/cli/compose/types"
|
||||
"github.com/docker/docker/api/types"
|
||||
@ -426,7 +427,8 @@ func deployServices(
|
||||
services map[string]swarm.ServiceSpec,
|
||||
namespace convert.Namespace,
|
||||
sendAuth bool,
|
||||
resolveImage string) ([]ui.ServiceMeta, error) {
|
||||
resolveImage string,
|
||||
) ([]ui.ServiceMeta, error) {
|
||||
var servicesMeta []ui.ServiceMeta
|
||||
|
||||
existingServices, err := GetStackServices(ctx, cl, namespace.Name())
|
||||
@ -446,6 +448,21 @@ func deployServices(
|
||||
encodedAuth string
|
||||
)
|
||||
|
||||
// When sendAuth is set, use the docker cli to retrieve the auth token
|
||||
// for the image we are deploying.
|
||||
// This enables using a private registry by running docker login on the
|
||||
// machine, that abra is executed.
|
||||
if sendAuth {
|
||||
dockerCLI, err := command.NewDockerCli()
|
||||
if err != nil {
|
||||
log.Errorf("retrieving docker auth token: failed create docker cli: %s", err)
|
||||
|
decentral1se marked this conversation as resolved
Outdated
|
||||
}
|
||||
encodedAuth, err = command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), image)
|
||||
if err != nil {
|
||||
log.Errorf("failed to retrieve registry auth for image %s: %s", image, err)
|
||||
}
|
||||
}
|
||||
|
||||
if service, exists := existingServiceMap[name]; exists {
|
||||
log.Debugf("updating %s", name)
|
||||
|
||||
@ -587,7 +604,7 @@ func WaitOnServices(ctx context.Context, cl *dockerClient.Client, opts WaitOpts)
|
||||
fmt.Sprintf("%s_%s", opts.AppName, timestamp()),
|
||||
)
|
||||
|
||||
if err := os.MkdirAll(filepath.Join(config.LOGS_DIR, opts.ServerName), 0764); err != nil {
|
||||
if err := os.MkdirAll(filepath.Join(config.LOGS_DIR, opts.ServerName), 0o764); err != nil {
|
||||
|
decentral1se marked this conversation as resolved
Outdated
decentral1se
commented
This seems unrelated, are you sure this won't break things? This seems unrelated, are you sure this won't break things?
p4u1
commented
this is a change by the formatter, and is semantically the same this is a change by the formatter, and is semantically the same
|
||||
return fmt.Errorf("waitOnServices: error creating log dir: %s", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user
An error like this will be very confusing without context, maybe we need to add more? E.g.
log.Errorf("retrieving docker auth token: failed create docker cli: %s", err)I updated the error message