prometheus_version.rego 710 B

12345678910111213141516171819202122232425
  1. package prometheus.version
  2. import future.keywords
  3. POLICY_ID := "prometheus_version"
  4. POLICY_VERSION := "v0.0.1"
  5. POLICY_SEVERITY := "high"
  6. latest_stable_version := "15.5.3"
  7. POLICY_TITLE := sprintf("The Prometheus version should be at least v%s", [latest_stable_version])
  8. POLICY_SUCCESS_MESSAGE := sprintf("Success: Prometheus version is up-to-date", [])
  9. trimmedVersion := trim_left(input.version, "v")
  10. # semver.compare returns -1 if latest_stable_version < trimmedVersion
  11. allow if semver.compare(latest_stable_version, trimmedVersion) <= 0
  12. FAILURE_MESSAGE contains msg if {
  13. not allow
  14. msg := sprintf("Failed: latest stable version is %s, but you are on %s", [latest_stable_version, trimmedVersion])
  15. }