-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
68 lines (59 loc) · 2.01 KB
/
Taskfile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
version: '3'
tasks:
silent: true
init:
silient: true
desc: "Set up the OpenTofu Project. Required: name:string, description:string, tier:number"
# take inputs for name, description and tier
inputs:
- name: name
desc: "Name of the environment"
- name: description
desc: "Description of the environment"
- name: tier
desc: "Tier of the environment"
- name: version
desc: "Version of the OpenTofu"
cmds:
- |
echo "Setting up OpenTF..."
name={{.name}}
description="{{.description}}"
tier={{.tier}}
version={{.version}}
# if name is not provided, throw error and exit
if [ -z "$name" ]; then
echo "Name is required"
exit 1
fi
# if description is not provided, set it to "No description"
if [ -z "$description" ]; then
description="No description"
fi
# if tier is not provided, set it to 1
if [ -z "$tier" ]; then
tier=1
fi
# if version is not provided, set it to 1.8
if [ -z "$version" ]; then
version=1.8
fi
echo "Name: $name"
echo "Description: $description"
echo "Tier: $tier"
echo "CWD: {{.USER_WORKING_DIR}}"
# Create `name` folder as a new project
# Throw error if folder already exists
if [ -d "$name" ]; then
echo "Project already exists"
exit 1
else
mkdir {{.USER_WORKING_DIR}}/$name
fi
# Copy Base folder relative this Taskfile to `name` folder
cp -r {{.TASKFILE_DIR}}/boiler/* {{.USER_WORKING_DIR}}/$name/
echo "# ${name}" > {{.USER_WORKING_DIR}}/$name/README.md
echo "${description}" >> {{.USER_WORKING_DIR}}/$name/README.md
echo "TIER=${tier}" > {{.USER_WORKING_DIR}}/$name/setup.config
echo "TF_VERSION=${version}" >> {{.USER_WORKING_DIR}}/$name/setup.config
echo "Project created successfully"