Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions envbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"io"
"io/fs"
"maps"
"net"
"net/http"
Expand Down Expand Up @@ -604,9 +605,14 @@ func Run(ctx context.Context, options Options) error {

// Remove the Docker config secret file!
if options.DockerConfigBase64 != "" {
err = os.Remove(filepath.Join(MagicDir, "config.json"))
if err != nil && !os.IsNotExist(err) {
return fmt.Errorf("remove docker config: %w", err)
c := filepath.Join(MagicDir, "config.json")
err = os.Remove(c)
if err != nil {
if !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("remove docker config: %w", err)
} else {
fmt.Fprintln(os.Stderr, "failed to remove the Docker config secret file: %w", c)
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,16 @@ func TestBuildFromDockerfile(t *testing.T) {
ctr, err := runEnvbuilder(t, options{env: []string{
"GIT_URL=" + srv.URL,
"DOCKERFILE_PATH=Dockerfile",
"DOCKER_CONFIG_BASE64=" + base64.StdEncoding.EncodeToString([]byte(`{"experimental": "enabled"}`)),
}})
require.NoError(t, err)

output := execContainer(t, ctr, "echo hello")
require.Equal(t, "hello", strings.TrimSpace(output))

// Verify that the Docker configuration secret file is removed
output = execContainer(t, ctr, "stat "+filepath.Join(envbuilder.MagicDir, "config.json"))
require.Contains(t, output, "No such file or directory")
}

func TestBuildPrintBuildOutput(t *testing.T) {
Expand Down