Skip to content

Commit f3f7738

Browse files
Make correct CLI image available for tests and check in e2e
1 parent 247301f commit f3f7738

File tree

10 files changed

+57
-11
lines changed

10 files changed

+57
-11
lines changed

images/cli/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ RUN INSTALL_PKGS="origin-clients" && \
1010
yum --enablerepo=origin-local-release install -y ${INSTALL_PKGS} && \
1111
rpm -V ${INSTALL_PKGS} && \
1212
yum clean all
13+
COPY manifests /manifests
1314

1415
LABEL io.k8s.display-name="OpenShift Client" \
1516
io.k8s.description="OpenShift is a platform for developing, building, and deploying containerized applications." \
16-
io.openshift.tags="openshift,cli"
17+
io.openshift.tags="openshift,cli" \
18+
io.openshift.release.operator="true"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
kind: ImageStream
2+
apiVersion: image.openshift.io/v1
3+
metadata:
4+
namespace: openshift
5+
name: cli
6+
spec:
7+
tags:
8+
- name: latest
9+
from:
10+
kind: DockerImage
11+
name: docker.io/openshift/origin-cli:v4.0

images/cli/manifests/image-references

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
kind: ImageStream
2+
apiVersion: image.openshift.io/v1
3+
spec:
4+
tags:
5+
- name: cli
6+
from:
7+
kind: DockerImage
8+
name: docker.io/openshift/origin-cli:v4.0

test/extended/images/append.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ func cliPodWithPullSecret(cli *exutil.CLI, shell string) *kapiv1.Pod {
2222
o.Expect(sa.ImagePullSecrets).NotTo(o.BeEmpty())
2323
pullSecretName := sa.ImagePullSecrets[0].Name
2424

25-
format, _ := exutil.FindImageFormatString(cli)
26-
cliImage := strings.Replace(format, "${component}", "cli", -1)
25+
cliImage, _ := exutil.FindCLIImage(cli)
2726

2827
return &kapiv1.Pod{
2928
ObjectMeta: metav1.ObjectMeta{

test/extended/router/config_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() {
4343
g.BeforeEach(func() {
4444
ns = oc.Namespace()
4545

46-
routerImage, _ := exutil.FindImageFormatString(oc)
46+
routerImage, _ := exutil.FindRouterImage(oc)
4747
routerImage = strings.Replace(routerImage, "${component}", "haproxy-router", -1)
4848

4949
err := oc.AsAdmin().Run("new-app").Args("-f", configPath, "-p", "IMAGE="+routerImage).Execute()

test/extended/router/scoped.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() {
5050
g.BeforeEach(func() {
5151
ns = oc.Namespace()
5252

53-
routerImage, _ = exutil.FindImageFormatString(oc)
53+
routerImage, _ = exutil.FindRouterImage(oc)
5454
routerImage = strings.Replace(routerImage, "${component}", "haproxy-router", -1)
5555

5656
configPath := exutil.FixturePath("testdata", "router-common.yaml")

test/extended/router/stress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() {
5050
g.BeforeEach(func() {
5151
ns = oc.Namespace()
5252

53-
routerImage, _ = exutil.FindImageFormatString(oc)
53+
routerImage, _ = exutil.FindRouterImage(oc)
5454
routerImage = strings.Replace(routerImage, "${component}", "haproxy-router", -1)
5555

5656
_, err := oc.AdminKubeClient().Rbac().RoleBindings(ns).Create(&rbacv1.RoleBinding{

test/extended/router/unprivileged.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() {
4141
g.BeforeEach(func() {
4242
ns = oc.Namespace()
4343

44-
routerImage, _ = exutil.FindImageFormatString(oc)
44+
routerImage, _ = exutil.FindRouterImage(oc)
4545
routerImage = strings.Replace(routerImage, "${component}", "haproxy-router", -1)
4646

4747
configPath := exutil.FixturePath("testdata", "router-common.yaml")

test/extended/router/weighted.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() {
2626
)
2727

2828
g.BeforeEach(func() {
29-
routerImage, _ := exutil.FindImageFormatString(oc)
29+
routerImage, _ := exutil.FindRouterImage(oc)
3030
routerImage = strings.Replace(routerImage, "${component}", "haproxy-router", -1)
3131
err := oc.AsAdmin().Run("new-app").Args("-f", configPath, "-p", "IMAGE="+routerImage).Execute()
3232
o.Expect(err).NotTo(o.HaveOccurred())

test/extended/util/framework.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,12 +1481,38 @@ func GetRouterPodTemplate(oc *CLI) (*corev1.PodTemplateSpec, string, error) {
14811481
return nil, "", errors.NewNotFound(schema.GroupResource{Group: "apps.openshift.io", Resource: "deploymentconfigs"}, "router")
14821482
}
14831483

1484+
// FindImageFormatString returns a format string for components on the cluster. It returns false
1485+
// if no format string could be inferred from the cluster. OpenShift 4.0 clusters will not be able
1486+
// to infer an image format string, so you must wrap this method in one that can locate your specific
1487+
// image.
14841488
func FindImageFormatString(oc *CLI) (string, bool) {
1485-
// the router is expected to be on all clusters
1486-
// TODO: switch this to read from the global config
1489+
// legacy support for 3.x clusters
14871490
template, _, err := GetRouterPodTemplate(oc)
14881491
if err == nil {
1489-
return strings.Replace(template.Spec.Containers[0].Image, "haproxy-router", "${component}", -1), true
1492+
if strings.Contains(template.Spec.Containers[0].Image, "haproxy-router") {
1493+
return strings.Replace(template.Spec.Containers[0].Image, "haproxy-router", "${component}", -1), true
1494+
}
14901495
}
1496+
// in openshift 4.0, no image format can be calculated on cluster
14911497
return "openshift/origin-${component}:latest", false
14921498
}
1499+
1500+
func FindCLIImage(oc *CLI) (string, bool) {
1501+
// look up image stream
1502+
is, err := oc.AdminImageClient().ImageV1().ImageStreams("openshift").Get("cli", metav1.GetOptions{})
1503+
if err == nil {
1504+
for _, tag := range is.Spec.Tags {
1505+
if tag.Name == "latest" && tag.From != nil && tag.From.Kind == "DockerImage" {
1506+
return tag.From.Name, true
1507+
}
1508+
}
1509+
}
1510+
1511+
format, ok := FindImageFormatString(oc)
1512+
return strings.Replace(format, "${component}", "cli", -1), ok
1513+
}
1514+
1515+
func FindRouterImage(oc *CLI) (string, bool) {
1516+
format, ok := FindImageFormatString(oc)
1517+
return strings.Replace(format, "${component}", "haproxy-router", -1), ok
1518+
}

0 commit comments

Comments
 (0)