Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Version models a specific version of a software package
type Version struct {
SemVersion string // this could probably be structured if we care about major vs minor vs patchlevel
Released time.Time
}
// VersionChecker describes an object that can check if a version of software is out of date with upstream
type VersionChecker interface {
// Check returns whether currentVersion is out-of-date and returns the newest available version, or error
Check(currentVersion Version) (outdated bool, newestVersion Version, err error)
// Name returns the name of the software being checked
Name() string
}
var modules = []VersionChecker{
// insert "modules" here
&k8s.Checker,
&vault.Checker,
&redis.Checker,
}
func CheckAllVersions(currentVersions map[string]Version) {
for _, m := range modules {
outdated, newest, err := m.Check(currentVersions[m.Name()])
if err != nil {
// handle error
}
if outdated {
fmt.Printf("%v is out of date! We need to upgrade to %v\n", m.Name(), newest.SemVersion)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment