Skip to content

Instantly share code, notes, and snippets.

@bkeroackdsc
Created July 20, 2020 23:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bkeroackdsc/39705f8e05e5c8462afdfdbf1cdad755 to your computer and use it in GitHub Desktop.
// 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