feat(swarm): port swarm to use libstack [BE-11476] (#2486)

This commit is contained in:
Devon Steenberg
2026-05-14 10:13:19 +12:00
committed by GitHub
parent a66f114f24
commit 3b0f1eca4b
23 changed files with 2071 additions and 755 deletions
+11 -9
View File
@@ -1390,7 +1390,7 @@ func Test_CredentialsStore_Behavior(t *testing.T) {
"auths": {}
}`
configPath := filesystem.JoinPaths(tmpDir, "config.json")
err := os.WriteFile(configPath, []byte(configJSON), 0644)
err := os.WriteFile(configPath, []byte(configJSON), 0o644)
require.NoError(t, err)
t.Run("withCli preserves credsStore when no registries provided", func(t *testing.T) {
@@ -1400,8 +1400,8 @@ func Test_CredentialsStore_Behavior(t *testing.T) {
var capturedCredsStore string
var capturedAuthConfigs map[string]configtypes.AuthConfig
err = withCli(t.Context(), libstack.Options{}, func(ctx context.Context, cli *command.DockerCli) error {
// Capture the state after withCli sets up credentials
err = libstack.WithCli(t.Context(), libstack.DockerCliOptions{}, func(ctx context.Context, cli *command.DockerCli) error {
// Capture the state after WithCli sets up credentials
capturedCredsStore = cli.ConfigFile().CredentialsStore
capturedAuthConfigs = cli.ConfigFile().AuthConfigs
return nil
@@ -1432,12 +1432,14 @@ func Test_CredentialsStore_Behavior(t *testing.T) {
var capturedCredsStore string
var capturedAuthConfigs map[string]configtypes.AuthConfig
err = withCli(t.Context(), libstack.Options{Registries: registries}, func(ctx context.Context, cli *command.DockerCli) error {
// Capture the state after withCli sets up credentials
capturedCredsStore = cli.ConfigFile().CredentialsStore
capturedAuthConfigs = cli.ConfigFile().AuthConfigs
return nil
})
err = libstack.WithCli(t.Context(),
libstack.DockerCliOptions{Registries: registries},
func(ctx context.Context, cli *command.DockerCli) error {
// Capture the state after WithCli sets up credentials
capturedCredsStore = cli.ConfigFile().CredentialsStore
capturedAuthConfigs = cli.ConfigFile().AuthConfigs
return nil
})
require.NoError(t, err)
// Verify the fix: credsStore should be empty when registries are provided