diff --git a/pkg/oc/oc.go b/pkg/oc/oc.go index 6fdb4ff2..1b1107e1 100644 --- a/pkg/oc/oc.go +++ b/pkg/oc/oc.go @@ -164,6 +164,10 @@ func CreateChainsImageRegistrySecret(dockerConfig string) { cmd.MustSucceed("oc", "create", "secret", "generic", "chains-image-registry-credentials", "--from-literal=.dockerconfigjson="+dockerConfig, "--from-literal=config.json="+dockerConfig, "--type=kubernetes.io/dockerconfigjson") } +func CreateJibMavenImageRegistrySecret(dockerConfig string) { + cmd.MustSucceed("oc", "create", "secret", "generic", "jib-maven-image-registry-credentials", "--from-literal=.dockerconfigjson="+dockerConfig, "--from-literal=config.json="+dockerConfig, "--type=kubernetes.io/dockerconfigjson") +} + func CopySecret(secretName string, sourceNamespace string, destNamespace string) { secretJson := cmd.MustSucceed("oc", "get", "secret", secretName, "-n", sourceNamespace, "-o", "json").Stdout() cmdOutput := cmd.MustSucceed("bash", "-c", fmt.Sprintf(`echo '%s' | jq 'del(.metadata["namespace", "creationTimestamp", "resourceVersion", "selfLink", "uid", "annotations"]) | .data |= with_entries(if .key == "github-auth-key" then .key = "token" else . end)'`, secretJson)).Stdout() diff --git a/specs/ecosystem/ecosystem-multiarch.spec b/specs/ecosystem/ecosystem-multiarch.spec index 0b81e108..0e7a0647 100644 --- a/specs/ecosystem/ecosystem-multiarch.spec +++ b/specs/ecosystem/ecosystem-multiarch.spec @@ -12,6 +12,8 @@ Type: Functional Importance: Critical Steps: + * Verify that jib-maven image registry variable is exported + * Create secret with image registry credentials for jib-maven * Create |S.NO|resource_dir | |----|------------------------------------------------------| @@ -31,6 +33,8 @@ Type: Functional Importance: Critical Steps: + * Verify that jib-maven image registry variable is exported + * Create secret with image registry credentials for jib-maven * Create |S.NO|resource_dir | |----|------------------------------------------------------| diff --git a/steps/ecosystem/ecosystem.go b/steps/ecosystem/ecosystem.go new file mode 100644 index 00000000..71d66b7c --- /dev/null +++ b/steps/ecosystem/ecosystem.go @@ -0,0 +1,24 @@ +package ecosystem + +import ( + "os" + + "github.com/getgauge-contrib/gauge-go/gauge" + "github.com/getgauge-contrib/gauge-go/testsuit" + "github.com/openshift-pipelines/release-tests/pkg/oc" +) + +var _ = gauge.Step("Verify that jib-maven image registry variable is exported", func() { + if os.Getenv("JIB_MAVEN_REPOSITORY") == "" { + testsuit.T.Errorf("'JIB_MAVEN_REPOSITORY' environment variable is not exported") + } +}) + +var _ = gauge.Step("Create secret with image registry credentials for jib-maven", func() { + if os.Getenv("JIB_MAVEN_DOCKER_CONFIG_JSON") == "" { + testsuit.T.Errorf("'JIB_MAVEN_DOCKER_CONFIG_JSON' credentials environment variable is not exported") + } else { + dockerConfig := os.Getenv("JIB_MAVEN_DOCKER_CONFIG_JSON") + oc.CreateJibMavenImageRegistrySecret(dockerConfig) + } +}) diff --git a/testdata/ecosystem/pipelines/jib-maven-pz.yaml b/testdata/ecosystem/pipelines/jib-maven-pz.yaml index ce53678f..5917c5e3 100644 --- a/testdata/ecosystem/pipelines/jib-maven-pz.yaml +++ b/testdata/ecosystem/pipelines/jib-maven-pz.yaml @@ -53,4 +53,4 @@ spec: - name: INSECUREREGISTRY value: "false" - name: MAVEN_IMAGE - value: maven:3.8.3-adoptopenjdk-11 + value: maven:3.8.3-adoptopenjdk-11 \ No newline at end of file