# Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
#
# 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: Pod
metadata:
  name: some-name.infra.tf-destroy
  namespace: default
spec:
  activeDeadlineSeconds: 1800
  containers:
  - name: terraform
    image: eu.gcr.io/gardener-project/gardener/terraformer:0.16.0
    imagePullPolicy: IfNotPresent
    command:
    - sh
    - -c
    - sh /terraform.sh destroy 2>&1; [[ -f /success ]] && exit 0 || exit 1
    env:
    - name: TF_STATE_CONFIG_MAP_NAME
      value: some-name.infra.tf-state
    resources:
      requests:
        cpu: 100m
    volumeMounts:
    - mountPath: /tf
      name: tf
    - mountPath: /tfvars
      name: tfvars
    - mountPath: /tf-state-in
      name: tfstate
  restartPolicy: Never
  terminationGracePeriodSeconds: 30
  volumes:
  - name: tf
    configMap:
      name: some-name.infra.tf-config
  - name: tfvars
    secret:
      secretName: some-name.infra.tf-vars
  - name: tfstate
    configMap:
      name: some-name.infra.tf-state
