Skip to content

Commit

Permalink
add local config.json to test configuration dir if exists
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Lours <[email protected]>
  • Loading branch information
glours committed Dec 4, 2024
1 parent 25197fe commit e4222bf
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func NewCLI(t testing.TB, opts ...CLIOption) *CLI {
t.Helper()

configDir := t.TempDir()
copyLocalConfig(t, configDir)
initializePlugins(t, configDir)
initializeContextDir(t, configDir)

Expand All @@ -117,10 +118,21 @@ func WithEnv(env ...string) CLIOption {
}
}

func copyLocalConfig(t testing.TB, configDir string) {
t.Helper()

// copy local config.json if exists
localConfig := filepath.Join(os.Getenv("HOME"), ".docker", "config.json")
// if no config present just continue
if _, err := os.Stat(localConfig); err != nil {
// copy the local config.json to the test config dir
CopyFile(t, localConfig, filepath.Join(configDir, "config.json"))
}
}

// initializePlugins copies the necessary plugin files to the temporary config
// directory for the test.
func initializePlugins(t testing.TB, configDir string) {
t.Helper()

t.Cleanup(func() {
if t.Failed() {
Expand Down

0 comments on commit e4222bf

Please sign in to comment.