Skip to content

Git and code hosts ​

Functions of the tools module at v0.7.0. Each returns what a command runs in; import it with import * as tools from "tools".

git.env ​

Git, configured by its parameters.

lask
git.env(
  --name: String | Null = null,
  --email: String | Null = null,
  --token: String | Null = <secret>,
  --host: String = "github.com",
  --token_user: String = "x-access-token",
  --ssh_dir: String | Null = null,
  --ssh_agent_socket: String | Null = null,
  --base_access: String | Map<String> | Null = null,
  --with: Array<Record<env: Map<String>, volumes: Array<String>>> = [],
  --extra_env: Map<String> = {}
): Runnable

The image is built from lib/images/unix/Dockerfile, as for unix.env(), so it takes no --image, and lask sync builds it. The container sees none of the host's Git configuration: the identity, a token for https and an SSH identity are given here, and the mounted project is trusted (safe.directory).

Parameters

  • --name GIT_AUTHOR_NAME and GIT_COMMITTER_NAME.
  • --email GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL.
  • --token!! An access token for https; masked in the command log. See git_setup.
  • --host The host the token is for.
  • --token_user The user name the host expects beside a token.
  • --ssh_dir Host directory mounted read-only at /root/.ssh; see ssh_setup.
  • --ssh_agent_socket Host path of an SSH agent socket (SSH_AUTH_SOCK); see ssh_setup.
  • --base_access What the container may do with the project directory: "rw" (the default), "ro", "none", or a table of paths such as {".": "ro", "dist": "rw"} (lask spec 10.2).
  • --with Setups of other tools this environment should also carry.
  • --extra_env Any other variable; below --with and the named parameters.

Returns Runnable: The environment, for command { "git" } on ... or $[...].

Image recipe lib/images/unix/Dockerfile

Command words bzip2, curl, envsubst, gzip, jq, openssl, rsync, tar, unzip, wget, xz, yq, zip: import command { "bzip2", "curl", "envsubst", "gzip", "jq", "openssl", "rsync", "tar", "unzip", "wget", "xz", "yq", "zip" } from "tools"

bash
lask eval git.env --name "CI" --email ci@example.com

lib/git.lask

git.setup ​

Git's identity and its access to private repositories over https.

lask
git.setup(
  --token: String | Null = <secret>,
  --host: String = "github.com",
  --token_user: String = "x-access-token",
  --name: String | Null = null,
  --email: String | Null = null
): Record<env: Map<String>, volumes: Array<String>>

The configuration is carried in GIT_CONFIG_* variables, so nothing is written to a file: the mounted project is trusted (safe.directory), and with a token, https://<host>/ and git@<host>: are both rewritten to https with the token in the URL. That reaches every tool that clones through Git — go get of a private module, a git dependency of npm, Cargo or Bundler. The token is masked wherever it appears.

Parameters

  • --token!! The access token; masked in the command log.
  • --host The host the token is for.
  • --token_user The user name the host expects beside a token: "x-access-token" for GitHub, "oauth2" for GitLab.
  • --name GIT_AUTHOR_NAME and GIT_COMMITTER_NAME.
  • --email GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL.

Returns Record<env: Map<String>, volumes: Array<String>>: The variables, for a tool's --with.

lib/git.lask

gh.env ​

The GitHub CLI, configured by its parameters.

lask
gh.env(
  --token: String | Null = <secret>,
  --host: String | Null = null,
  --repo: String | Null = null,
  --base_access: String | Map<String> | Null = null,
  --with: Array<Record<env: Map<String>, volumes: Array<String>>> = [],
  --extra_env: Map<String> = {}
): Runnable

The image is that of unix.env(), as for git. gh never prompts, checks for no update, and pages nothing (GH_PROMPT_DISABLED=1, GH_NO_UPDATE_NOTIFIER=1, GH_PAGER=""). The token authenticates gh's own API calls; a command that also runs git over https — gh pr checkout, gh repo clone — takes with = [git.setup(token = ...)] as well.

Parameters

  • --token!! GH_TOKEN; masked in the command log.
  • --host GH_HOST, for GitHub Enterprise Server.
  • --repo GH_REPO, "owner/name": the repository a command acts on when it is not the project's.
  • --base_access What the container may do with the project directory: "rw" (the default), "ro", "none", or a table of paths such as {".": "ro", "dist": "rw"} (lask spec 10.2).
  • --with Setups of other tools this environment should also carry.
  • --extra_env Any other variable; below --with and the named parameters.

Returns Runnable: The environment, for command { "gh" } on ... or $[...].

Image recipe lib/images/unix/Dockerfile

Command words bzip2, curl, envsubst, gzip, jq, openssl, rsync, tar, unzip, wget, xz, yq, zip: import command { "bzip2", "curl", "envsubst", "gzip", "jq", "openssl", "rsync", "tar", "unzip", "wget", "xz", "yq", "zip" } from "tools"

bash
lask eval gh.env --repo lask-task-runner/lask

lib/gh.lask

glab.env ​

The GitLab CLI, configured by its parameters.

lask
glab.env(
  --token: String | Null = <secret>,
  --host: String | Null = null,
  --base_access: String | Map<String> | Null = null,
  --with: Array<Record<env: Map<String>, volumes: Array<String>>> = [],
  --extra_env: Map<String> = {}
): Runnable

The image is that of unix.env(), as for git. glab checks for no update and never prompts (GLAB_CHECK_UPDATE=false, GLAB_NO_PROMPT=true). As with gh, a command that runs git over https takes git_setup as well, with token_user = "oauth2".

Parameters

  • --token!! GITLAB_TOKEN; masked in the command log.
  • --host GITLAB_HOST, for a self-managed instance.
  • --base_access What the container may do with the project directory: "rw" (the default), "ro", "none", or a table of paths such as {".": "ro", "dist": "rw"} (lask spec 10.2).
  • --with Setups of other tools this environment should also carry.
  • --extra_env Any other variable; below --with and the named parameters.

Returns Runnable: The environment, for command { "glab" } on ... or $[...].

Image recipe lib/images/unix/Dockerfile

Command words bzip2, curl, envsubst, gzip, jq, openssl, rsync, tar, unzip, wget, xz, yq, zip: import command { "bzip2", "curl", "envsubst", "gzip", "jq", "openssl", "rsync", "tar", "unzip", "wget", "xz", "yq", "zip" } from "tools"

bash
lask eval glab.env --host gitlab.example.com

lib/glab.lask

Released under the MIT License.