Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add registry prefix option #477

Merged
merged 1 commit into from
Jul 2, 2019
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
1 change: 1 addition & 0 deletions cmd/critest/cri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func TestCRISuite(t *testing.T) {

if *isBenchMark {
flag.Set("ginkgo.focus", "benchmark")
flag.Set("ginkgo.succinct", "true")
} else {
// Skip benchmark measurements for validation tests.
flag.Set("ginkgo.skipMeasurements", "true")
Expand Down
6 changes: 6 additions & 0 deletions pkg/framework/test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ type TestContextType struct {

// Test configuration.
IsLcow bool

RegistryPrefix string
}

// TestContext is a test context.
var TestContext TestContextType

// DefaultRegistryPrefix specifies the default prefix used for images
const DefaultRegistryPrefix = "docker.io/library"

// RegisterFlags registers flags to e2e test suites.
func RegisterFlags() {
// Turn on verbose by default to get spec names
Expand Down Expand Up @@ -77,4 +82,5 @@ func RegisterFlags() {
} else {
TestContext.IsLcow = false
}
flag.StringVar(&TestContext.RegistryPrefix, "registry-prefix", DefaultRegistryPrefix, "A possible registry prefix added to all images, like 'localhost:5000/'")
}
24 changes: 21 additions & 3 deletions pkg/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"sync"
"time"

"github.com/docker/distribution/reference"
"github.com/pborman/uuid"
internalapi "k8s.io/kubernetes/pkg/kubelet/apis/cri"
runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
Expand Down Expand Up @@ -297,9 +298,26 @@ func ListImage(c internalapi.ImageManagerService, filter *runtimeapi.ImageFilter

// PullPublicImage pulls the public image named imageName.
func PullPublicImage(c internalapi.ImageManagerService, imageName string, podConfig *runtimeapi.PodSandboxConfig) string {
if !strings.Contains(imageName, ":") {
imageName = imageName + ":latest"
Logf("Use latest as default image tag.")

ref, err := reference.ParseNamed(imageName)
saschagrunert marked this conversation as resolved.
Show resolved Hide resolved
if err == nil {
// Modify the image if it's a fully qualified image name
if TestContext.RegistryPrefix != DefaultRegistryPrefix {
r := fmt.Sprintf("%s/%s", TestContext.RegistryPrefix, reference.Path(ref))
ref, err = reference.ParseNamed(r)
ExpectNoError(err, "failed to parse new image name: %v", err)
}
imageName = ref.String()

if !strings.Contains(imageName, ":") {
imageName = imageName + ":latest"
Logf("Use latest as default image tag.")
}
} else if err == reference.ErrNameNotCanonical {
// Non canonical images can simply be prefixed
imageName = fmt.Sprintf("%s/%s", TestContext.RegistryPrefix, imageName)
} else {
Failf("Unable to parse imageName: %v", err)
}

By("Pull image : " + imageName)
Expand Down
1 change: 1 addition & 0 deletions vendor.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109
github.com/docker/docker a9fbbdc8dd8794b20af358382ab780559bca589d
github.com/docker/distribution v2.7.1
github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1
github.com/docker/spdystream 449fdfce4d962303d702fec724ef0ad181c92528
github.com/fsnotify/fsnotify f12c6236fe7b5cf6bcf30e5935d08cb079d78334
Expand Down
202 changes: 202 additions & 0 deletions vendor/github.com/docker/distribution/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading