Skip to content

Latest commit

 

History

History
310 lines (189 loc) · 8.68 KB

API.md

File metadata and controls

310 lines (189 loc) · 8.68 KB

API Reference

Constructs

Image

Represents a docker image built during synthesis from a context directory (dir) with a Dockerfile.

The image will be built using docker build and then pushed through docker push. The URL of the pushed image can be accessed through image.url.

If you push to a registry other than docker hub, you can specify the registry URL through the registry option.

Initializers

import { Image } from 'cdk8s-image'

new Image(scope: Construct, id: string, props: ImageProps)
Name Type Description
scope constructs.Construct No description.
id string No description.
props ImageProps No description.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

propsRequired

Methods

Name Description
toString Returns a string representation of this construct.

toString
public toString(): string

Returns a string representation of this construct.

Static Functions

Name Description
isConstruct Checks if x is a construct.

isConstruct
import { Image } from 'cdk8s-image'

Image.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


Properties

Name Type Description
node constructs.Node The tree node.
url string The image URL to use in order to pull this instance of the image.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


urlRequired
public readonly url: string;
  • Type: string

The image URL to use in order to pull this instance of the image.


Structs

BuildArg

Build arg to pass to the docker build.

Initializer

import { BuildArg } from 'cdk8s-image'

const buildArg: BuildArg = { ... }

Properties

Name Type Description
name string the name of the build arg.
value string the value of the build arg.

nameRequired
public readonly name: string;
  • Type: string

the name of the build arg.


valueRequired
public readonly value: string;
  • Type: string

the value of the build arg.


ImageProps

Props for Image.

Initializer

import { ImageProps } from 'cdk8s-image'

const imageProps: ImageProps = { ... }

Properties

Name Type Description
dir string The docker build context directory (where Dockerfile is).
buildArgs BuildArg[] List of build args to pass to the build action.
file string Path to Dockerfile.
name string Name for the image.
platform string Set to specify the target platform for the build output, (for example, linux/amd64, linux/arm64, or darwin/amd64).
registry string The registry URL to use.
tag string Tag for the image.

dirRequired
public readonly dir: string;
  • Type: string

The docker build context directory (where Dockerfile is).


buildArgsOptional
public readonly buildArgs: BuildArg[];

List of build args to pass to the build action.


fileOptional
public readonly file: string;
  • Type: string

Path to Dockerfile.


nameOptional
public readonly name: string;
  • Type: string
  • Default: auto-generated name

Name for the image.

Docker convention is {registry_name}/{name}:{tag} Visit https://docs.docker.com/engine/reference/commandline/tag/ for more information


platformOptional
public readonly platform: string;
  • Type: string

Set to specify the target platform for the build output, (for example, linux/amd64, linux/arm64, or darwin/amd64).


registryOptional
public readonly registry: string;
  • Type: string
  • Default: "docker.io/library"

The registry URL to use.

This will be used as the prefix for the image name.

For example, if you have a local registry listening on port 500, you can set this to localhost:5000.


tagOptional
public readonly tag: string;
  • Type: string
  • Default: "latest"

Tag for the image.

Docker convention is {registry_name}/{name}:{tag} Visit https://docs.docker.com/engine/reference/commandline/tag/ for more information