-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
Copy pathpullsecret.go
99 lines (87 loc) · 3.71 KB
/
pullsecret.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package builds
import (
"context"
"fmt"
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
exutil "github.com/openshift/origin/test/extended/util"
)
var _ = g.Describe("[sig-builds][Feature:Builds][Slow] using pull secrets in a build", func() {
defer g.GinkgoRecover()
var (
exampleBuild = exutil.FixturePath("testdata", "builds", "test-docker-app")
linkedBuild = exutil.FixturePath("testdata", "builds", "pullsecret", "linked-nodejs-bc.yaml")
pullSecretBuild = exutil.FixturePath("testdata", "builds", "pullsecret", "pullsecret-nodejs-bc.yaml")
oc = exutil.NewCLI("cli-pullsecret-build")
)
g.Context("", func() {
g.BeforeEach(func() {
exutil.PreTestDump()
})
g.Context("start-build test context", func() {
g.AfterEach(func() {
if g.CurrentSpecReport().Failed() {
exutil.DumpPodStates(oc)
exutil.DumpPodLogsStartingWith("", oc)
}
})
g.Describe("binary builds", func() {
g.It("should be able to run a build that is implicitly pulling from the internal registry [apigroup:build.openshift.io]", func() {
g.By("creating a build")
err := oc.Run("new-build").Args("--binary", "--strategy=docker", "--name=docker").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
br, err := exutil.StartBuildAndWait(oc, "docker", fmt.Sprintf("--from-dir=%s", exampleBuild))
br.AssertSuccess()
})
})
// Test pulling from registry.redhat.io - an authenticated registry
// CI clusters should have a pull secret to this registry in order for the samples operator to work
// Note that this registry is known to be flaky
g.Describe("pulling from an external authenticated registry", func() {
g.BeforeEach(func() {
g.By("copying the cluster pull secret to the namespace")
ps, err := oc.AsAdmin().AdminKubeClient().CoreV1().Secrets("openshift-config").Get(context.Background(), "pull-secret", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
localPullSecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "local-ps",
},
Data: ps.Data,
Type: ps.Type,
}
_, err = oc.KubeClient().CoreV1().Secrets(oc.Namespace()).Create(context.Background(), localPullSecret, metav1.CreateOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
})
g.AfterEach(func() {
g.By("unlinking the cluster pull secret in the namespace")
oc.Run("secrets").Args("unlink", "builder", "local-ps").Execute()
g.By("deleting the cluster pull secret in the namespace")
oc.Run("delete").Args("secret", "local-ps").Execute()
})
g.It("should be able to use a pull secret in a build [apigroup:build.openshift.io]", func() {
g.By("creating build config")
err := oc.Run("create").Args("-f", pullSecretBuild).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("starting build with a pull secret")
br, err := exutil.StartBuildAndWait(oc, "pullsecret-nodejs", "--build-loglevel=6")
o.Expect(err).NotTo(o.HaveOccurred())
br.AssertSuccess()
})
g.It("should be able to use a pull secret linked to the builder service account [apigroup:build.openshift.io]", func() {
g.By("linking pull secret with the builder service account")
err := oc.Run("secrets").Args("link", "builder", "local-ps").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("creating build config")
err = oc.Run("create").Args("-f", linkedBuild).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("starting a build")
br, err := exutil.StartBuildAndWait(oc, "linked-nodejs", "--build-loglevel=6")
o.Expect(err).NotTo(o.HaveOccurred())
br.AssertSuccess()
})
})
})
})
})