Documentation ¶
Index ¶
- Constants
- Variables
- func BuildInfo() string
- func Check(log hclog.Logger, input []byte, out io.Writer, args []string) error
- func Get(log hclog.Logger, input []byte, out io.Writer, args []string) error
- func MergeAndValidateSinks(sourceSinks []string, paramsSinks []string) (*sets.Set[string], error)
- func Put(log hclog.Logger, input []byte, out io.Writer, args []string, putter Putter) error
- type BuildState
- type CheckRequest
- type Environment
- type GetRequest
- type GitHubCommitStatusSink
- type GoogleChatSink
- type Metadata
- type Output
- type ProdPutter
- type PutParams
- type PutRequest
- type Putter
- type Sinker
- type Source
- type Version
Constants ¶
const KeyState = "state"
Variables ¶
var DummyVersion = Version{Ref: "dummy"}
DummyVersion is the version always returned by the Cogito resource. DO NOT REASSIGN!
Functions ¶
func BuildInfo ¶
func BuildInfo() string
BuildInfo returns human-readable build information (tag, git commit, date, ...). This is useful to understand in the Concourse UI and logs which resource it is, since log output in Concourse doesn't mention the name of the resource (or task) generating it.
func Check ¶
Check implements the "check" step (the "check" executable). For the Cogito resource, this is a no-op.
From https://concourse-ci.org/implementing-resource-types.html#resource-check:
A resource type's check script is invoked to detect new versions of the resource. It is given the configured source and current version on stdin, and must print the array of new versions, in chronological order (oldest first), to stdout, including the requested version if it is still valid.
func Get ¶
Get implements the "get" step (the "in" executable). For the Cogito resource, this is a no-op.
From https://concourse-ci.org/implementing-resource-types.html#resource-in:
The program is passed a destination directory as command line argument $1, and is given on stdin the configured source and a version of the resource to fetch.
The program must fetch the resource and place it in the given directory.
If the desired resource version is unavailable (for example, if it was deleted), the script must exit with error.
The program must emit a JSON object containing the fetched version, and may emit metadata as a list of key-value pairs. This data is intended for public consumption and will be shown on the build page.
func MergeAndValidateSinks ¶ added in v0.9.0
MergeAndValidateSinks returns an error if the user set an unsupported sink in source or put.params. If validation passes, it return the list of sinks to address: - return sinks in put.params if found. - return sinks in source if found. - return all supported sinks.
func Put ¶
Put implements the "put" step (the "out" executable).
From https://concourse-ci.org/implementing-resource-types.html#resource-out:
The out script is passed a path to the directory containing the build's full set of inputs as command line argument $1, and is given on stdin the configured params and the resource's source configuration.
The script must emit the resulting version of the resource.
Additionally, the script may emit metadata as a list of key-value pairs. This data is intended for public consumption and will make it upstream, intended to be shown on the build's page.
Types ¶
type BuildState ¶
type BuildState string
BuildState is a pseudo-enum representing the valid values of PutParams.State
const ( StateAbort BuildState = "abort" StateError BuildState = "error" StateFailure BuildState = "failure" StatePending BuildState = "pending" StateSuccess BuildState = "success" )
NOTE: this list must be kept in sync with the custom JSON methods of BuildState.
func (BuildState) MarshalJSON ¶ added in v0.8.1
func (bs BuildState) MarshalJSON() ([]byte, error)
func (*BuildState) UnmarshalJSON ¶ added in v0.8.1
func (bs *BuildState) UnmarshalJSON(data []byte) error
type CheckRequest ¶
type CheckRequest struct { Source Source `json:"source"` // Concourse will omit field Version from the first request. Version Version `json:"version"` Env Environment }
CheckRequest contains the JSON object passed on the stdin of the "check" executable (Source and Version) and the build metadata (Env, environment variables). Use NewCheckRequest to instantiate.
See https://concourse-ci.org/implementing-resource-types.html#resource-check
func NewCheckRequest ¶ added in v0.8.2
func NewCheckRequest(input []byte) (CheckRequest, error)
NewCheckRequest returns a CheckRequest ready to be used.
type Environment ¶
type Environment struct { BuildId string BuildName string BuildJobName string BuildPipelineName string BuildPipelineInstanceVars string BuildTeamName string BuildCreatedBy string AtcExternalUrl string }
Environment represents the environment variables made available to the program. Depending on the type of build and on the step, only some variables could be set. See https://concourse-ci.org/implementing-resource-types.html#resource-metadata
func (*Environment) Fill ¶
func (env *Environment) Fill()
Fill fills Environment by reading the associated environment variables.
type GetRequest ¶
type GetRequest struct { Source Source `json:"source"` Version Version `json:"version"` // Cogito does not support get params; a resource supporting them would have the // following line uncommented: // Params GetParams `json:"params"` Env Environment }
GetRequest contains the JSON object passed on the stdin of the "request" executable (Source and Version) and the build metadata (Env, environment variables). Use NewGetRequest to instantiate.
See https://concourse-ci.org/implementing-resource-types.html#resource-in
func NewGetRequest ¶ added in v0.8.2
func NewGetRequest(input []byte) (GetRequest, error)
NewGetRequest returns a GetRequest ready to be used.
type GitHubCommitStatusSink ¶
type GitHubCommitStatusSink struct { Log hclog.Logger GitRef string Request PutRequest }
GitHubCommitStatusSink is an implementation of Sinker for the Cogito resource.
func (GitHubCommitStatusSink) Send ¶
func (sink GitHubCommitStatusSink) Send() error
Send sets the build status via the GitHub Commit status API endpoint.
type GoogleChatSink ¶
type GoogleChatSink struct { Log hclog.Logger InputDir fs.FS GitRef string Request PutRequest }
GoogleChatSink is an implementation of Sinker for the Cogito resource.
func (GoogleChatSink) Send ¶
func (sink GoogleChatSink) Send() error
Send sends a message to Google Chat if the configuration matches.
type Metadata ¶
Metadata is an element of a list of indirect k/v pairs, part of the Concourse protocol.
Note that Concourse confusingly uses the term "metadata" for two completely different concepts: (1) the environment variables made available from Concourse to the check, get and put steps and (2) the metadata k/v map outputted by the get and put steps.
type ProdPutter ¶
type ProdPutter struct { Request PutRequest InputDir string // contains filtered or unexported fields }
ProdPutter is an implementation of a Putter for the Cogito resource. Use NewPutter to create an instance.
func NewPutter ¶
func NewPutter(log hclog.Logger) *ProdPutter
NewPutter returns a Cogito ProdPutter.
func (*ProdPutter) LoadConfiguration ¶
func (putter *ProdPutter) LoadConfiguration(input []byte, args []string) error
func (*ProdPutter) ProcessInputDir ¶
func (putter *ProdPutter) ProcessInputDir() error
func (*ProdPutter) Sinks ¶
func (putter *ProdPutter) Sinks() []Sinker
type PutParams ¶
type PutParams struct { // // Mandatory // State BuildState `json:"state"` // // Optional // Context string `json:"context"` ChatMessage string `json:"chat_message"` ChatMessageFile string `json:"chat_message_file"` ChatAppendSummary bool `json:"chat_append_summary"` GChatWebHook string `json:"gchat_webhook"` // SENSITIVE Sinks []string `json:"sinks"` }
PutParams is the "params:" block in a pipeline put step for the Cogito resource.
type PutRequest ¶
type PutRequest struct { Source Source `json:"source"` Params PutParams `json:"params"` Env Environment }
PutRequest contains the JSON object passed to the stdin of the "out" executable (Source and Params) and the build metadata (Env, environment variables). Use NewPutRequest to instantiate.
See https://concourse-ci.org/implementing-resource-types.html#resource-out
func NewPutRequest ¶ added in v0.8.2
func NewPutRequest(input []byte) (PutRequest, error)
NewPutRequest returns a PutRequest ready to be used.
func (*PutRequest) UnmarshalJSON ¶ added in v0.8.1
func (req *PutRequest) UnmarshalJSON(data []byte) error
type Putter ¶
type Putter interface { // LoadConfiguration parses the resource source configuration and put params. LoadConfiguration(input []byte, args []string) error // ProcessInputDir validates and extract the needed information from the "put input". ProcessInputDir() error // Sinks return the list of configured sinks. Sinks() []Sinker // Output emits the version and metadata required by the Concourse protocol. Output(out io.Writer) error }
Putter represents the put step of a Concourse resource. Note: The methods will be called in the same order as they are listed here.
type Sinker ¶
type Sinker interface { // Send posts the information extracted by the Putter to a specific sink. Send() error }
Sinker represents a sink: an endpoint to send a message.
type Source ¶
type Source struct { // // Mandatory // Owner string `json:"owner"` Repo string `json:"repo"` AccessToken string `json:"access_token"` // SENSITIVE // // Optional // GhHostname string `json:"github_hostname"` GChatWebHook string `json:"gchat_webhook"` // SENSITIVE LogLevel string `json:"log_level"` LogUrl string `json:"log_url"` // DEPRECATED ContextPrefix string `json:"context_prefix"` ChatAppendSummary bool `json:"chat_append_summary"` ChatNotifyOnStates []BuildState `json:"chat_notify_on_states"` Sinks []string `json:"sinks"` }
Source is the "source:" block in a pipeline "resources:" block for the Cogito resource.
func (*Source) UnmarshalJSON ¶ added in v0.8.1
UnmarshalJSON is used to set some default values of the struct. See https://www.orsolabs.com/post/go-json-default-values/