Skip to content

Commit d242ce5

Browse files
DavidGOrtega0x2b3bfa0restyled-commits
authored
CML sugar 🍬 (#339)
* CML sugar * temp remove rerun * nil * temp remove rerun * temp remove env * Constrain permissions for tpi-task-shutdown * cosmetic * add TPI_TASK * nitpicks * Restyled by gofmt * notpicks * no os Co-authored-by: Helio Machado <0x2b3bfa0+git@googlemail.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 12d79e1 commit d242ce5

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

iterative/resource_task.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ func resourceTaskBuild(ctx context.Context, d *schema.ResourceData, m interface{
236236
}
237237
}
238238

239+
val := "true"
240+
v["TPI_TASK"] = &val
241+
v["CI"] = nil
242+
v["CI_*"] = nil
243+
v["GITHUB_*"] = nil
244+
v["BITBUCKET_*"] = nil
245+
v["CML_*"] = nil
246+
v["REPO_TOKEN"] = nil
247+
239248
c := common.Cloud{
240249
Provider: common.Provider(d.Get("cloud").(string)),
241250
Region: common.Region(d.Get("region").(string)),

task/common/machine/script.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ base64 --decode << END | sudo tee /usr/bin/tpi-task > /dev/null
3232
END
3333
chmod u=rwx,g=rx,a=rx /usr/bin/tpi-task
3434
35+
sudo tee /usr/bin/tpi-task-shutdown << 'END'
36+
#!/bin/bash
37+
if ! test -z "$CI"; then
38+
cml rerun-workflow
39+
fi
40+
(systemctl is-system-running | grep stopping) || tpi --stop;
41+
END
42+
chmod u=rwx,g=rx,o=rx /usr/bin/tpi-task-shutdown
43+
3544
base64 --decode << END | sudo tee /tmp/tpi-environment > /dev/null
3645
%s
3746
END
@@ -47,7 +56,7 @@ sudo tee /etc/systemd/system/tpi-task.service > /dev/null <<END
4756
[Service]
4857
Type=simple
4958
ExecStart=/usr/bin/tpi-task
50-
ExecStopPost=/bin/bash -c 'systemctl is-system-running | grep stopping || tpi --stop'
59+
ExecStopPost=/usr/bin/tpi-task-shutdown
5160
Environment=HOME=/root
5261
EnvironmentFile=/tmp/tpi-environment
5362
WorkingDirectory=/tmp/tpi-task
@@ -61,6 +70,10 @@ sudo mv terraform-provider-iterative* /usr/bin/tpi
6170
sudo chmod u=rwx,g=rx,o=rx /usr/bin/tpi
6271
sudo chown root:root /usr/bin/tpi
6372
73+
curl --location --remote-name https://github.com/iterative/cml/releases/latest/download/cml-linux
74+
chmod u=rwx,g=rx,o=rx cml-linux
75+
sudo mv cml-linux /usr/bin/cml
76+
6477
extract_here(){
6578
if command -v unzip 2>&1 > /dev/null; then
6679
unzip "$1"

0 commit comments

Comments
 (0)