This is a concourse resource type that records the versions of other concourse resources ("sub-resources") in a git repository, and then allows this collection of versions to be "replayed" later or elsewhere.
Notionally it "packs" these resource versions into a "bag" from which they can later be "unpacked".
This can be used to create deployments that have greater control and certainty over the exact set of resource versions used to perform a particular deployment. With bag-resource, a problematic deployment can have all of its inputs rolled-back together to a the last known-good set of input versions using a single resource pin (or unticking). A deployment that was successful on one pipeline can be marked as such with a single tag on the bag's git repository revision and the deployment can then be reproduced in another pipeline.
The bag-resource attempts to bring some of the deployment-time advantages of a monorepo for non-monorepo projects and projects that have a mixture of input types that don't necessarily fit into a git repository.
Though the bag-resource is designed to pack arbitrary other resource types, those resource types need to be specified at image build time and it has currently only been tested with the git resource and the registry-image resource.
The bag-resource embeds copies of the supported resource types' container images
in sub-directories and forwards calls to their in
, out
and check
scripts using
proot
with parameters adjusted accordingly.
Resource versions are recorded in the bag repository using the version
json format
of the underlying resource (as used to communicate versions
between the check
and in
scripts). This makes it agnostic of the underlying resource
type.
A bag-resource can operate in one of two modes: "bag" mode and "proxy" mode, with "proxy" mode being a light wrapper around a single underlying resource that gives it the ability to be used as an input when packing a bag-resource in "bag" mode.
-
bag_repo
: thegit-resource
configuration for the "bag" repository. The contents of this are forwarded directly togit-resource
'ssource
section when attempting to access the "bag" repository. Supplying this key implies this resource is working in "bag" mode. Required in "bag" mode. -
subresources
: a mapping of (subresource-name) to (subresource-configuration). A "subresource" describes one of the resources contained by the bag. Supplying this key implies this resource is working in "bag" mode. Required in "bag" mode.- (subresource-name):
type
: currently eithergit
orregistry-image
. Required.source
: thesource
section to be passed to the underlying resource when performing aget
(anin
script call) of the subresource. This should include the details required to access the resource (e.g. location and credentials), but this should be unrestricted in which versions it can fetch, because version selection is the responsibility of the resource (likely another bag-resource inproxy
mode) that's used to feed the "packing" of the bag. In fact, many keys which resources use to select versions are only used in thecheck
phase and placed in this section they would have no effect, this section only being used in theget
phase. To prevent any potential confusion, some keys are specifically disallowed from this section (see disallowed-subresource-source-keys). Required.
- (subresource-name):
-
proxy
: operate this bag-resource in "proxy" mode where it simply augments the capabilities of a single underlying resource.type
: currently eithergit
orregistry-image
. Required.source
: passed directly as thesource
of the underlying resource. Required.
In "bag" mode this checks for new commits to the bag_repo
.
In "proxy" mode this is handled by the proxied resource.
In "bag" mode this will fetch the appropriate revision of the bag_repo
and then populate
the output directory with it (under the bag_repo/
or .bag_repo/
directories) and then,
based on the versions recorded in bag repository checkout, fetch any requested subresources
to the output directory.
subresources
: a mapping of (subresource-name) to (subresource-configuration). Without this, only thebag_repo
will be fetched.- (subresource-name):
flatten
: boolean - iftrue
, this sub-resource will be fetched directly to the root of the output directory. Only a single subresource can be fetched in this case. This was created so thatregistry-image
subresources could be fetched inrootfs
format and fed directly to concourse as a task-step image, concourse being extremely fussy about being given an output name here, not allowing sub-directories to be specified. The bag repository is placed in.bag_repo/
if flattening. Defaultfalse
.params
: passed through to underlying resource. Default{}
.
- (subresource-name):
Tip
While it's possible to list multiple subresources to be fetched in one get
operation, this
will be done serially. So it's often better to perform several separate get
operations in
an in_parallel
block, as it will also result in clearer error messages if one subresource
is to fail. This is at the expense of greater number of bag_repo
fetches.
In "proxy" mode, either a regular fetch of the underlying resource can be performed or the version information can be exposed for use in bag-packing.
version_only
: boolean - iftrue
, instead of fetching the actual underlying resource, the contents of thein
call'sversion
field will be serialized to the output directory under the filenameversion.json
. This can then be used to assemble a new bag revision in theput
operation of a bag-resource inbag
mode. Defaultfalse
proxy
: contents passed through toparams
of underlying proxied resource for performing a regular fetch.
In "bag" mode this will optionally assemble a new bag revision and push this revision to a
remote repository, operating similarly to how put
ting to a git-resource works
-
path
: for assembling a new bag revision, this specifies the path of a directory to which a bag resource has previously been fetched (not inproxy
orflatten
mode - abag_repo
subdirectory is expected to be found). Whenpath
is specified, theput
phase will look for each subresource'sversion.json
under a directory with the same name as the subresource. These will then be assembled, committed and pushed to the remotebag_repo
. -
bag_repo
: parameters passed to theparams
of the underlying git-resource when pushing to the remote bag repository.- (arbitrary parameters)
repository
: if therepository
key is provided, the automatic bag-packing procedure is skipped and it is assumed thatrepository
points to a manually prepared directory for pushing to thebag_repo
. In this case operation is identical to git-resource'sput
. Notably, no checking will be performed for the validity of the contents.
In "proxy" mode a regular push to the underlying resource will be performed.
proxy
: contents passed through toparams
of underlying proxied resource for performing a regularput
.