File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ << comment
4+ When you run a ` make bin` in the terraform-provider-rancher2 repo, it
5+ downloads a binary into your local cache from the specified source. To
6+ tell Terraform to use a local binary, you need to overwrite the one in
7+ the cache.
8+
9+ Add the following to your Terraform config file. This tells Terraform
10+ to use the local cache https://terraform.io/cli/config/config-file.
11+
12+ terraform {
13+ required_providers {
14+ rancher2 = {
15+ source = "terraform.local/local/rancher2"
16+ version = "1.0.0"
17+ }
18+ }
19+ }
20+ comment
21+
22+ # Compile the local binary
23+ make bin
24+
25+ opsys=windows
26+ if [[ " $OSTYPE " == linux* ]]; then
27+ opsys=linux
28+ elif [[ " $OSTYPE " == darwin* ]]; then
29+ opsys=darwin
30+ fi
31+
32+ # Supported values of 'arch': amd64, arm64, ppc64le, s390x
33+ case $( uname -m) in
34+ x86_64)
35+ arch=amd64
36+ ;;
37+ arm64)
38+ arch=arm64
39+ ;;
40+ ppc64le)
41+ arch=ppc64le
42+ ;;
43+ s390x)
44+ arch=s390x
45+ ;;
46+ * )
47+ arch=amd64
48+ ;;
49+ esac
50+
51+ LOCAL_BINARY_PATH=~ /.terraform.d/plugins/terraform.local/local/rancher2/1.0.0/${opsys} _${arch}
52+
53+ if [ ! -d $LOCAL_BINARY_PATH ]
54+ then
55+ echo " Directory ${LOCAL_BINARY_PATH} does not exist. Creating..."
56+ mkdir -p $LOCAL_BINARY_PATH
57+ fi
58+
59+ # Overwrite the cached binary with your local one
60+ cp terraform-provider-rancher2 ${LOCAL_BINARY_PATH} /terraform-provider-rancher2
61+
62+ # Check if user specified options for init or apply
63+ while getopts ' ia' OPTION; do
64+ case " $OPTION " in
65+ i)
66+ rm -r .terraform.lock.hcl
67+ terraform init
68+ ;;
69+ a)
70+ rm -r .terraform.lock.hcl
71+ terraform init
72+ terraform apply
73+ ;;
74+ ? )
75+ echo " script usage: $( basename \$ 0) [-i] [-a]" >&2
76+ exit 1
77+ esac
78+ done
You can’t perform that action at this time.
0 commit comments