# Copyright 2019 The Tekton Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Secret
metadata:
  name: test-readonly-credentials
type: kubernetes.io/dockercfg
data:
  # Generated by:
  # kubectl create secret docker-registry regsecret --docker-server=https://gcr.io \
  #     --docker-username=_json_key --docker-password="$(cat /tmp/key.json)" \
  #     --docker-email=noreply@google.com --dry-run -o yaml
  # This service account is JUST a storage reader on gcr.io/build-crd-testing
  .dockercfg: [encoded data, 7564 characters]
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: test-build-robot
secrets:
- name: test-readonly-credentials
imagePullSecrets:
- name: test-readonly-credentials
---
# This example contains embedded taskSpec. This taskrun requires the secrets and service accounts to be able to pull the
# private image. Required secret and service account for this run is configured in test-build-robot SA and test-readonly-credentials secret.
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
  generateName: pull-private-image-
spec:
  serviceAccountName: test-build-robot
  taskSpec:
    steps:
    - name: pull
      # Private image is just Ubuntu
      image: quay.io/rhpipeline/skopeo:alpine
      script: skopeo copy docker://gcr.io/build-crd-testing/secret-sauce dir:///tmp/
