Skip to content

Instantly share code, notes, and snippets.

@rthallisey
Last active February 24, 2020 17:12
Show Gist options
  • Select an option

  • Save rthallisey/0a29d1ef0a90334a5557c88174973957 to your computer and use it in GitHub Desktop.

Select an option

Save rthallisey/0a29d1ef0a90334a5557c88174973957 to your computer and use it in GitHub Desktop.

Revisions

  1. Ryan Hallisey revised this gist Feb 24, 2020. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions stage-testing.sh
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,7 @@ set -e

    QUAY_USERNAME="${1:-}"
    QUAY_PASSWORD="${2:-}"

    APP_REGISTRY_NAMESPACE="${APP_REGISTRY_NAMESPACE:-redhat-operators-stage}"
    APP_REGISTRY_NAMESPACE="${3:-redhat-operators-stage}"

    if [ -z "${QUAY_USERNAME}" ]; then
    echo "QUAY_USERNAME not set"
  2. Ryan Hallisey created this gist Feb 24, 2020.
    58 changes: 58 additions & 0 deletions stage-testing.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    #!/bin/bash

    set -e

    QUAY_USERNAME="${1:-}"
    QUAY_PASSWORD="${2:-}"

    APP_REGISTRY_NAMESPACE="${APP_REGISTRY_NAMESPACE:-redhat-operators-stage}"

    if [ -z "${QUAY_USERNAME}" ]; then
    echo "QUAY_USERNAME not set"
    exit 1
    fi
    if [ -z "${QUAY_PASSWORD}" ]; then
    echo "QUAY_PASSWORD not set"
    exit 1
    fi

    TOKEN=$(curl -sH "Content-Type: application/json" -XPOST https://quay.io/cnr/api/v1/users/login -d '
    {
    "user": {
    "username": "'"${QUAY_USERNAME}"'",
    "password": "'"${QUAY_PASSWORD}"'"
    }
    }' | jq -r '.token')

    echo $TOKEN
    if [ "${TOKEN}" == "null" ]; then
    echo "TOKEN was 'null'. Did you enter the correct quay Username & Password?"
    exit 1
    fi

    cat <<EOF | oc create -f -
    apiVersion: v1
    kind: Secret
    metadata:
    name: quay-registry-$APP_REGISTRY_NAMESPACE
    namespace: "openshift-marketplace"
    type: Opaque
    stringData:
    token: "$TOKEN"
    EOF

    cat <<EOF | oc create -f -
    apiVersion: operators.coreos.com/v1
    kind: OperatorSource
    metadata:
    name: "${APP_REGISTRY_NAMESPACE}"
    namespace: "openshift-marketplace"
    spec:
    type: appregistry
    endpoint: https://quay.io/cnr
    registryNamespace: $APP_REGISTRY_NAMESPACE
    displayName: "${APP_REGISTRY_NAMESPACE}"
    publisher: "Stage testing"
    authorizationToken:
    secretName: quay-registry-$APP_REGISTRY_NAMESPACE
    EOF