Replace the boolean for schema1 registry with an enum

We will add one more registry.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač
2026-03-10 18:43:39 +01:00
parent fcc3aa683b
commit 726479d948
4 changed files with 23 additions and 15 deletions

View File

@@ -35,8 +35,8 @@ func (s *skopeoSuite) SetupSuite() {
t := s.T()
_, err := exec.LookPath(skopeoBinary)
require.NoError(t, err)
s.regV2 = setupRegistryV2At(t, privateRegistryURL0, false, false)
s.regV2WithAuth = setupRegistryV2At(t, privateRegistryURL1, true, false)
s.regV2 = setupRegistryV2At(t, privateRegistryURL0, false, registryVersionModern)
s.regV2WithAuth = setupRegistryV2At(t, privateRegistryURL1, true, registryVersionModern)
}
func (s *skopeoSuite) TearDownSuite() {

View File

@@ -76,8 +76,8 @@ func (s *copySuite) SetupSuite() {
}
// FIXME: Set up TLS for the docker registry port instead of using "--tls-verify=false" all over the place.
s.registry = setupRegistryV2At(t, v2DockerRegistryURL, false, false)
s.s1Registry = setupRegistryV2At(t, v2s1DockerRegistryURL, false, true)
s.registry = setupRegistryV2At(t, v2DockerRegistryURL, false, registryVersionModern)
s.s1Registry = setupRegistryV2At(t, v2s1DockerRegistryURL, false, registryVersionSchema1Only)
s.gpgHome = t.TempDir()
t.Setenv("GNUPGHOME", s.gpgHome)

View File

@@ -17,6 +17,14 @@ const (
binaryV2Schema1 = "registry-v2-schema1"
)
type registryVersion int
const (
registryVersionInvalid registryVersion = iota
registryVersionModern
registryVersionSchema1Only
)
type testRegistryV2 struct {
cmd *exec.Cmd
url string
@@ -25,8 +33,8 @@ type testRegistryV2 struct {
email string
}
func setupRegistryV2At(t *testing.T, url string, auth, schema1 bool) *testRegistryV2 {
reg, err := newTestRegistryV2At(t, url, auth, schema1)
func setupRegistryV2At(t *testing.T, url string, auth bool, version registryVersion) *testRegistryV2 {
reg, err := newTestRegistryV2At(t, url, auth, version)
require.NoError(t, err)
// Wait for registry to be ready to serve requests.
@@ -43,7 +51,7 @@ func setupRegistryV2At(t *testing.T, url string, auth, schema1 bool) *testRegist
return reg
}
func newTestRegistryV2At(t *testing.T, url string, auth, schema1 bool) (*testRegistryV2, error) {
func newTestRegistryV2At(t *testing.T, url string, auth bool, version registryVersion) (*testRegistryV2, error) {
tmp := t.TempDir()
template := `version: 0.1
loglevel: debug
@@ -89,10 +97,13 @@ compatibility:
}
var cmd *exec.Cmd
if schema1 {
cmd = exec.Command(binaryV2Schema1, confPath)
} else {
switch version {
case registryVersionModern:
cmd = exec.Command(binaryV2, "serve", confPath)
case registryVersionSchema1Only:
cmd = exec.Command(binaryV2Schema1, confPath)
default:
return nil, fmt.Errorf("invalid registry version: %v", version)
}
consumeAndLogOutputs(t, fmt.Sprintf("registry-%s", url), cmd)

View File

@@ -54,12 +54,9 @@ var (
func (s *syncSuite) SetupSuite() {
t := s.T()
const registryAuth = false
const registrySchema1 = false
if os.Getenv("SKOPEO_LOCAL_TESTS") == "1" {
t.Log("Running tests without a container")
fmt.Printf("NOTE: tests requires a V2 registry at url=%s, with auth=%t, schema1=%t \n", v2DockerRegistryURL, registryAuth, registrySchema1)
fmt.Printf("NOTE: tests requires a V2 registry at url=%s\n", v2DockerRegistryURL)
return
}
@@ -82,7 +79,7 @@ func (s *syncSuite) SetupSuite() {
}
// FIXME: Set up TLS for the docker registry port instead of using "--tls-verify=false" all over the place.
s.registry = setupRegistryV2At(t, v2DockerRegistryURL, registryAuth, registrySchema1)
s.registry = setupRegistryV2At(t, v2DockerRegistryURL, false, registryVersionModern)
gpgHome := t.TempDir()
t.Setenv("GNUPGHOME", gpgHome)