Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SPSTRAT-465): add task for marketplacesvm #719

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions schema/dataKeys.json
mmalina marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,51 @@
}
}
},
"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"
}
}
},
mmalina marked this conversation as resolved.
Show resolved Hide resolved
"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"
}
}
}
},
"pushSourceContainer": {
"type": "boolean",
"description": "Indicates if the source container should be pushed"
Expand Down Expand Up @@ -475,6 +520,10 @@
"registrySecret": {
"type": "string",
"description": "The k8s secret containing token for quay.io API"
},
"cloudMarketplacesSecret": {
"type": "string",
"description": "Secret for cloud marketplaces"
}
}
},
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:6556e8a6b031c1aad4f0472703fd121a6e1cd45d
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:6556e8a6b031c1aad4f0472703fd121a6e1cd45d
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:6556e8a6b031c1aad4f0472703fd121a6e1cd45d
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:6556e8a6b031c1aad4f0472703fd121a6e1cd45d
env:
- name: "SECRET"
value: '$(params.secret)'
script: |
#!/usr/bin/env sh
set -eux

test "$SECRET" = "eyJ0ZXN0Ijoic2VjcmV0In0K"
13 changes: 13 additions & 0 deletions tasks/marketplacesvm-push-disk-images/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# marketplacesvm-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 | - |
| cloudMarketplacesSecret | Env specific secret containing the marketplaces credentials. | No | - |
| concurrentLimit | The maximum number of images to be pulled at once. | Yes | 3 |
Loading
Loading