Exemple #1
0
func jenkinsJobBytes(filename, namespace string) []byte {
	pre := exutil.FixturePath("fixtures", filename)
	post := exutil.ArtifactPath(filename)
	err := exutil.VarSubOnFile(pre, post, "PROJECT_NAME", namespace)
	o.Expect(err).NotTo(o.HaveOccurred())
	data, err := ioutil.ReadFile(post)
	o.Expect(err).NotTo(o.HaveOccurred())
	return data
}
Exemple #2
0
// Returns the content of a Jenkins job XML file. Instances of the
// string "PROJECT_NAME" are replaced with the specified namespace.
func (j *JenkinsRef) readJenkinsJob(filename, namespace string) string {
	pre := exutil.FixturePath("testdata", "jenkins-plugin", filename)
	post := exutil.ArtifactPath(filename)
	err := exutil.VarSubOnFile(pre, post, "PROJECT_NAME", namespace)
	o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())
	data, err := ioutil.ReadFile(post)
	o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())
	return string(data)
}
Exemple #3
0
// ReadJenkinsJobUsingVars returns the content of a Jenkins job XML file. Instances of the
// string "PROJECT_NAME" are replaced with the specified namespace.
// Variables named in the vars map will also be replaced with their
// corresponding value.
func (j *JenkinsRef) ReadJenkinsJobUsingVars(filename, namespace string, vars map[string]string) string {
	pre := exutil.FixturePath("testdata", "jenkins-plugin", filename)
	post := exutil.ArtifactPath(filename)

	if vars == nil {
		vars = map[string]string{}
	}
	vars["PROJECT_NAME"] = namespace
	err := exutil.VarSubOnFile(pre, post, vars)
	o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())

	data, err := ioutil.ReadFile(post)
	o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())
	return string(data)
}
Exemple #4
0
		// and then create the build config resources
		pre := exutil.FixturePath("testdata", "forcepull-test.json")
		post := exutil.ArtifactPath("forcepull-test.json")
		varSubDest = authCfg.ServerAddress + "/" + oc.Namespace()

		// grant access to the custom build strategy
		g.By("granting system:build-strategy-custom")
		err = oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "system:build-strategy-custom", oc.Username()).Execute()
		o.Expect(err).NotTo(o.HaveOccurred())

		defer func() {
			err = oc.AsAdmin().Run("adm").Args("policy", "remove-cluster-role-from-user", "system:build-strategy-custom", oc.Username()).Execute()
			o.Expect(err).NotTo(o.HaveOccurred())
		}()

		err = exutil.VarSubOnFile(pre, post, varSubSrc, varSubDest)
		o.Expect(err).NotTo(o.HaveOccurred())
		err = exutil.CreateResource(post, oc)
		o.Expect(err).NotTo(o.HaveOccurred())

		// dump the image textual tags and hex ids out for debug
		tags = []string{fullImageName + ":latest", corruptor + ":latest"}
		hexIDs, err := exutil.DumpAndReturnTagging(tags)
		o.Expect(err).NotTo(o.HaveOccurred())
		resetData = map[string]string{fullImageName: hexIDs[0], corruptor: hexIDs[1]}

	})

	g.Context("ForcePull test context  ", func() {

		g.JustBeforeEach(func() {
Exemple #5
0
		// and then create the build config resources
		pre := exutil.FixturePath("testdata", "forcepull-test.json")
		post := exutil.ArtifactPath("forcepull-test.json")
		varSubDest = authCfg.ServerAddress + "/" + oc.Namespace()

		// grant access to the custom build strategy
		g.By("granting system:build-strategy-custom")
		err = oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "system:build-strategy-custom", oc.Username()).Execute()
		o.Expect(err).NotTo(o.HaveOccurred())

		defer func() {
			err = oc.AsAdmin().Run("adm").Args("policy", "remove-cluster-role-from-user", "system:build-strategy-custom", oc.Username()).Execute()
			o.Expect(err).NotTo(o.HaveOccurred())
		}()

		err = exutil.VarSubOnFile(pre, post, map[string]string{varSubSrc: varSubDest})
		o.Expect(err).NotTo(o.HaveOccurred())
		err = exutil.CreateResource(post, oc)
		o.Expect(err).NotTo(o.HaveOccurred())

		// dump the image textual tags and hex ids out for debug
		tags = []string{fullImageName + ":latest", corruptor + ":latest"}
		hexIDs, err := exutil.DumpAndReturnTagging(tags)
		o.Expect(err).NotTo(o.HaveOccurred())
		resetData = map[string]string{fullImageName: hexIDs[0], corruptor: hexIDs[1]}

	})

	g.Context("ForcePull test context  ", func() {

		g.JustBeforeEach(func() {