Skip to content

Commit

Permalink
feat(SPSTRAT-465): add task for marketplacesvm
Browse files Browse the repository at this point in the history
This commit introduces a new task named `marketplaces-push-disk-images`
which will be used to deliver disk images to various cloud marketplaces
using the `marketplacesvm_push_wrapper`.

Signed-off-by: Jonathan Gangi <jgangi@redhat.com>
  • Loading branch information
JAVGan committed Dec 9, 2024
1 parent 2f309e3 commit bc2c9db
Show file tree
Hide file tree
Showing 11 changed files with 624 additions and 0 deletions.
49 changes: 49 additions & 0 deletions schema/dataKeys.json
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,55 @@
}
}
},
"productInfo": {
"type": "object",
"properties": {
"productName": {
"type": "string",
"description": "productName in content gateway"
},
"productCode": {
"type": "string",
"description": "productCode in content gateway"
},
"productVersionName": {
"type": "string",
"description": "productVersionName in content gateway"
}
}
},
"starmap": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Artifact name"
},
"workflow": {
"type": "string",
"description": "Push workflow"
},
"cloud": {
"type": "string",
"description": "Cloud provider's name"
},
"mappings": {
"type": "object",
"description": "Mappings for the given artifact"
},
"billing-code-config": {
"type": "object",
"description": "Billing configuration for the community worklow"
}
}
}
},
"cloudMarketplacesSecret": {
"type": "string",
"description": "Secret for cloud marketplaces"
},
"pushSourceContainer": {
"type": "boolean",
"description": "Indicates if the source container should be pushed"
Expand Down
9 changes: 9 additions & 0 deletions tasks/collect-marketplacesvm-secret/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# collect-marketplacesvm-secret

Tekton task that collects the secret for the cloud marketplaces from the data file

## Parameters

| Name | Description | Optional | Default value |
|--------------|------------------------------------------------------------------|----------|---------------|
| dataPath | Path to the merged data JSON file generated by collect-data task | No | - |
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: collect-marketplaces-secret
labels:
app.kubernetes.io/version: "0.1.0"
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/tags: release
spec:
description: >-
Tekton task that collects the secret for the cloud marketplaces from the data file
params:
- name: dataPath
type: string
description: Path to the merged data JSON file generated by collect-data task
workspaces:
- name: data
description: The workspace where the data json file resides
results:
- name: cloudMarketplacesSecret
type: string
description: "The base64 encoded secret to use for various cloud marketplaces."
steps:
- name: collect-marketplacesvm-secret
image:
quay.io/konflux-ci/release-service-utils:7f7a156a835c773bbcd7e5d7e44df2f573db14f2
script: |
#!/usr/bin/env bash
set -eux
DATA_FILE="$(workspaces.data.path)/$(params.dataPath)"
if [ ! -f "${DATA_FILE}" ] ; then
echo "No valid data file was provided."
exit 1
fi
if [ "$(jq '.mapping | has("cloudMarketplacesSecret")' "$DATA_FILE")" == false ] ; then
echo "Marketplaces secret missing in data JSON file"
exit 1
fi
jq -j '.mapping.cloudMarketplacesSecret' "$DATA_FILE" | tee "$(results.cloudMarketplacesSecret.path)"
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: test-collect-marketplaces-secret-fail-no-secret
annotations:
test/assert-task-failure: "run-task"
spec:
description: |
Run the collect-marketplaces-secret task with no secret in the data file and
verify the task fails as expected
workspaces:
- name: tests-workspace
tasks:
- name: setup
workspaces:
- name: data
workspace: tests-workspace
taskSpec:
workspaces:
- name: data
steps:
- name: setup-values
image: quay.io/konflux-ci/release-service-utils:7f7a156a835c773bbcd7e5d7e44df2f573db14f2
script: |
#!/usr/bin/env sh
set -eux
cat > $(workspaces.data.path)/data.json << EOF
{
"mapping": {
"components": [
{
"name": "mycomponent"
}
],
"defaults": {
"public": true
}
}
}
EOF
- name: run-task
taskRef:
name: collect-marketplaces-secret
params:
- name: dataPath
value: data.json
workspaces:
- name: data
workspace: tests-workspace
runAfter:
- setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: test-collect-marketplaces-secret-fail-no-data
annotations:
test/assert-task-failure: "run-task"
spec:
description: |
Run the test-collect-marketplaces-secret task with no data file and verify the taks fails as expected
workspaces:
- name: tests-workspace
tasks:
- name: run-task
taskRef:
name: collect-marketplaces-secret
params:
- name: dataPath
value: data.json
workspaces:
- name: data
workspace: tests-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: test-collect-marketplaces-secret
spec:
description: |
Run the collect-marketplaces-secret task with the secret required and verify that
it will return the secret string.
workspaces:
- name: tests-workspace
tasks:
- name: setup
workspaces:
- name: data
workspace: tests-workspace
taskSpec:
workspaces:
- name: data
steps:
- name: setup-values
image: quay.io/konflux-ci/release-service-utils:7f7a156a835c773bbcd7e5d7e44df2f573db14f2
script: |
#!/usr/bin/env sh
set -eux
cat > $(workspaces.data.path)/data.json << EOF
{
"mapping": {
"components": [
{
"name": "mycomponent1"
},
{
"name": "mycomponent2",
"public": true
}
],
"defaults": {},
"cloudMarketplacesSecret": "eyJ0ZXN0Ijoic2VjcmV0In0K"
}
}
EOF
- name: run-task
taskRef:
name: collect-marketplaces-secret
params:
- name: dataPath
value: data.json
workspaces:
- name: data
workspace: tests-workspace
runAfter:
- setup
- name: check-result
params:
- name: secret
value: $(tasks.run-task.results.cloudMarketplacesSecret)
taskSpec:
params:
- name: secret
steps:
- name: check-result
image: quay.io/konflux-ci/release-service-utils:7f7a156a835c773bbcd7e5d7e44df2f573db14f2
env:
- name: "SECRET"
value: '$(params.secret)'
script: |
#!/usr/bin/env sh
set -eux
test "$SECRET" = "eyJ0ZXN0Ijoic2VjcmV0In0K"
14 changes: 14 additions & 0 deletions tasks/marketplacesvm-push-disk-images/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# marketplaces-push-disk-images

Tekton Task to publish VM disk images into various cloud marketplaces using `pubtools-marketplacesvm`.

It currently supports images in `raw` and `vhd` formats for `AWS` and `Azure` respectively.

## Parameters

| Name | Description | Optional | Default value |
| ----------------------- | -------------------------------------------------------------------------------------- | -------- | --------------- |
| snapshotPath | Path to the JSON string of the mapped snapshot spec in the data workspace. | No | - |
| dataPath | Path to the data JSON in the workspace containing the marketplacesvm options to use. | No | - |
| cloudMarketplacesSecret | Env specific secret containing the marketplaces credentials. | No | - |
| concurrentLimit | The maximum number of images to be pulled at once. | Yes | 3 |
Loading

0 comments on commit bc2c9db

Please sign in to comment.