From 47ce5ff4717afd904369a5796d935d03e1026b34 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Wed, 18 Nov 2020 17:40:43 -0500 Subject: [PATCH] docs: expand artifact getter options Adds an example of using HTTP Basic Auth, git options, and using HCL2 syntax to encode an SSH key from file. --- .../pages/docs/job-specification/artifact.mdx | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/website/pages/docs/job-specification/artifact.mdx b/website/pages/docs/job-specification/artifact.mdx index 2f8a4c7f3..29909f195 100644 --- a/website/pages/docs/job-specification/artifact.mdx +++ b/website/pages/docs/job-specification/artifact.mdx @@ -95,6 +95,17 @@ artifact { } ``` +To use HTTP basic authentication, preprend the username and password to the +hostname in the URL. All special characters, including the username and +password, must be URL encoded. For example, for a username `exampleUser` and +the password `pass/word!`: + +```hcl +artifact { + source = "https://exampleUser:pass%2Fword%21@example.com/file.txt" +} +``` + ### Download using git This example downloads the artifact from the provided GitHub URL and places it at @@ -108,14 +119,30 @@ artifact { ``` To download from private repo, sshkey needs to be set. The key must be -base64-encoded string. Run `base64 -w0 ` +base64-encoded string. On Linux, you can run `base64 -w0 ` to encode the +file. Or use [HCL2](https://www.nomadproject.io/docs/job-specification/hcl2) +expressions to read and encode the key from a file on your machine: ```hcl artifact { source = "git@github.com:example/nomad-examples" destination = "local/repo" options { - sshkey = "" + sshkey = "${base64encode(file(pathexpand("~/.ssh/id_rsa")))}" + } +} +``` + +To clone specific refs or at a specific depth, use the `ref` and `depth` +options: + +```hcl +artifact { + source = "git::https://github.com/example/nomad-examples" + destination = "local/repo" + options { + ref = "main" + depth = 1 } } ```