ofcourse

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 10 Imported by: 2

Documentation

Overview

Code generated for package ofcourse by go-bindata DO NOT EDIT. (@generated) sources: templates/Dockerfile templates/Makefile templates/README.md templates/cmd/check/main.go templates/cmd/in/main.go templates/cmd/out/main.go templates/go.mod templates/pipeline.yml templates/resource/resource.go templates/resource/resource_test.go

Package ofcourse reduces boilerplate for implementing Concourse resources.

Index

Constants

View Source
const (
	// SilentLevel for logging.
	SilentLevel = "silent"
	// ErrorLevel for logging.
	ErrorLevel = "error"
	// WarnLevel for logging.
	WarnLevel = "warn"
	// InfoLevel for logging.
	InfoLevel = "info"
	// DebugLevel for logging.
	DebugLevel = "debug"
)

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func Check

func Check(resource Resource)

Check takes an implementation of Resource as its input. The Main function for the /opt/resource/check command that is run by Concourse should create an instance of the resource and pass it to this function.

func EnvVarMap

func EnvVarMap() map[string]string

EnvVarMap returns the current environment as a map[string]string. This may be used for generating test environments based on the current environment.

func In

func In(resource Resource)

In takes an implementation of Resource as its input. The Main function for the /opt/resource/in command that is run by Concourse should create an instance of the resource and pass it to this function.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func Out

func Out(resource Resource)

Out takes an implementation of Resource as its input. The Main function for the /opt/resource/out command that is run by Concourse should create an instance of the resource and pass it to this function.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type CheckInput

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

CheckInput represents the stdin to an /opt/resource/check command.

type Environment

type Environment interface {
	Get(string, ...string) string
	GetAll() map[string]string
}

Environment represents the environment of a `check`, `in`, or `out` process. It is passed to Resource functions to enable easier testing than if calling `os.Getenv` within the function.

func NewEnvironment

func NewEnvironment(variables ...map[string]string) Environment

NewEnvironment returns the current environment, or one from the optional variables.

type InInput

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

InInput represents the stdin to an /opt/resource/in command.

type Logger

type Logger struct {
	Level int
}

Logger is passed to resource functions so that they can log to the Concourse UI without printing to stdout, as doing so would corrupt the JSON output expected by Concourse. Resources using this library may set their log level in the source configuration of the pipeline using the parameter `log_level`, which may have a case insensitive value of "error", "warn", "info", or "debug". Respective to those log levels, the output colors are red, yellow, green, and blue.

func NewLogger

func NewLogger(level string) *Logger

NewLogger returns a logger instance with the given log level, defaulting to "info" if the given level is not recognized.

func (*Logger) Debugf

func (l *Logger) Debugf(message string, args ...interface{})

Debugf logs a blue formatted string to the Concourse UI with newline.

func (*Logger) Errorf

func (l *Logger) Errorf(message string, args ...interface{})

Errorf logs a red formatted string to the Concourse UI with newline.

func (*Logger) Infof

func (l *Logger) Infof(message string, args ...interface{})

Infof logs a green formatted string to the Concourse UI with newline.

func (*Logger) Warnf

func (l *Logger) Warnf(message string, args ...interface{})

Warnf logs a yellow formatted string to the Concourse UI with newline.

type Metadata

type Metadata []NameVal

Metadata represents Concourse metadata, which is a set of key/value pairs that are used for printing extra information to the Concourse UI on `get` or `put`.

type NameVal

type NameVal struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

NameVal is one item of a Metadata array.

type OutInput

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

OutInput represents the stdin to an /opt/resource/out command.

type Params

type Params map[string]interface{}

Params is the pipeline `get` or `put` parameters for the resource.

type Resource

type Resource interface {
	Check(src Source, ver Version, env Environment, log *Logger) ([]Version, error)
	In(outDir string, src Source, par Params, ver Version, env Environment, log *Logger) (Version, Metadata, error)
	Out(inDir string, src Source, par Params, env Environment, log *Logger) (Version, Metadata, error)
}

Resource is a type that contains Check, In, and Out methods. The user of this library must implement this interface.

type Source

type Source map[string]interface{}

Source is the pipeline source configuration for the resource.

type Version

type Version map[string]string

Version represents Concourse a version, which is a set of key/value pairs.

Jump to

Keyboard shortcuts

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