client-shell

command module
Version: v0.0.0-...-81b11f5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2020 License: MPL-2.0 Imports: 12 Imported by: 0

README

Taskcluster Client for Shell

Download License

A Taskcluster client library for the command line.

This directory builds an executable, taskcluster, suitable for interacting with Taskcluster from the comfort of you command-line and in simple shell scripts. It provides utilities ranging from direct calls to the specific API endpoints to more complex and practical tasks like listing and cancelling scheduled runs.

Installation

To install, download the taskcluster binary for the latest release your platform, and run it! On POSIX platforms you will need to chmod +x of course.

Usage

For a list of all commands run taskcluster help, detailed information about each command is available with taskcluster help <command> [<sub-command> [...]]. You can also use the -h or --help parameter to get a command's help information.

For a general guide to using Taskcluster clients, see Calling Taskcluster APIs.

Setup

Provide Taskcluster credentials to this tool with environment variables.

At least TASKCLUSTER_ROOT_URL must be given. For API calls that require authentication, additionally TASKCLUSTER_CLIENT_ID, TASKCLUSTER_ACCESS_TOKEN, and perhaps TASKCLUSTER_CERTIFICATE are also required.

The taskcluster signin command provides an easy method to get credentials for use with this tool See below.

Calling API Methods

To call an API method, use the taskcluster api <service> <apiMethod> subcommand. Help for these commands is extensive and based on the reference documentation; try

taskcluster api --help
taskcluster api auth --help
taskcluster api auth createClient --help

Positional URL arguments are given on the command line, with query arguments given with options (e.g., --limit). Methods that expect a payload body will read that body in JSON format from stdin. Response bodies are written to stdout in JSON, or to the destination file given by -o.

jq is a useful tool for dealing with JSON inputs and outputs.

Getting Credentials

The taskcluster signin subcommand provides an easy way to get credentials encoded into environment variables via a browser session.

$ eval `taskcluster signin`

This will open a web browser to get credentials, then set the corresponding environment variables in your shell session.

You might make this easy to use with a shell function in ~/.bashrc:

tc-signin() { eval `taskcluster signin "${@}"`; }

It's common to pass a --name (to help you differentiate clients from one another) and one or more --scope arguments:

tc-signin --name smoketest --scope assume:project:taskcluster:smoketests

See the taskcluster signin --help output or Calling Taskcluster APIs for more information.

Handling Timestamps

The taskcluster from-now subcommand can be used to generate timestamps relative to the current time. For example:

echo '{"expires": "'`taskcluster from-now 1 hour`'", ...}' | taskcluster api ..
Generating SlugIDs

The taskcluster slugid subcommand can generate (and encode and decode) slugids. To generate a nice slugid:

taskcluster slugid generate -n
Task and Task Group Commands

The following higher-level commands can be useful in day-to-day operations. This list may be incomplete; consult taskcluster --help for the full list.

  • taskcluster group cancel - cancel a whole task group by taskGroupId.
  • taskcluster group list - list tasks (taskId and label) in a task group
  • taskcluster group status - show the status of a task group
  • taskcluster task artifacts - get the name of the artifacts of a task.
  • taskcluster task cancel - cancel a task.
  • taskcluster task complete - completes a task.
  • taskcluster task def - get the full definition of a task.
  • taskcluster task group - get the taskGroupID of a task.
  • taskcluster task log - streams the log until completion.
  • taskcluster task name - get the name of a task.
  • taskcluster task rerun - rerun a task.
  • taskcluster task retrigger - re-trigger a task (new taskId, updated timestamps).
  • taskcluster task run - create and schedule a task through a 'docker run'-like interface.
  • taskcluster task status - get the status of a task.

Compatibility

This library is co-versioned with Taskcluster itself. That is, a client with version x.y.z contains API methods corresponding to Taskcluster version x.y.z. Taskcluster is careful to maintain API compatibility, and guarantees it within a major version. That means that any client with version x.* will work against any Taskcluster services at version x.*, and is very likely to work for many other major versions of the Taskcluster services. Any incompatibilities are noted in the Changelog.

Development

Requirements

This package requires Go version 1.12 and uses Go Modules.

Building

To build the client, clone the Taskcluster repository, switch to the clients/client-shell directory, and run go build -o taskcluster ..

Code Generation

The API specifications are generated automatically as part of running yarn generate in the root directory of this repository.

Commands

We are using cobra to manage the various commands and sub-commands that are implemented in taskcluster-cli.

Each command is a instance of the cobra.Command struct, and is dynamically registered at run-time in the command tree (in func init() {...}). Thus, commands are registered as an import side-effect. Commands are implemented in sub-packages.

To add a new command, create a new sub-package under cmds and add an import for that sub-package to subtree_import.go, keeping the imports in order.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package apis implements all the API endpoints.
Package apis implements all the API endpoints.
Package client contains integration code for taskcluster-client-go.
Package client contains integration code for taskcluster-client-go.
cmds
completions
Package completions implements command completion support.
Package completions implements command completion support.
config
Package configCmd implements the config subcommands.
Package configCmd implements the config subcommands.
from-now
Package fromNow implements the from-now command.
Package fromNow implements the from-now command.
group
Package group implements the group interaction subcommands.
Package group implements the group interaction subcommands.
root
Package root defines the root of the application command tree.
Package root defines the root of the application command tree.
signin
Package signin implements the signin command.
Package signin implements the signin command.
slugid
Package slugid implements the slugid subcommands.
Package slugid implements the slugid subcommands.
task
Package task implements the task subcommands.
Package task implements the task subcommands.
version
Package version implements the version subcommand.
Package version implements the version subcommand.
Package config implements the configuration management system.
Package config implements the configuration management system.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL