Skip to content

Commit

Permalink
fetch_image -> mirror_self, add no_initial_version
Browse files Browse the repository at this point in the history
also support mirroring self via params
  • Loading branch information
vito committed Sep 21, 2018
1 parent abb8a50 commit 72e46dc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions cmd/check/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions cmd/in/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down
12 changes: 11 additions & 1 deletion types.go
Original file line number Diff line number Diff line change
@@ -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"`
Expand Down

0 comments on commit 72e46dc

Please sign in to comment.