version: 2.1
jobs:
  build:
    environment:
      GO111MODULE: "on"
      CONSUL_VERSION: 1.8.0
      VAULT_VERSION: 1.4.2
    docker:
      - image: docker.mirror.hashicorp.services/circleci/golang:latest
    working_directory: /go/src/github.com/hashicorp/consul-template
    steps:
      - checkout
      - restore_cache:
          keys:
            - ct-modcache-v1-{{ checksum "go.mod" }}
      - run: |
          curl -sLo consul.zip https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
          unzip consul.zip
          sudo cp consul /usr/local/bin/
      - run: |
          curl -sLo vault.zip https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip
          unzip vault.zip
          sudo cp vault /usr/local/bin/
      - run: |
          make test
      - save_cache:
          key: ct-modcache-v1-{{ checksum "go.mod" }}
          paths:
            - /go/pkg/mod

version: 2.1
jobs:
  build:
    environment:
      GO111MODULE: "on"
      CONSUL_VERSION: 1.8.0
      VAULT_VERSION: 1.4.2
    docker:
      - image: docker.mirror.hashicorp.services/cimg/go:1.17
    steps:
      - checkout
      - restore_cache:
          keys:
            - ct-modcache-v1-{{ checksum "go.mod" }}
      - run: |
          curl -sLo consul.zip https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
          unzip consul.zip
          sudo cp consul /usr/local/bin/
      - run: |
          curl -sLo vault.zip https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip
          unzip vault.zip
          sudo cp vault /usr/local/bin/
      - run: |
          make test
      - save_cache:
          key: ct-modcache-v1-{{ checksum "go.mod" }}
          paths:
            - /go/pkg/mod

Replace deprecated 'circleci/golang' with 'cimg/go' image
Replace deprecated 'circleci/golang' with 'cimg/go' image

Context for deprecating 'circleci/golang':
https://discuss.circleci.com/t/legacy-convenience-image-deprecation/41034

Removed working_dir:
 - Reason: This was causing circleci error: "mkdir: cannot create directory
 ‘/go’: Permission denied"
 - Solution: Referred to Consul PR for this fix. The working_dir is redundant
