mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-21 08:33:55 +00:00
a bit of cleanup
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
deploy
|
||||
.gitignore
|
||||
.git/*
|
||||
Dockerfile
|
||||
LICENSE
|
||||
Tiltfile
|
||||
|
||||
@@ -51,13 +51,13 @@ func (cv *ContainerValidation) addFailure(name, expected, actual string) {
|
||||
|
||||
func (cv *ContainerValidation) validateResources(conf conf.RequestsAndLimits) {
|
||||
actualRes := cv.Container.Resources
|
||||
cv.ensureWithinRange("requests.cpu", conf.Requests["cpu"], actualRes.Requests.Cpu())
|
||||
cv.ensureWithinRange("requests.memory", conf.Requests["memory"], actualRes.Requests.Memory())
|
||||
cv.ensureWithinRange("limits.cpu", conf.Limits["cpu"], actualRes.Limits.Cpu())
|
||||
cv.ensureWithinRange("limits.memory", conf.Limits["memory"], actualRes.Limits.Memory())
|
||||
cv.withinRange("requests.cpu", conf.Requests["cpu"], actualRes.Requests.Cpu())
|
||||
cv.withinRange("requests.memory", conf.Requests["memory"], actualRes.Requests.Memory())
|
||||
cv.withinRange("limits.cpu", conf.Limits["cpu"], actualRes.Limits.Cpu())
|
||||
cv.withinRange("limits.memory", conf.Limits["memory"], actualRes.Limits.Memory())
|
||||
}
|
||||
|
||||
func (cv *ContainerValidation) ensureWithinRange(resName string, expectedRange conf.ResourceMinMax, actual *resource.Quantity) {
|
||||
func (cv *ContainerValidation) withinRange(resName string, expectedRange conf.ResourceMinMax, actual *resource.Quantity) {
|
||||
expectedMin, err := resource.ParseQuantity(expectedRange.Min)
|
||||
if err != nil {
|
||||
log.Error(err, fmt.Sprintf("Error parsing min quantity for %s", resName))
|
||||
@@ -67,7 +67,7 @@ func (cv *ContainerValidation) ensureWithinRange(resName string, expectedRange c
|
||||
|
||||
expectedMax, err := resource.ParseQuantity(expectedRange.Max)
|
||||
if err != nil {
|
||||
log.Error(err, "Error parsing max quantity")
|
||||
log.Error(err, fmt.Sprintf("Error parsing max quantity for %s", resName))
|
||||
} else if expectedMax.MilliValue() < actual.MilliValue() {
|
||||
cv.addFailure(resName, expectedMax.String(), actual.String())
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ func (r *Results) Format() (bool, string) {
|
||||
r.Pass = true
|
||||
|
||||
for _, cv := range r.ContainerValidations {
|
||||
if !containerValidation(sb, cv) {
|
||||
if !validContainer(&sb, &cv) {
|
||||
r.Pass = false
|
||||
}
|
||||
}
|
||||
|
||||
for _, cv := range r.InitContainerValidations {
|
||||
if !containerValidation(sb, cv) {
|
||||
if !validContainer(&sb, &cv) {
|
||||
r.Pass = false
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ func (r *Results) Format() (bool, string) {
|
||||
return r.Pass, r.FailMsg
|
||||
}
|
||||
|
||||
func containerValidation(sb strings.Builder, cv ContainerValidation) bool {
|
||||
func validContainer(sb *strings.Builder, cv *ContainerValidation) bool {
|
||||
if len(cv.Failures) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user