feat(swarm): port swarm to use libstack [BE-11476] (#2486)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user