Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runner docker volumes #367

Merged
merged 8 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions iterative/resource_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ func resourceRunner() *schema.Resource {
Type: schema.TypeString,
},
},
"docker_volumes": &schema.Schema{
Type: schema.TypeList,
ForceNew: true,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
}
}
Expand Down Expand Up @@ -331,6 +339,7 @@ HOME="$(mktemp -d)" exec cml-runner \
{{if .repo}} --repo {{escape .repo}}{{end}} \
{{if .token}} --token {{escape .token}}{{end}} \
{{if .single}} --single{{end}} \
{{range .docker_volumes}}--docker-volumes {{escape .}} {{end}} \
{{if .tf_resource}} --tf-resource {{escape .tf_resource}}{{end}}

{{- if not .container}}
Expand Down Expand Up @@ -424,6 +433,7 @@ func provisionerCode(d *schema.ResourceData) (string, error) {
data["tf_resource"] = base64.StdEncoding.EncodeToString(jsonResource)
data["instance_gpu"] = d.Get("instance_gpu").(string)
data["single"] = d.Get("single").(bool)
data["docker_volumes"] = d.Get("docker_volumes").([]interface{})
data["AWS_SECRET_ACCESS_KEY"] = os.Getenv("AWS_SECRET_ACCESS_KEY")
data["AWS_ACCESS_KEY_ID"] = os.Getenv("AWS_ACCESS_KEY_ID")
data["AWS_SESSION_TOKEN"] = os.Getenv("AWS_SESSION_TOKEN")
Expand Down
11 changes: 11 additions & 0 deletions iterative/resource_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ func TestScript(t *testing.T) {
})
}

func TestDockerVolumes(t *testing.T) {
t.Run("Runner Docker Volumes", func(t *testing.T) {
data := make(map[string]interface{})
data["docker_volumes"] = []string{"/one/one.txt:/one/one.txt", "/two:/two"}

script, err := renderScript(data)
assert.Nil(t, err)
assert.Contains(t, script, "--docker-volumes /one/one.txt:/one/one.txt --docker-volumes /two:/two")
})
}

func TestProvisionerCode(t *testing.T) {
g := goldie.New(t, goldie.WithDiffEngine(goldie.ColoredDiff))

Expand Down
1 change: 1 addition & 0 deletions iterative/testdata/script_template_cloud_aws.golden
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ HOME="$(mktemp -d)" exec cml-runner \
--repo '14 value with "quotes" and spaces' \
--token '13 value with "quotes" and spaces' \
--single \
\
--tf-resource eyJtb2RlIjoibWFuYWdlZCIsInR5cGUiOiJpdGVyYXRpdmVfY21sX3J1bm5lciIsIm5hbWUiOiJydW5uZXIiLCJwcm92aWRlciI6InByb3ZpZGVyW1wicmVnaXN0cnkudGVycmFmb3JtLmlvL2l0ZXJhdGl2ZS9pdGVyYXRpdmVcIl0iLCJpbnN0YW5jZXMiOlt7InByaXZhdGUiOiIiLCJzY2hlbWFfdmVyc2lvbiI6MCwiYXR0cmlidXRlcyI6eyJuYW1lIjoiMTAgdmFsdWUgd2l0aCBcInF1b3Rlc1wiIGFuZCBzcGFjZXMiLCJsYWJlbHMiOiIiLCJpZGxlX3RpbWVvdXQiOjExLCJyZXBvIjoiIiwidG9rZW4iOiIiLCJkcml2ZXIiOiIiLCJjbG91ZCI6ImF3cyIsImN1c3RvbV9kYXRhIjoiIiwiaWQiOiIiLCJpbWFnZSI6IiIsImluc3RhbmNlX2dwdSI6IiIsImluc3RhbmNlX2hkZF9zaXplIjoxMiwiaW5zdGFuY2VfaXAiOiIiLCJpbnN0YW5jZV9sYXVuY2hfdGltZSI6IiIsImluc3RhbmNlX3R5cGUiOiIiLCJyZWdpb24iOiI5IHZhbHVlIHdpdGggXCJxdW90ZXNcIiBhbmQgc3BhY2VzIiwic3NoX25hbWUiOiIiLCJzc2hfcHJpdmF0ZSI6IiIsInNzaF9wdWJsaWMiOiIiLCJhd3Nfc2VjdXJpdHlfZ3JvdXAiOiIifX1dfQ==
EOF
sudo chmod +x /usr/bin/cml.sh
Expand Down
1 change: 1 addition & 0 deletions iterative/testdata/script_template_cloud_azure.golden
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ HOME="$(mktemp -d)" exec cml-runner \
--repo '14 value with "quotes" and spaces' \
--token '13 value with "quotes" and spaces' \
--single \
\
--tf-resource eyJtb2RlIjoibWFuYWdlZCIsInR5cGUiOiJpdGVyYXRpdmVfY21sX3J1bm5lciIsIm5hbWUiOiJydW5uZXIiLCJwcm92aWRlciI6InByb3ZpZGVyW1wicmVnaXN0cnkudGVycmFmb3JtLmlvL2l0ZXJhdGl2ZS9pdGVyYXRpdmVcIl0iLCJpbnN0YW5jZXMiOlt7InByaXZhdGUiOiIiLCJzY2hlbWFfdmVyc2lvbiI6MCwiYXR0cmlidXRlcyI6eyJuYW1lIjoiMTAgdmFsdWUgd2l0aCBcInF1b3Rlc1wiIGFuZCBzcGFjZXMiLCJsYWJlbHMiOiIiLCJpZGxlX3RpbWVvdXQiOjExLCJyZXBvIjoiIiwidG9rZW4iOiIiLCJkcml2ZXIiOiIiLCJjbG91ZCI6ImF6dXJlIiwiY3VzdG9tX2RhdGEiOiIiLCJpZCI6IiIsImltYWdlIjoiIiwiaW5zdGFuY2VfZ3B1IjoiIiwiaW5zdGFuY2VfaGRkX3NpemUiOjEyLCJpbnN0YW5jZV9pcCI6IiIsImluc3RhbmNlX2xhdW5jaF90aW1lIjoiIiwiaW5zdGFuY2VfdHlwZSI6IiIsInJlZ2lvbiI6IjkgdmFsdWUgd2l0aCBcInF1b3Rlc1wiIGFuZCBzcGFjZXMiLCJzc2hfbmFtZSI6IiIsInNzaF9wcml2YXRlIjoiIiwic3NoX3B1YmxpYyI6IiIsImF3c19zZWN1cml0eV9ncm91cCI6IiJ9fV19
EOF
sudo chmod +x /usr/bin/cml.sh
Expand Down
1 change: 1 addition & 0 deletions iterative/testdata/script_template_cloud_gcp.golden
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ HOME="$(mktemp -d)" exec cml-runner \
--repo '14 value with "quotes" and spaces' \
--token '13 value with "quotes" and spaces' \
--single \
\
--tf-resource eyJtb2RlIjoibWFuYWdlZCIsInR5cGUiOiJpdGVyYXRpdmVfY21sX3J1bm5lciIsIm5hbWUiOiJydW5uZXIiLCJwcm92aWRlciI6InByb3ZpZGVyW1wicmVnaXN0cnkudGVycmFmb3JtLmlvL2l0ZXJhdGl2ZS9pdGVyYXRpdmVcIl0iLCJpbnN0YW5jZXMiOlt7InByaXZhdGUiOiIiLCJzY2hlbWFfdmVyc2lvbiI6MCwiYXR0cmlidXRlcyI6eyJuYW1lIjoiMTAgdmFsdWUgd2l0aCBcInF1b3Rlc1wiIGFuZCBzcGFjZXMiLCJsYWJlbHMiOiIiLCJpZGxlX3RpbWVvdXQiOjExLCJyZXBvIjoiIiwidG9rZW4iOiIiLCJkcml2ZXIiOiIiLCJjbG91ZCI6ImdjcCIsImN1c3RvbV9kYXRhIjoiIiwiaWQiOiIiLCJpbWFnZSI6IiIsImluc3RhbmNlX2dwdSI6IiIsImluc3RhbmNlX2hkZF9zaXplIjoxMiwiaW5zdGFuY2VfaXAiOiIiLCJpbnN0YW5jZV9sYXVuY2hfdGltZSI6IiIsImluc3RhbmNlX3R5cGUiOiIiLCJyZWdpb24iOiI5IHZhbHVlIHdpdGggXCJxdW90ZXNcIiBhbmQgc3BhY2VzIiwic3NoX25hbWUiOiIiLCJzc2hfcHJpdmF0ZSI6IiIsInNzaF9wdWJsaWMiOiIiLCJhd3Nfc2VjdXJpdHlfZ3JvdXAiOiIifX1dfQ==
EOF
sudo chmod +x /usr/bin/cml.sh
Expand Down
1 change: 1 addition & 0 deletions iterative/testdata/script_template_cloud_invalid.golden
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ HOME="$(mktemp -d)" exec cml-runner \
--repo '14 value with "quotes" and spaces' \
--token '13 value with "quotes" and spaces' \
--single \
\
--tf-resource eyJtb2RlIjoibWFuYWdlZCIsInR5cGUiOiJpdGVyYXRpdmVfY21sX3J1bm5lciIsIm5hbWUiOiJydW5uZXIiLCJwcm92aWRlciI6InByb3ZpZGVyW1wicmVnaXN0cnkudGVycmFmb3JtLmlvL2l0ZXJhdGl2ZS9pdGVyYXRpdmVcIl0iLCJpbnN0YW5jZXMiOlt7InByaXZhdGUiOiIiLCJzY2hlbWFfdmVyc2lvbiI6MCwiYXR0cmlidXRlcyI6eyJuYW1lIjoiMTAgdmFsdWUgd2l0aCBcInF1b3Rlc1wiIGFuZCBzcGFjZXMiLCJsYWJlbHMiOiIiLCJpZGxlX3RpbWVvdXQiOjExLCJyZXBvIjoiIiwidG9rZW4iOiIiLCJkcml2ZXIiOiIiLCJjbG91ZCI6ImludmFsaWQiLCJjdXN0b21fZGF0YSI6IiIsImlkIjoiIiwiaW1hZ2UiOiIiLCJpbnN0YW5jZV9ncHUiOiIiLCJpbnN0YW5jZV9oZGRfc2l6ZSI6MTIsImluc3RhbmNlX2lwIjoiIiwiaW5zdGFuY2VfbGF1bmNoX3RpbWUiOiIiLCJpbnN0YW5jZV90eXBlIjoiIiwicmVnaW9uIjoiOSB2YWx1ZSB3aXRoIFwicXVvdGVzXCIgYW5kIHNwYWNlcyIsInNzaF9uYW1lIjoiIiwic3NoX3ByaXZhdGUiOiIiLCJzc2hfcHVibGljIjoiIiwiYXdzX3NlY3VyaXR5X2dyb3VwIjoiIn19XX0=
EOF
sudo chmod +x /usr/bin/cml.sh
Expand Down
1 change: 1 addition & 0 deletions iterative/testdata/script_template_cloud_kubernetes.golden
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ HOME="$(mktemp -d)" exec cml-runner \
--repo '14 value with "quotes" and spaces' \
--token '13 value with "quotes" and spaces' \
--single \
\
--tf-resource eyJtb2RlIjoibWFuYWdlZCIsInR5cGUiOiJpdGVyYXRpdmVfY21sX3J1bm5lciIsIm5hbWUiOiJydW5uZXIiLCJwcm92aWRlciI6InByb3ZpZGVyW1wicmVnaXN0cnkudGVycmFmb3JtLmlvL2l0ZXJhdGl2ZS9pdGVyYXRpdmVcIl0iLCJpbnN0YW5jZXMiOlt7InByaXZhdGUiOiIiLCJzY2hlbWFfdmVyc2lvbiI6MCwiYXR0cmlidXRlcyI6eyJuYW1lIjoiMTAgdmFsdWUgd2l0aCBcInF1b3Rlc1wiIGFuZCBzcGFjZXMiLCJsYWJlbHMiOiIiLCJpZGxlX3RpbWVvdXQiOjExLCJyZXBvIjoiIiwidG9rZW4iOiIiLCJkcml2ZXIiOiIiLCJjbG91ZCI6Imt1YmVybmV0ZXMiLCJjdXN0b21fZGF0YSI6IiIsImlkIjoiIiwiaW1hZ2UiOiIiLCJpbnN0YW5jZV9ncHUiOiIiLCJpbnN0YW5jZV9oZGRfc2l6ZSI6MTIsImluc3RhbmNlX2lwIjoiIiwiaW5zdGFuY2VfbGF1bmNoX3RpbWUiOiIiLCJpbnN0YW5jZV90eXBlIjoiIiwicmVnaW9uIjoiOSB2YWx1ZSB3aXRoIFwicXVvdGVzXCIgYW5kIHNwYWNlcyIsInNzaF9uYW1lIjoiIiwic3NoX3ByaXZhdGUiOiIiLCJzc2hfcHVibGljIjoiIiwiYXdzX3NlY3VyaXR5X2dyb3VwIjoiIn19XX0=