Skip to content

Commit

Permalink
dont fail if there is no docker config file, wait for the request to …
Browse files Browse the repository at this point in the history
…fail

Signed-off-by: razzle <[email protected]>
  • Loading branch information
Noxsios committed Jul 8, 2023
1 parent de2ac50 commit dc30300
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/pkg/oci/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package oci

import (
"context"
"errors"
"fmt"
"net/http"
"strings"
Expand Down Expand Up @@ -113,7 +112,8 @@ func (o *OrasRemote) withAuthClient(ref registry.Reference) (*auth.Client, error
return nil, err
}
if !cfg.ContainsAuth() {
return nil, errors.New("no docker config file found, run 'zarf tools registry login --help'")
message.Debug("no docker config file found, run 'zarf tools registry login --help'")
return nil, nil
}

configs := []*configfile.ConfigFile{cfg}
Expand Down
15 changes: 1 addition & 14 deletions src/test/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (

"github.com/defenseunicorns/zarf/src/pkg/utils/exec"
"github.com/defenseunicorns/zarf/src/pkg/utils/helpers"
dconfig "github.com/docker/cli/cli/config"
"github.com/docker/cli/cli/config/configfile"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -101,22 +99,11 @@ func (e2e *ZarfE2ETest) GetLogFileContents(t *testing.T, stdErr string) string {
}

// SetupDockerRegistry uses the host machine's docker daemon to spin up a local registry for testing purposes.
func (e2e *ZarfE2ETest) SetupDockerRegistry(t *testing.T, port int) *configfile.ConfigFile {
func (e2e *ZarfE2ETest) SetupDockerRegistry(t *testing.T, port int) {
// spin up a local registry
registryImage := "registry:2.8.2"
err := exec.CmdWithPrint("docker", "run", "-d", "--restart=always", "-p", fmt.Sprintf("%d:5000", port), "--name", "registry", registryImage)
require.NoError(t, err)

// docker config folder
cfg, err := dconfig.Load(dconfig.Dir())
require.NoError(t, err)
if !cfg.ContainsAuth() {
// make a docker config file w/ some blank creds
_, _, err := e2e.Zarf("tools", "registry", "login", "--username", "zarf", "-p", "zarf", "localhost:6000")
require.NoError(t, err)
}

return cfg
}

// GetZarfVersion returns the current build/zarf version
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/52_oci_compose_differential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (suite *OCIDifferentialSuite) SetupSuite() {
differentialPackageName = fmt.Sprintf("zarf-package-podinfo-with-oci-flux-%s-v0.24.0-differential-v0.25.0.tar.zst", e2e.Arch)
normalPackageName = fmt.Sprintf("zarf-package-podinfo-with-oci-flux-%s-v0.24.0.tar.zst", e2e.Arch)

_ = e2e.SetupDockerRegistry(suite.T(), 555)
e2e.SetupDockerRegistry(suite.T(), 555)
suite.Reference.Registry = "localhost:555"
}

Expand Down

0 comments on commit dc30300

Please sign in to comment.