Documentationcurrent version
Help us improve the docs by fixing typos and proposing enhancements.

Nikita

Action "docker.tools.checksum"

Return the checksum of image:tag, if it exists. Note, there is no corresponding native docker command.

Output

  • err
    Error object if any.
  • $status
    True if command was executed.
  • checksum
    Image cheksum if it exist, undefined otherwise.

Hooks

on_action = ({config}) ->
  throw Error 'Configuration `repository` is deprecated, use `image` instead' if config.repository

Schema definitions

definitions =
  config:
    type: 'object'
    properties:
      'cwd':
        type: 'string'
        description: '''
        Change the build working directory.
        '''
      'docker':
        $ref: 'module://@nikitajs/docker/src/tools/execute#/definitions/docker'
      'image':
        type: 'string'
        description: '''
        Name of the Docker image present in the registry.
        '''
      'tag':
        type: 'string'
        default: 'latest'
        description: '''
        Tag of the Docker image, default to latest.
        '''

Handler

handler = ({config, tools: {find, log}}) ->
  # Global config
  config.docker = await find ({config: {docker}}) -> docker
  config[k] ?= v for k, v of config.docker
  log message: "Getting image checksum :#{config.image}", level: 'DEBUG'
  # Run `docker images` with the following config:
  # - `--no-trunc`: display full checksum
  # - `--quiet`: discard headers
  {$status, stdout} = await @docker.tools.execute
    boot2docker: config.boot2docker
    command: "images --no-trunc --quiet #{config.image}:#{config.tag}"
    compose: config.compose
    machine: config.machine
  checksum = if stdout is '' then undefined else stdout.toString().trim()
  log message: "Image checksum for #{config.image}: #{checksum}", level: 'INFO' if $status
  $status: $status, checksum: checksum

Exports

module.exports =
  handler: handler
  hooks:
    on_action: on_action
  metadata:
    definitions: definitions
Edit on GitHub
Navigate
About

Nikita is an open source project hosted on GitHub and developed by Adaltas.