Resource

Trait Resource 

Source
pub trait Resource {
    type Version: Serialize + DeserializeOwned;
    type Source: DeserializeOwned;
    type InParams: DeserializeOwned;
    type InMetadata: Serialize + IntoMetadataKV;
    type OutParams: DeserializeOwned;
    type OutMetadata: Serialize + IntoMetadataKV;

    // Required methods
    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>;

    // Provided method
    fn build_metadata() -> BuildMetadata { ... }
}
Expand description

The methods and associated types needed to implement a resource

Required Associated Types§

Source

type Version: Serialize + DeserializeOwned

A version of the resource

Source

type Source: DeserializeOwned

Resource configuration, from the source field

Source

type InParams: DeserializeOwned

Parameters for the “in” step, from the params field

Source

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.

Source

type OutParams: DeserializeOwned

Parameters for the “out” step, from the params field

Source

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.

Required Methods§

Source

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

Source

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

Source

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

Provided Methods§

Source

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§