resource

package module
v0.0.0-...-53f2cc2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

README

Artifactory Docker Resource

Concourse resource for triggering, getting and putting new versions of docker / container image artifacts within Artifactory repositories.

Config

Complete source configuration details can be viewed in GoDoc on the Source struct

Check

Checks use the items domain to find container image artifacts with the supplied raw AQL or repo, image & tag combination. Each artifact found is returned as its own unique version for Concourse with the Repo, Image, Tag & Modified values from the Artifactory API. Modified is used to filter future checks to ensure that API queries stay performant.

Get

Get will download a compressed container image to the input directory defined along with metadata for the artifact. View GoDoc for GetParameter options

Put

Put supports publishing 1 compressed container image (output of docker save) using glob style patterns to locate the artifact to publish. View GoDoc for PutParameter options

Examples

Configure the resource type:

resource_types:
- name: artifactory
  type: docker-image
  source:
    repository: digitalocean/artifactory-docker-resource
    tag: latest

Source configuration using raw AQL for item.find:

resources:
- name: myapplication
  type: artifactory
  icon: application-export
  source:
    endpoint: https://example.com/artifactory/
    user: ci
    password: ((artifactory.password))
    aql:
      raw: '{"repo": "docker-local", "path": {"$match" : "myapp/myimage/*"}, "name": "manifest.json"}'
    host: artifactory.example.com

Source configuration using repo, path, name:

resources:
- name: myapplication
  type: artifactory
  icon: application-export
  source:
    endpoint: https://example.com/artifactory/
    user: ci
    password: ((artifactory.password))
    aql:
      repo: docker-local
      image: myapp/myimage
      tag: '*'

Publishing artifacts to Artifactory:

- put: myapplication
  params:
    repo_path: code
    pattern: built/image.tar
    target: docker-local

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AQL

type AQL struct {
	Raw   string `json:"raw,omitempty"`   // Raw AQL to filter versions on
	Repo  string `json:"repo,omitempty"`  // Repo within Artifactory to search
	Image string `json:"image,omitempty"` // Image to match
	Tag   string `json:"tag,omitempty"`   // Tag of image to match, defaults to `latest`
}

AQL provides the version query structure

func (*AQL) SetModifiedTime

func (a *AQL) SetModifiedTime(v Version)

SetModifiedTime appends the version modified time to the raw AQL query

func (*AQL) UnmarshalJSON

func (a *AQL) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaller to convert PR number

type CheckRequest

type CheckRequest struct {
	Source  Source  `json:"source"`
	Version Version `json:"version"`
}

CheckRequest is the data struct received from Concoruse by the resource check operation

func (*CheckRequest) Read

func (r *CheckRequest) Read(input []byte) error

Read will read the json response from Concourse via stdin

type CheckResponse

type CheckResponse []Version

CheckResponse is the data struct returned to Concourse by the resource check operation

func Check

func Check(req CheckRequest) (CheckResponse, error)

Check performs the check operation for the resource

func (CheckResponse) Len

func (r CheckResponse) Len() int

Len returns the number of versions in the response

func (CheckResponse) Write

func (r CheckResponse) Write() error

Write will write the json response to stdout for Concourse to parse

type GetParameters

type GetParameters struct {
	Format       string `json:"format"`        // Format defaults to `rootfs` (used for task steps), to write image to tarball, use `oci`
	SkipDownload bool   `json:"skip_download"` // SkipDownload is used with `put` steps to skip `get` step that Concourse runs by default
}

GetParameters is the configuration for a resource step

type GetRequest

type GetRequest struct {
	Source  Source        `json:"source"`
	Version Version       `json:"version"`
	Params  GetParameters `json:"params"`
}

GetRequest is the data struct received from Concoruse by the resource get operation

func (*GetRequest) OCIRepository

func (r *GetRequest) OCIRepository() string

OCIRepository uses Source & Version to generate container registry compliant url

func (*GetRequest) Read

func (r *GetRequest) Read(input []byte) error

Read will read the json response from Concourse via stdin

type GetResponse

type GetResponse struct {
	Version  Version    `json:"version"`
	Metadata m.Metadata `json:"metadata,omitempty"`
}

GetResponse ...

func Get

func Get(req GetRequest, dir string) (GetResponse, error)

Get performs the get operation for the resource

func Put

func Put(req PutRequest, dir string) (GetResponse, error)

Put performs the Put operation for the resource

func (GetResponse) Write

func (r GetResponse) Write() error

Write will write the json response to stdout for Concourse to parse

type PutParameters

type PutParameters struct {
	Pattern        string        `json:"pattern"`               // Pattern to search inputs for image tarbull to push in GLOB form, e.g. `input/image.tar`
	Image          string        `json:"image"`                 // Image to push, e.g. owner/image
	Target         string        `json:"target,omitempty"`      // Target Artifactory repository, required if not using a Proxy
	Tags           []string      `json:"tags,omitempty"`        // Tags is the list of tags to apply to the image
	Properties     string        `json:"properties,omitempty"`  // Properties is file path containing image properties in `key=value\n` form
	Params         string        `json:"params,omitempty"`      // Params is a file path containing the Image struct in json syntax for dynamic workflows
	BuildEnv       string        `json:"build_env,omitempty"`   // BuildEnv is path to file containing build environment values in `key=value\n` form, e.g. `env > env.txt`
	EnvInclude     string        `json:"env_include,omitempty"` // EnvInclude case insensitive patterns in the form of "value1;value2;..." will be included
	EnvExclude     string        `json:"env_exclude,omitempty"` // EnvExclude case insensitive patterns in the form of "value1;value2;..." will be excluded, defaults to `*password*;*psw*;*secret*;*key*;*token*`
	RepositoryPath string        `json:"repo_path,omitempty"`   // RepositoryPath sets the path to the input containing the repository (git support only)
	Repository     string        `json:"repo,omitempty"`        // Repository set the Git repository url explicitly for compatibility with the Git resource
	Get            GetParameters `json:"get,omitempty"`         // Get parameters for explicit get step after put
}

PutParameters for the resource

func (*PutParameters) Parse

func (p *PutParameters) Parse() error

Parse reads a file and unmarshals into itself

type PutRequest

type PutRequest struct {
	Source Source        `json:"source"`
	Params PutParameters `json:"params"`
}

PutRequest is the data struct received from Concoruse by the resource put operation

func (*PutRequest) OCIRepository

func (r *PutRequest) OCIRepository() string

OCIRepository uses Source & Params to generate container registry compliant url

func (*PutRequest) Read

func (r *PutRequest) Read(input []byte) error

Read will read the json response from Concourse via stdin

type Source

type Source struct {
	Endpoint    string `json:"endpoint"`           // Endpoint for Artifactory AQL API (leave blank for cloud)
	User        string `json:"user,omitempty"`     // User for Artifactory API with permissions to Repository
	Password    string `json:"password,omitempty"` // Password for Artifactory API with permissions to Repository
	AccessToken string `json:"access_token"`       // AccessToken for Artifactory API with permissions to Repository
	APIKey      string `json:"api_key,omitempty"`  // APIKey for Artifactory API with permissions to Repository
	Host        string `json:"host"`               // Host is used to get / put the image via the Docker v2 registry api
	AQL         AQL    `json:"aql"`                // AQL details to search for
	Proxy       bool   `json:"proxy,omitempty"`    // Proxy if you are using a proxy, defaults to false & direct access, see: https://www.jfrog.com/confluence/display/JFROG/HTTP+Settings#HTTPSettings-DockerReverseProxySettings
}

Source represents the configuration for the resource

func (*Source) Validate

func (s *Source) Validate() error

Validate ensures that the source configuration is valid

type Version

type Version struct {
	Repo     string    `json:"repo,omitempty"`
	Image    string    `json:"image,omitempty"`
	Tag      string    `json:"tag,omitempty"`
	Digest   string    `json:"digest,omitempty"`
	Modified time.Time `json:"modified,omitempty"`
}

Version contains the version data Concourse uses to determine if a build should run

func (*Version) ArtifactoryPath

func (v *Version) ArtifactoryPath() string

ArtifactoryPath builds the internal path for an manifest based on the version

func (*Version) Empty

func (v *Version) Empty() bool

Empty returns true if the version is empty

func (*Version) ImageTag

func (v *Version) ImageTag() string

ImageTag returns the string needed to fetch the artifact

Directories

Path Synopsis
cmd
get
put

Jump to

Keyboard shortcuts

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