-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathdeprecation.go
53 lines (43 loc) · 1.9 KB
/
deprecation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Copyright 2020 The cert-manager Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package validation
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
cmacme "github.com/jetstack/cert-manager/pkg/apis/acme/v1"
cmacmev1alpha2 "github.com/jetstack/cert-manager/pkg/apis/acme/v1alpha2"
cmacmev1alpha3 "github.com/jetstack/cert-manager/pkg/apis/acme/v1alpha3"
cmacmev1beta1 "github.com/jetstack/cert-manager/pkg/apis/acme/v1beta1"
"github.com/jetstack/cert-manager/pkg/internal/api/validation"
)
// This file holds temporary functionality for cert-manager v1.4 API deprecation.
// It will be removed in cert-manager v1.6, when we remove the deprecated APIs.
var (
deprecatedAPIs = map[string]schema.GroupVersion{
cmacmev1alpha2.SchemeGroupVersion.String(): cmacme.SchemeGroupVersion,
cmacmev1alpha3.SchemeGroupVersion.String(): cmacme.SchemeGroupVersion,
cmacmev1beta1.SchemeGroupVersion.String(): cmacme.SchemeGroupVersion,
}
deprecationMessageTemplate = "%s %s is deprecated in v1.4+, unavailable in v1.6+; use %v %s"
)
func validateAPIVersion(gvk *metav1.GroupVersionKind) validation.WarningList {
// There might be a smarter way to get GroupVersion
gv := fmt.Sprintf("%s/%s", gvk.Group, gvk.Version)
kind := gvk.Kind
if newV, ok := deprecatedAPIs[gv]; ok {
w := fmt.Sprintf(deprecationMessageTemplate, gv, kind, newV, kind)
return validation.WarningList{w}
}
return nil
}