-
-
Save ChrisPhillips-cminion/ea228d9ea3429bad11ad0a1c30f48b59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: tekton.dev/v1beta1 | |
kind: Task | |
metadata: | |
annotations: | |
tekton.dev/categories: APIPublish | |
tekton.dev/displayName: APIConnect Publish | |
tekton.dev/pipelines.minVersion: 0.0.1 | |
tekton.dev/platforms: linux/amd64 | |
tekton.dev/tags: apic | |
name: apic-publish | |
spec: | |
description: Publishes a Product to API Connect | |
params: | |
- default: fedora:latest | |
description: Base container Image | |
name: baseimage | |
type: string | |
- default: apiui.apic.com | |
description: APIConnect hostname | |
name: hostname | |
type: string | |
- default: ./dir | |
description: Subdirectory containing the products to be published | |
name: subdirectory | |
type: string | |
- description: User to log into the catalog with | |
name: user | |
type: string | |
- description: password for the user account | |
name: password | |
type: string | |
- default: provider/default-idp-2 | |
description: User Registry Realm | |
name: realm | |
type: string | |
- default: sandbox | |
description: Target Catalog | |
name: catalog | |
type: string | |
- default: demo | |
description: Target Provider Org | |
name: providerorg | |
type: string | |
- description: Target Space (leave blank if spaces are not used) | |
name: space | |
default: ' ' | |
type: string | |
- description: Auto migrate subscriptions (leave blank if not needed) | |
name: replace_subscriptions | |
default: ' ' | |
type: string | |
steps: | |
- env: | |
- name: dir | |
value: $(params.subdirectory) | |
- name: url | |
value: $(params.hostname) | |
- name: user | |
value: $(params.user) | |
- name: password | |
value: $(params.password) | |
- name: realm | |
value: $(params.realm) | |
- name: target_catalog | |
value: $(params.catalog) | |
- name: target_porg | |
value: $(params.providerorg) | |
- name: target_space | |
value: $(params.space) | |
- name: replace_subscriptions | |
value: $(params.replace_subscriptions) | |
image: $(params.baseimage) | |
name: ansible-builder-create | |
resources: {} | |
script: | | |
#!/bin/sh | |
if [ "replace_subscriptions" == "" ] ; then | |
migrate_subscriptions="" | |
else | |
migrate_subscriptions="--migrate_subscriptions" | |
fi | |
if [ "$target_space" == "" ] ; then | |
scope="space" | |
else | |
scope="catalog" | |
fi | |
rm -rf toolkit* | |
echo Downloading CLI tool | |
curl https://$url/client-downloads/toolkit-linux.tgz -k -o toolkit-linux.tgz | |
tar zxvf toolkit-linux.tgz | |
chmod 755 apic-slim | |
echo Login | |
./apic-slim --accept-license login -s $url --realm $realm --username $user --password $password | |
product_list=$(grep -ri product:\ 1.0.0 $dir | sed -e s/:.\*//) | |
echo Publishing to $publish_url | |
for i in $product_list ; do | |
echo "publishing ./apic-slim products:publish $i -s $url -o $target_porg -c $target_catalog --scope $scope $migrate_subscriptions" | |
./apic-slim products:publish $i -s $url -o $target_porg -c $target_catalog --scope $scope $migrate_subscriptions | |
done | |
workingDir: $(workspaces.workdir.path) | |
workspaces: | |
- name: workdir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment