Skip to content

Commit

Permalink
Merge #172
Browse files Browse the repository at this point in the history
172: gofmt -w -s . r=zegl a=zegl



Co-authored-by: Gustav Westling <[email protected]>
  • Loading branch information
bors[bot] and zegl authored Aug 18, 2019
2 parents 1fff23b + b13d11c commit 4733785
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 36 deletions.
11 changes: 9 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ jobs:
working_directory: /go/app
steps:
- checkout
- run: go test -race -coverprofile=coverage.txt -covermode=atomic -coverpkg github.com/zegl/kube-score/... -v github.com/zegl/kube-score/...
- run: bash <(curl -s https://codecov.io/bash)
- run:
name: "Run go test"
command: go test -race -coverprofile=coverage.txt -covermode=atomic -coverpkg github.com/zegl/kube-score/... -v github.com/zegl/kube-score/...
- run:
name: "Enforce Go Formatted Code"
command: "! go fmt github.com/zegl/kube-score/... 2>&1 | read"
- run:
name: "Upload test coverage results"
command: bash <(curl -s https://codecov.io/bash)

workflows:
version: 2
Expand Down
2 changes: 0 additions & 2 deletions cmd/kube-score/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,6 @@ func outputHumanStep(card scorecard.TestScore, verboseOutput int, termWidth int)

fmt.Fprint(w, comment.Summary)



if len(comment.Description) > 0 {
wrapper := wordwrap.Wrapper(termWidth-12, false)
wrapped := wrapper(comment.Description)
Expand Down
2 changes: 0 additions & 2 deletions cmd/kube-score/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,5 +353,3 @@ func TestHumanOutputLogDescription80Width(t *testing.T) {
nisl venenatis, elementum augue a, porttitor libero.
`, string(all))
}


2 changes: 1 addition & 1 deletion parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func decodeItem(cnf config.Configuration, s *parsedObjects, detectedVersion sche
decode(fileContents, &hpa)
s.horizontalPodAutoscalers = append(s.horizontalPodAutoscalers, hpa)
s.bothMetas = append(s.bothMetas, ks.BothMeta{hpa.TypeMeta, hpa.ObjectMeta})

default:
if cnf.VerboseOutput > 1 {
log.Printf("Unknown datatype: %s", detectedVersion.String())
Expand Down
33 changes: 16 additions & 17 deletions score/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ func TestOkAllTheSameContainerResourceRequestsEqualLimits(t *testing.T) {
Name: "foo",
Resources: corev1.ResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
Limits: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
},
Expand All @@ -47,11 +47,11 @@ func TestOkMultipleContainersContainerResourceRequestsEqualLimits(t *testing.T)
Name: "foo",
Resources: corev1.ResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
Limits: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
},
Expand All @@ -62,11 +62,11 @@ func TestOkMultipleContainersContainerResourceRequestsEqualLimits(t *testing.T)
Name: "foo",
Resources: corev1.ResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
Limits: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
},
Expand All @@ -75,11 +75,11 @@ func TestOkMultipleContainersContainerResourceRequestsEqualLimits(t *testing.T)
Name: "foo2",
Resources: corev1.ResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
Limits: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
},
Expand All @@ -102,11 +102,11 @@ func TestOkSameQuantityContainerResourceRequestsEqualLimits(t *testing.T) {
Name: "foo",
Resources: corev1.ResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
Limits: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1000m"),
"cpu": resource.MustParse("1000m"),
"memory": resource.MustParse("0.25Gi"),
},
},
Expand All @@ -129,11 +129,11 @@ func TestFailBothContainerResourceRequestsEqualLimits(t *testing.T) {
Name: "foo",
Resources: corev1.ResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
Limits: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("2"),
"cpu": resource.MustParse("2"),
"memory": resource.MustParse("512Mi"),
},
},
Expand All @@ -153,7 +153,6 @@ func TestFailBothContainerResourceRequestsEqualLimits(t *testing.T) {
assert.Equal(t, "Having equal requests and limits is recommended to avoid resource DDOS of the node during spikes. Set resources.requests.memory == resources.limits.memory", s.Comments[1].Description)
}


func TestFailCpuInitContainerResourceRequestsEqualLimits(t *testing.T) {
s := containerResourceRequestsEqualLimits(
corev1.PodTemplateSpec{
Expand All @@ -163,11 +162,11 @@ func TestFailCpuInitContainerResourceRequestsEqualLimits(t *testing.T) {
Name: "init",
Resources: corev1.ResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
Limits: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("2"),
"cpu": resource.MustParse("2"),
"memory": resource.MustParse("256Mi"),
},
},
Expand All @@ -178,11 +177,11 @@ func TestFailCpuInitContainerResourceRequestsEqualLimits(t *testing.T) {
Name: "foo",
Resources: corev1.ResourceRequirements{
Requests: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
Limits: map[corev1.ResourceName]resource.Quantity{
"cpu": resource.MustParse("1"),
"cpu": resource.MustParse("1"),
"memory": resource.MustParse("256Mi"),
},
},
Expand Down
4 changes: 2 additions & 2 deletions score/disruptionbudget/disruptionbudget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestStatefulSetReplicas(t *testing.T) {
skipped bool
}{
nil: {scorecard.GradeCritical, false}, // failed
intptr(1): {0, true}, // skipped
intptr(1): {0, true}, // skipped
intptr(10): {scorecard.GradeCritical, false}, // failed
}

Expand All @@ -40,7 +40,7 @@ func TestDeploymentReplicas(t *testing.T) {
skipped bool
}{
nil: {scorecard.GradeCritical, false}, // failed
intptr(1): {0, true}, // skipped
intptr(1): {0, true}, // skipped
intptr(10): {scorecard.GradeCritical, false}, // failed
}

Expand Down
16 changes: 6 additions & 10 deletions score/hpa/hpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestHpaHasTarget(t *testing.T) {
},
allTargets: []domain.BothMeta{
{
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1",},
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1"},
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
},
},
Expand All @@ -64,14 +64,13 @@ func TestHpaHasTarget(t *testing.T) {
},
allTargets: []domain.BothMeta{
{
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1",},
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1"},
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "foospace"},
},
},
expectedGrade: scorecard.GradeAllOK,
},


// No match (namespace)
{
hpa: v1.HorizontalPodAutoscaler{
Expand All @@ -86,14 +85,13 @@ func TestHpaHasTarget(t *testing.T) {
},
allTargets: []domain.BothMeta{
{
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1",},
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1"},
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "foospace"},
},
},
expectedGrade: scorecard.GradeCritical,
},


// No match (name)
{
hpa: v1.HorizontalPodAutoscaler{
Expand All @@ -108,14 +106,13 @@ func TestHpaHasTarget(t *testing.T) {
},
allTargets: []domain.BothMeta{
{
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1",},
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1"},
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "foospace"},
},
},
expectedGrade: scorecard.GradeCritical,
},


// No match (kind)
{
hpa: v1.HorizontalPodAutoscaler{
Expand All @@ -130,14 +127,13 @@ func TestHpaHasTarget(t *testing.T) {
},
allTargets: []domain.BothMeta{
{
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1",},
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1"},
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "foospace"},
},
},
expectedGrade: scorecard.GradeCritical,
},


// No match (version)
{
hpa: v1.HorizontalPodAutoscaler{
Expand All @@ -152,7 +148,7 @@ func TestHpaHasTarget(t *testing.T) {
},
allTargets: []domain.BothMeta{
{
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1",},
TypeMeta: metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1"},
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "foospace"},
},
},
Expand Down

0 comments on commit 4733785

Please sign in to comment.