# Generated from .gitlab-ci.jsonnet 
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN 
---
container-base-build:
  before_script:
  - docker login -u $DOCKER_USER -p $DOCKER_PASS quay.io
  image: docker:git
  only:
  - schedules
  - tags
  script:
  - 'docker build --build-arg sshkey=$OPERATORCLENT_RSA_B64 --no-cache -f base.Dockerfile -t quay.io/coreos/olm-ci:base . '
  - docker push quay.io/coreos/olm-ci:base
  stage: docker_base
  tags:
  - kubernetes
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://docker-host.gitlab.svc.cluster.local:2375
container-build:
  before_script:
  - docker login -u $DOCKER_USER -p $DOCKER_PASS quay.io
  - mkdir -p $PWD/bin
  image: docker:git
  only:
  - master
  - tags
  script:
  - docker build -f upstream.Dockerfile .
  - "docker tag $(docker images --filter 'label=stage=builder' --format '{{.CreatedAt}}\t{{.ID}}' | sort -nr | head -n 1 | cut -f2) quay.io/coreos/olm-ci:${CI_COMMIT_REF_SLUG}"
  - "docker tag $(docker images --filter 'label=stage=e2e' --format '{{.CreatedAt}}\t{{.ID}}' | sort -nr | head -n 1 | cut -f2) quay.io/coreos/olm-e2e:${CI_COMMIT_REF_SLUG}-${SHA8}"
  - "docker tag $(docker images --filter 'label=stage=olm' --format '{{.CreatedAt}}\t{{.ID}}' | sort -nr | head -n 1 | cut -f2) quay.io/coreos/olm-ci:${CI_COMMIT_REF_SLUG}-pre"
  - docker push quay.io/coreos/olm-ci:${CI_COMMIT_REF_SLUG}
  - docker push quay.io/coreos/olm-e2e:${CI_COMMIT_REF_SLUG}-${SHA8}
  - docker push quay.io/coreos/olm-ci:${CI_COMMIT_REF_SLUG}-pre
  stage: docker_build
  tags:
  - kubernetes
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://docker-host.gitlab.svc.cluster.local:2375
container-release:
  before_script:
  - docker login -u $DOCKER_USER -p $DOCKER_PASS quay.io
  - mkdir -p $PWD/bin
  image: docker:git
  only:
  - master
  script:
  - docker pull quay.io/coreos/olm-ci:${CI_COMMIT_REF_SLUG}-pre
  - docker tag quay.io/coreos/olm-ci:${CI_COMMIT_REF_SLUG}-pre quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}
  - docker push quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}
  - docker pull quay.io/coreos/olm-e2e:${CI_COMMIT_REF_SLUG}-${SHA8}
  - docker tag quay.io/coreos/olm-e2e:${CI_COMMIT_REF_SLUG}-${SHA8} quay.io/coreos/olm-e2e:latest
  - docker push quay.io/coreos/olm-e2e:latest
  stage: docker_release
  tags:
  - kubernetes
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://docker-host.gitlab.svc.cluster.local:2375
deploy-openshift:
  before_script:
  - 'echo "version: 1.0.0-${CI_COMMIT_REF_SLUG}-pre" >> deploy/chart/Chart.yaml'
  - 'echo "{\"catalog.image.ref\": \"quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}\", \"catalog_namespace\": \"operator-lifecycle-manager\", \"namespace\": \"operator-lifecycle-manager\", \"olm.image.ref\":
    \"quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}\", \"package.image.ref\": \"quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}\", \"watchedNamespaces\": \"\"}" > params.json'
  - cat params.json
  environment:
    name: openshift
    url: https://console.apps.ui-preserve.origin-gce.dev.openshift.com
  image: quay.io/coreos/alm-ci-build:latest
  only:
  - master
  script:
  - echo $OPENSHIFT_KUBECONFIG | base64 -d > kubeconfig
  - export KUBECONFIG=./kubeconfig
  - charttmpdir=`mktemp -d 2>/dev/null || mktemp -d -t 'charttmpdir'`;mkdir -p ${charttmpdir};helm template -n olm --set namespace=operator-lifecycle-manager deploy/chart --set catalog.image.ref=quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}
    --set catalog_namespace=operator-lifecycle-manager --set namespace=operator-lifecycle-manager --set olm.image.ref=quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8} --set package.image.ref=quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}
    --set watchedNamespaces= --output-dir ${charttmpdir};chartfilenames=$(ls ${charttmpdir}/olm/templates/*.yaml);echo ${chartfilenames};for f in ${chartfilenames};do if [[ $f == *.configmap.yaml ]];then
    kubectl replace --force -f ${f};else kubectl apply -f ${f};fi;done;
  - kubectl create secret docker-registry coreos-pull-secret --docker-server quay.io --docker-username $DOCKER_USER --docker-password $DOCKER_PASS --docker-email ignored@example.com --namespace=operator-lifecycle-manager
    || true
  - kubectl rollout status -w deployment/olm-operator --namespace=operator-lifecycle-manager
  - kubectl rollout status -w deployment/catalog-operator --namespace=operator-lifecycle-manager
  - 'curl -X POST --data-urlencode "payload={\"text\": \"New OLM Operator quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA} deployed to ${OPENSHIFT_HOST}/k8s/ns/operator-lifecycle-manager/deployments/alm-operator\"}"
    ${TEAMUI_SLACK_URL}'
  stage: deploy_staging
  tags:
  - kubernetes
  variables:
    ALM_DOMAIN: console.apps.ui-preserve.origin-gce.dev.openshift.com
    K8S_NAMESPACE: operator-lifecycle-manager
deploy-staging:
  before_script:
  - 'echo "version: 1.0.0-${CI_COMMIT_REF_SLUG}-pre" >> deploy/chart/Chart.yaml'
  - 'echo "{\"catalog.image.ref\": \"quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}\", \"catalog_namespace\": \"ci-alm-staging\", \"namespace\": \"ci-alm-staging\", \"olm.image.ref\": \"quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}\",
    \"package.image.ref\": \"quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}\", \"watchedNamespaces\": \"ci-alm-staging\"}" > params.json'
  - cat params.json
  environment:
    name: staging
    url: https://alm-staging.k8s.devtable.com
  image: quay.io/coreos/alm-ci-build:latest
  only:
  - master
  script:
  - echo $CD_KUBECONFIG | base64 -d > kubeconfig
  - export KUBECONFIG=./kubeconfig
  - charttmpdir=`mktemp -d 2>/dev/null || mktemp -d -t 'charttmpdir'`;mkdir -p ${charttmpdir};helm template -n olm --set namespace=ci-alm-staging deploy/chart --set catalog.image.ref=quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}
    --set catalog_namespace=ci-alm-staging --set namespace=ci-alm-staging --set olm.image.ref=quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8} --set package.image.ref=quay.io/coreos/olm:${CI_COMMIT_REF_SLUG}-${SHA8}
    --set watchedNamespaces=ci-alm-staging --output-dir ${charttmpdir};chartfilenames=$(ls ${charttmpdir}/olm/templates/*.yaml);echo ${chartfilenames};for f in ${chartfilenames};do if [[ $f == *.configmap.yaml
    ]];then kubectl replace --force -f ${f};else kubectl apply -f ${f};fi;done;
  - kubectl create secret docker-registry coreos-pull-secret --docker-server quay.io --docker-username $DOCKER_USER --docker-password $DOCKER_PASS --docker-email ignored@example.com --namespace=ci-alm-staging
    || true
  - kubectl rollout status -w deployment/olm-operator --namespace=ci-alm-staging
  - kubectl rollout status -w deployment/catalog-operator --namespace=ci-alm-staging
  stage: deploy_staging
  tags:
  - kubernetes
  variables:
    ALM_DOMAIN: alm-staging.k8s.devtable.com
    K8S_NAMESPACE: ci-alm-staging
stages:
- docker_base
- docker_build
- deploy_preview
- test_setup
- tests
- test_teardown
- integration
- docker_release
- deploy_staging
- teardown
tag-release:
  before_script:
  - docker login -u $DOCKER_USER -p $DOCKER_PASS quay.io
  - mkdir -p $PWD/bin
  image: docker:git
  only:
  - tags
  script:
  - docker pull quay.io/coreos/olm-ci:${CI_COMMIT_REF_SLUG}-pre
  - docker tag quay.io/coreos/olm-ci:${CI_COMMIT_REF_SLUG}-pre quay.io/coreos/olm:${CI_COMMIT_TAG}
  - docker push quay.io/coreos/olm:${CI_COMMIT_TAG}
  - docker pull quay.io/coreos/olm-e2e:${CI_COMMIT_REF_SLUG}-${SHA8}
  - docker tag quay.io/coreos/olm-e2e:${CI_COMMIT_REF_SLUG}-${SHA8} quay.io/coreos/olm-e2e:latest
  - docker push quay.io/coreos/olm-e2e:latest
  stage: docker_release
  tags:
  - kubernetes
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://docker-host.gitlab.svc.cluster.local:2375
variables:
  FAILFASTCI_NAMESPACE: operator-framework
  GET_SOURCES_ATTEMPTS: '10'
