added more deprecated APIs

Signed-off-by: Matt Butcher <matt.butcher@microsoft.com>
pull/7986/head
Matt Butcher 6 years ago
parent a4150707a5
commit 2d1ce6d786
No known key found for this signature in database
GPG Key ID: DCD5F5E5EF32C345

@ -18,17 +18,24 @@ package rules // import "helm.sh/helm/v3/pkg/lint/rules"
import "fmt"
// deprecatedApis lists APIs that are deprecated (left) with suggested alternatives (right).
// deprecatedAPIs lists APIs that are deprecated (left) with suggested alternatives (right).
//
// An empty rvalue indicates that the API is completely deprecated.
var deprecatedApis = map[string]string{
var deprecatedAPIs = map[string]string{
"extensions/v1 Deployment": "apps/v1 Deployment",
"extensions/v1 DaemonSet": "apps/v1 DaemonSet",
"extensions/v1 ReplicaSet": "apps/v1 ReplicaSet",
"extensions/v1beta1 PodSecurityPolicy": "policy/v1beta1 PodSecurityPolicy",
"extensions/v1beta1 NetworkPoliicy": "networking.k8s.iio/v1beta1 NetworkPolicy",
"extensions/v1beta1 NetworkPolicy": "networking.k8s.io/v1beta1 NetworkPolicy",
"extensions/v1beta1 Ingress": "networking.k8s.io/v1beta1 Ingress",
"apps/v1beta1 Deployment": "apps/v1 Deployment",
"apps/v1beta1 StatefulSet": "apps/v1 StatefulSet",
"apps/v1beta1 DaemonSet": "apps/v1 DaemonSet",
"apps/v1beta1 ReplicaSet": "apps/v1 ReplicaSet",
"apps/v1beta2 Deployment": "apps/v1 Deployment",
"apps/v1beta2 StatefulSet": "apps/v1 StatefulSet",
"apps/v1beta2 DaemonSet": "apps/v1 DaemonSet",
"apps/v1beta2 ReplicaSet": "apps/v1 ReplicaSet",
}
// deprecatedAPIError indicates than an API is deprecated in Kubernetes
@ -47,7 +54,7 @@ func (e deprecatedAPIError) Error() string {
func validateNoDeprecations(resource *K8sYamlStruct) error {
gvk := fmt.Sprintf("%s %s", resource.APIVersion, resource.Kind)
if alt, ok := deprecatedApis[gvk]; ok {
if alt, ok := deprecatedAPIs[gvk]; ok {
return deprecatedAPIError{
Deprecated: gvk,
Alternative: alt,

@ -104,7 +104,6 @@ func TestV3Fail(t *testing.T) {
t.Errorf("Unexpected error: %s", res[2].Err)
}
}
<<<<<<< HEAD
func TestValidateMetadataName(t *testing.T) {
names := map[string]bool{
@ -134,8 +133,6 @@ func TestValidateMetadataName(t *testing.T) {
}
}
}
||||||| merged common ancestors
=======
func TestDeprecatedAPIFails(t *testing.T) {
mychart := chart.Chart{
@ -148,11 +145,11 @@ func TestDeprecatedAPIFails(t *testing.T) {
Templates: []*chart.File{
{
Name: "templates/baddeployment.yaml",
Data: []byte("apiVersion: apps/v1beta1\nkind: Deployment"),
Data: []byte("apiVersion: apps/v1beta1\nkind: Deployment\nmetadata:\n name: baddep"),
},
{
Name: "templates/goodsecret.yaml",
Data: []byte("apiVersion: v1\nkind: Secret"),
Data: []byte("apiVersion: v1\nkind: Secret\nmetadata:\n name: goodsecret"),
},
},
}
@ -166,7 +163,10 @@ func TestDeprecatedAPIFails(t *testing.T) {
linter := support.Linter{ChartDir: filepath.Join(tmpdir, mychart.Name())}
Templates(&linter, values, namespace, strict)
if l := len(linter.Messages); l != 1 {
t.Errorf("Expected 1 lint error, got %d", l)
for i, msg := range linter.Messages {
t.Logf("Message %d: %s", i, msg)
}
t.Fatalf("Expected 1 lint error, got %d", l)
}
err := linter.Messages[0].Err.(deprecatedAPIError)
@ -174,4 +174,3 @@ func TestDeprecatedAPIFails(t *testing.T) {
t.Errorf("Surprised to learn that %q is deprecated", err.Deprecated)
}
}
>>>>>>> feat: implement deprecation warnings in helm lint

Loading…
Cancel
Save