# Copyright 2023 Google LLC
#
# 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.

substitutions:
  _WORKER_POOL: ""

options:
  pool:
    name: ${_WORKER_POOL}
  env:
    - PROJECT_ID=${PROJECT_ID}
    - LOCATION=${LOCATION}
    - SUBNETWORK=${_SUBNETWORK}
    - BUILD_ID=${BUILD_ID}

steps:
  - name: "gcr.io/cloud-builders/docker"
    id: "Terratest build image creation"
    args:
      - "build"
      - "-t"
      - "${_DOCKER_REPOSITORY}/knfsd-terratest:1.0"
      - "-f"
      - "./terratest/Dockerfile"
      - "./terratest"

  - name: "hashicorp/packer:1.9"
    id: "Packer client image creation"
    script: |
      packer init client &&
      packer build \
        -var use_iap=false \
        -var project=${PROJECT_ID} \
        -var zone=${LOCATION}-a \
        -var subnetwork=${SUBNETWORK} \
        client

images:
  - "${_DOCKER_REPOSITORY}/knfsd-terratest:1.0"
