Skip to content

Commit

Permalink
make initial version configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
vito committed Sep 21, 2018
1 parent 72e46dc commit 6bf3d74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/check/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {
response = append(response, *req.Version)
} else if !req.Source.NoInitialVersion {
response = append(response, resource.Version{
Version: "mirror",
Version: req.Source.InitialVersion(),
})
}

Expand Down
14 changes: 14 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
package resource

const DefaultInitialVersion = "mirror"

type Source struct {
// fetch the resource itself as an image
MirrorSelf bool `json:"mirror_self"`

// initial version that the mirrored resource image should emit from /check
// (default: 'mirror')
RawInitialVersion string `json:"mirrored_version"`

// don't emit an initial version; useful for testing pipeline triggering
NoInitialVersion bool `json:"no_initial_version"`
}

func (s Source) InitialVersion() string {
if s.RawInitialVersion == "" {
return DefaultInitialVersion
}

return s.RawInitialVersion
}

type Version struct {
Version string `json:"version"`
}
Expand Down

0 comments on commit 6bf3d74

Please sign in to comment.