Created
July 20, 2020 23:16
-
-
Save bkeroackdsc/39705f8e05e5c8462afdfdbf1cdad755 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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