Trait concourse_resource::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;
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 { ... }
}
Expand description
The methods and associated types needed to implement a resource
Associated Types
type Version: Serialize + DeserializeOwned
type Version: Serialize + DeserializeOwned
A version of the resource
type Source: DeserializeOwned
type Source: DeserializeOwned
Resource configuration, from the source
field
Parameters for the “in” step, from the params
field
type InMetadata: Serialize + IntoMetadataKV
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.
Parameters for the “out” step, from the params
field
type OutMetadata: Serialize + IntoMetadataKV
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
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.
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.
fn resource_out(
source: Option<Self::Source>,
params: Option<Self::OutParams>,
input_path: &str
) -> OutOutput<Self::Version, Self::OutMetadata>
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.
Provided methods
fn build_metadata() -> BuildMetadata
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.