[][src]Trait concourse_resource::Resource

pub trait Resource {
    type Version: Serialize + DeserializeOwned;
    type Source: DeserializeOwned;
    type InParams: DeserializeOwned;
    type InMetadata: Serialize + IntoMetadataKV;
    type OutParams: DeserializeOwned;
    type OutMetadata: Serialize + IntoMetadataKV;
    fn resource_check(
        source: Option<Self::Source>,
        version: Option<Self::Version>
    ) -> Vec<Self::Version>;
fn resource_in(
        source: Option<Self::Source>,
        version: Self::Version,
        params: Option<Self::InParams>,
        output_path: &str
    ) -> Result<InOutput<Self::Version, Self::InMetadata>, Box<dyn Error>>;
fn resource_out(
        source: Option<Self::Source>,
        params: Option<Self::OutParams>,
        input_path: &str
    ) -> OutOutput<Self::Version, Self::OutMetadata>; fn build_metadata() -> BuildMetadata { ... } }

The methods and associated types needed to implement a resource

Associated Types

type Version: Serialize + DeserializeOwned

A version of the resource

type Source: DeserializeOwned

Resource configuration, from the source field

type InParams: DeserializeOwned

Parameters for the "in" step, from the params field

type InMetadata: Serialize + IntoMetadataKV

A list of key-value pairs for the "in" step. This data is intended for public consumption and will make it upstream, intended to be shown on the build's page.

type OutParams: DeserializeOwned

Parameters for the "out" step, from the params field

type OutMetadata: Serialize + IntoMetadataKV

A list of key-value pairs for the "out" step. This data is intended for public consumption and will make it upstream, intended to be shown on the build's page.

Loading content...

Required methods

fn resource_check(
    source: Option<Self::Source>,
    version: Option<Self::Version>
) -> Vec<Self::Version>

A resource type's check method is invoked to detect new versions of the resource. It is given the configured source and current version, and must return the array of new versions, in chronological order, including the requested version if it's still valid.

Concourse documentation

fn resource_in(
    source: Option<Self::Source>,
    version: Self::Version,
    params: Option<Self::InParams>,
    output_path: &str
) -> Result<InOutput<Self::Version, Self::InMetadata>, Box<dyn Error>>

The in method is passed the configured source, a precise version of the resource to fetch and a destination directory. The method 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 method must return an error.

The method must return the fetched version, and may return 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.

Concourse documentation

fn resource_out(
    source: Option<Self::Source>,
    params: Option<Self::OutParams>,
    input_path: &str
) -> OutOutput<Self::Version, Self::OutMetadata>

The out method is called with the resource's source configuration, the configured params and a path to the directory containing the build's full set of sources.

The script must return the resulting version of the resource. Additionally, it may return 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.

Concourse documentation

Loading content...

Provided methods

fn build_metadata() -> BuildMetadata

When used in a "get" or "put" step, will return metadata about the running build is made available via environment variables.

Concourse documentation

Loading content...

Implementors

Loading content...