diff --git a/cmd/check/main.go b/cmd/check/main.go index 9c89c97..508fc6b 100644 --- a/cmd/check/main.go +++ b/cmd/check/main.go @@ -33,6 +33,10 @@ func main() { if req.Version != nil { response = append(response, *req.Version) + } else if !req.Source.NoInitialVersion { + response = append(response, resource.Version{ + Version: "mirror", + }) } json.NewEncoder(os.Stdout).Encode(response) diff --git a/cmd/in/main.go b/cmd/in/main.go index 7f9df5a..135d78d 100644 --- a/cmd/in/main.go +++ b/cmd/in/main.go @@ -12,8 +12,9 @@ import ( ) type InRequest struct { - Source resource.Source `json:"source"` - Version resource.Version `json:"version"` + Source resource.Source `json:"source"` + Version resource.Version `json:"version"` + Params resource.GetParams `json:"params"` } type InResponse struct { @@ -56,7 +57,7 @@ func main() { return } - if req.Source.FetchImage { + if req.Source.MirrorSelf || req.Params.MirrorSelfViaParams { replicateTo(filepath.Join(dest, "rootfs")) encTo(filepath.Join(dest, "metadata.json"), ImageMetadata{ diff --git a/types.go b/types.go index 48f1a15..f15aaae 100644 --- a/types.go +++ b/types.go @@ -1,13 +1,23 @@ package resource type Source struct { - FetchImage bool `json:"fetch_image"` + // fetch the resource itself as an image + MirrorSelf bool `json:"mirror_self"` + + // don't emit an initial version; useful for testing pipeline triggering + NoInitialVersion bool `json:"no_initial_version"` } type Version struct { Version string `json:"version"` } +type GetParams struct { + // same as configuring MirrorSelf in source, but in params, so that we can + // test params are respected in places + MirrorSelfViaParams bool `json:"mirror_self_via_params"` +} + type MetadataField struct { Name string `json:"name"` Value string `json:"value"`