From 23d17945683e64e3e09ee19e98bbc8ed546c27df Mon Sep 17 00:00:00 2001 From: Chris Bruce Date: Tue, 23 Apr 2024 11:20:18 -0700 Subject: [PATCH] Allow repotest OCI server to bind to localhost Signed-off-by: Chris Bruce --- pkg/repo/repotest/server.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/repo/repotest/server.go b/pkg/repo/repotest/server.go index 4a86707cf..8ef54e7d2 100644 --- a/pkg/repo/repotest/server.go +++ b/pkg/repo/repotest/server.go @@ -93,6 +93,10 @@ func WithDependingChart(c *chart.Chart) OCIServerOpt { } func NewOCIServer(t *testing.T, dir string) (*OCIServer, error) { + return NewOCIServerWithBindAddress(t, dir, "") +} + +func NewOCIServerWithBindAddress(t *testing.T, dir string, bindAddress string) (*OCIServer, error) { testHtpasswdFileBasename := "authtest.htpasswd" testUsername, testPassword := "username", "password" @@ -113,7 +117,7 @@ func NewOCIServer(t *testing.T, dir string) (*OCIServer, error) { t.Fatalf("error finding free port for test registry") } - config.HTTP.Addr = fmt.Sprintf(":%d", port) + config.HTTP.Addr = fmt.Sprintf("%s:%d", bindAddress, port) config.HTTP.DrainTimeout = time.Duration(10) * time.Second config.Storage = map[string]configuration.Parameters{"inmemory": map[string]interface{}{}} config.Auth = configuration.Auth{