Skip to content

Commit

Permalink
Merge #291
Browse files Browse the repository at this point in the history
291: score/stable: recommend Ingress networking.k8s.io/v1beta1 r=zegl a=zegl

```
RELNOTE: If using Kubernetes v1.14 or later, recommend to use the networking.k8s.io/v1beta1 Ingress API instead of extensions/v1beta1
```


Co-authored-by: Gustav Westling <[email protected]>
  • Loading branch information
bors[bot] and zegl authored Aug 10, 2020
2 parents 56fc1b4 + 367340d commit 5c3ed1b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"errors"
"fmt"
"io"
"strconv"
"strings"
Expand Down Expand Up @@ -65,3 +66,7 @@ func (s Semver) LessThan(other Semver) bool {
}
return false
}

func (s Semver) String() string {
return fmt.Sprintf("v%d.%d", s.Major, s.Minor)
}
3 changes: 2 additions & 1 deletion score/stable/stable_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func metaStableAvailable(kubernetsVersion config.Semver) func(meta domain.BothMe
"extensions/v1beta1": {
"Deployment": recommendedApi{"apps/v1", config.Semver{1, 9}},
"DaemonSet": recommendedApi{"apps/v1", config.Semver{1, 9}},
"Ingress": recommendedApi{"networking.k8s.io/v1beta1", config.Semver{1, 14}},
},
"apps/v1beta1": {
"Deployment": recommendedApi{"apps/v1", config.Semver{1, 9}},
Expand All @@ -51,7 +52,7 @@ func metaStableAvailable(kubernetsVersion config.Semver) func(meta domain.BothMe
score.Grade = scorecard.GradeWarning
score.AddComment("",
fmt.Sprintf("The apiVersion and kind %s/%s is deprecated", meta.TypeMeta.APIVersion, meta.TypeMeta.Kind),
fmt.Sprintf("It's recommended to use %s instead", recAPI.newAPI),
fmt.Sprintf("It's recommended to use %s instead which has been available since Kubernetes %s", recAPI.newAPI, recAPI.availableSince.String()),
)
return
}
Expand Down
9 changes: 8 additions & 1 deletion score/stable/stable_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@ func TestStableVersionNewKubernetesVersion(t *testing.T) {
newKubernetes := metaStableAvailable(config.Semver{1, 18})
scoreNew := newKubernetes(ks.BothMeta{TypeMeta: v1.TypeMeta{Kind: "Deployment", APIVersion: "extensions/v1beta1"}})
assert.Equal(t, scorecard.GradeWarning, scoreNew.Grade)
assert.Equal(t, []scorecard.TestScoreComment{{Path: "", Summary: "The apiVersion and kind extensions/v1beta1/Deployment is deprecated", Description: "It's recommended to use apps/v1 instead", DocumentationURL: ""}}, scoreNew.Comments)
assert.Equal(t, []scorecard.TestScoreComment{{Path: "", Summary: "The apiVersion and kind extensions/v1beta1/Deployment is deprecated", Description: "It's recommended to use apps/v1 instead which has been available since Kubernetes v1.9", DocumentationURL: ""}}, scoreNew.Comments)
}

func TestStableVersionIngress(t *testing.T) {
newKubernetes := metaStableAvailable(config.Semver{1, 18})
scoreNew := newKubernetes(ks.BothMeta{TypeMeta: v1.TypeMeta{Kind: "Ingress", APIVersion: "extensions/v1beta1"}})
assert.Equal(t, scorecard.GradeWarning, scoreNew.Grade)
assert.Equal(t, []scorecard.TestScoreComment{{Path: "", Summary: "The apiVersion and kind extensions/v1beta1/Ingress is deprecated", Description: "It's recommended to use networking.k8s.io/v1beta1 instead which has been available since Kubernetes v1.14", DocumentationURL: ""}}, scoreNew.Comments)
}

0 comments on commit 5c3ed1b

Please sign in to comment.