Skip to content

Commit

Permalink
make PR comment changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JessicaGreben committed Jan 3, 2019
1 parent 6648ced commit 21e7d2b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
14 changes: 1 addition & 13 deletions deploy/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ data:
memory:
min: 10m
max: 2000M
ingresses:
whitelist:
- '*.example.com'
prevent_overlaps: true
healthchecks:
healthChecks:
readiness:
require: true
liveness:
Expand All @@ -90,14 +86,6 @@ data:
tagRequired: true
whitelistRepos:
- gcr.io
namespaces:
require_labels: true
security_context:
capabilities:
whitelist:
- 'CAP_SYS_ADMIN'
prevent_privileged: true
read_only_file_system: true
---
apiVersion: extensions/v1beta1
kind: Deployment
Expand Down
13 changes: 7 additions & 6 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type RequestsAndLimits struct {
// Configuration contains all of the config for the validation checks.
type Configuration struct {
Resources RequestsAndLimits
Healthchecks Probes
HealthChecks Probes
Images Images
}

Expand Down Expand Up @@ -59,13 +59,14 @@ func Parse(rawBytes []byte) (Configuration, error) {

// Probes contains config for the readiness and liveness probes.
type Probes struct {
Readiness resourceRequire
Liveness resourceRequire
Readiness ResourceRequire
Liveness ResourceRequire
}

type resourceRequire map[require]bool

type require string
// ResourceRequire indicates if this resource should be validated.
type ResourceRequire struct {
Require bool
}

// Images contains the config for images.
type Images struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

var resourceConfInvalid1 = `test`

var resourceConfYaml1 = `---
var resourceConfYAML1 = `---
resources:
requests:
cpu:
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestParseError(t *testing.T) {
}

func TestParseYaml(t *testing.T) {
parsedConf, err := Parse([]byte(resourceConfYaml1))
parsedConf, err := Parse([]byte(resourceConfYAML1))
assert.NoError(t, err, "Expected no error when parsing config")

requests := parsedConf.Resources.Requests
Expand Down
6 changes: 3 additions & 3 deletions pkg/validator/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func validateContainer(conf conf.Configuration, container corev1.Container) Cont
}

cv.validateResources(conf.Resources)
cv.validateHealthChecks(conf.Healthchecks)
cv.validateHealthChecks(conf.HealthChecks)
cv.validateImage(conf.Images)

return cv
Expand Down Expand Up @@ -68,10 +68,10 @@ func (cv *ContainerValidation) withinRange(resourceName string, expectedRange co
}

func (cv *ContainerValidation) validateHealthChecks(conf conf.Probes) {
if conf.Readiness["require"] && cv.Container.ReadinessProbe == nil {
if conf.Readiness.Require && cv.Container.ReadinessProbe == nil {
cv.addFailure("readiness", "probe needs to be configured", "nil")
}
if conf.Liveness["require"] && cv.Container.LivenessProbe == nil {
if conf.Liveness.Require && cv.Container.LivenessProbe == nil {
cv.addFailure("liveness", "probe needs to be configured", "nil")
}
}
Expand Down

0 comments on commit 21e7d2b

Please sign in to comment.