Skip to content

Commit e0f5cca

Browse files
committed
Copy CSR v1beta1 to v1
* Remove prerelease tags * Update copyright, package, imports to v1 * Remove signerName, usages, and condition status defaulting
1 parent eda662b commit e0f5cca

File tree

18 files changed

+513
-5
lines changed

18 files changed

+513
-5
lines changed

cmd/kube-apiserver/app/aggregator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ var apiVersionPriorities = map[schema.GroupVersion]priority{
263263
{Group: "batch", Version: "v1"}: {group: 17400, version: 15},
264264
{Group: "batch", Version: "v1beta1"}: {group: 17400, version: 9},
265265
{Group: "batch", Version: "v2alpha1"}: {group: 17400, version: 9},
266+
{Group: "certificates.k8s.io", Version: "v1"}: {group: 17300, version: 15},
266267
{Group: "certificates.k8s.io", Version: "v1beta1"}: {group: 17300, version: 9},
267268
{Group: "networking.k8s.io", Version: "v1"}: {group: 17200, version: 15},
268269
{Group: "networking.k8s.io", Version: "v1beta1"}: {group: 17200, version: 9},

hack/lib/init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ autoscaling/v2beta2 \
8080
batch/v1 \
8181
batch/v1beta1 \
8282
batch/v2alpha1 \
83+
certificates.k8s.io/v1 \
8384
certificates.k8s.io/v1beta1 \
8485
coordination.k8s.io/v1beta1 \
8586
coordination.k8s.io/v1 \

pkg/apis/certificates/install/install.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2424
"k8s.io/kubernetes/pkg/api/legacyscheme"
2525
"k8s.io/kubernetes/pkg/apis/certificates"
26+
v1 "k8s.io/kubernetes/pkg/apis/certificates/v1"
2627
"k8s.io/kubernetes/pkg/apis/certificates/v1beta1"
2728
)
2829

@@ -33,6 +34,8 @@ func init() {
3334
// Install registers the API group and adds types to a scheme
3435
func Install(scheme *runtime.Scheme) {
3536
utilruntime.Must(certificates.AddToScheme(scheme))
37+
utilruntime.Must(v1.AddToScheme(scheme))
3638
utilruntime.Must(v1beta1.AddToScheme(scheme))
37-
utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion))
39+
// TODO(liggitt): prefer v1 in 1.20
40+
utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion, v1.SchemeGroupVersion))
3841
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
"fmt"
21+
22+
"k8s.io/apimachinery/pkg/runtime"
23+
)
24+
25+
func addConversionFuncs(scheme *runtime.Scheme) error {
26+
// Add field conversion funcs.
27+
return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("CertificateSigningRequest"),
28+
func(label, value string) (string, string, error) {
29+
switch label {
30+
case "metadata.name",
31+
"spec.signerName":
32+
return label, value, nil
33+
default:
34+
return "", "", fmt.Errorf("field label not supported: %s", label)
35+
}
36+
},
37+
)
38+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
"k8s.io/apimachinery/pkg/runtime"
21+
)
22+
23+
func addDefaultingFuncs(scheme *runtime.Scheme) error {
24+
return RegisterDefaults(scheme)
25+
}

pkg/apis/certificates/v1/doc.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/certificates
18+
// +k8s:conversion-gen-external-types=k8s.io/api/certificates/v1
19+
// +k8s:defaulter-gen=TypeMeta
20+
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/certificates/v1
21+
22+
// +groupName=certificates.k8s.io
23+
24+
package v1 // import "k8s.io/kubernetes/pkg/apis/certificates/v1"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
"crypto/x509"
21+
"encoding/pem"
22+
"errors"
23+
)
24+
25+
// ParseCSR decodes a PEM encoded CSR
26+
func ParseCSR(pemBytes []byte) (*x509.CertificateRequest, error) {
27+
// extract PEM from request object
28+
block, _ := pem.Decode(pemBytes)
29+
if block == nil || block.Type != "CERTIFICATE REQUEST" {
30+
return nil, errors.New("PEM block type must be CERTIFICATE REQUEST")
31+
}
32+
csr, err := x509.ParseCertificateRequest(block.Bytes)
33+
if err != nil {
34+
return nil, err
35+
}
36+
return csr, nil
37+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
certificatesv1 "k8s.io/api/certificates/v1"
21+
"k8s.io/apimachinery/pkg/runtime/schema"
22+
)
23+
24+
// GroupName is the group name use in this package
25+
const GroupName = "certificates.k8s.io"
26+
27+
// SchemeGroupVersion is group version used to register these objects
28+
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
29+
30+
// Kind takes an unqualified kind and returns a Group qualified GroupKind
31+
func Kind(kind string) schema.GroupKind {
32+
return SchemeGroupVersion.WithKind(kind).GroupKind()
33+
}
34+
35+
// Resource takes an unqualified resource and returns a Group qualified GroupResource
36+
func Resource(resource string) schema.GroupResource {
37+
return SchemeGroupVersion.WithResource(resource).GroupResource()
38+
}
39+
40+
var (
41+
localSchemeBuilder = &certificatesv1.SchemeBuilder
42+
AddToScheme = localSchemeBuilder.AddToScheme
43+
)
44+
45+
func init() {
46+
// We only register manually written functions here. The registration of the
47+
// generated functions takes place in the generated files. The separation
48+
// makes the code compile even when the generated files are missing.
49+
localSchemeBuilder.Register(addDefaultingFuncs, addConversionFuncs)
50+
}

pkg/master/master.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
batchapiv1 "k8s.io/api/batch/v1"
3939
batchapiv1beta1 "k8s.io/api/batch/v1beta1"
4040
batchapiv2alpha1 "k8s.io/api/batch/v2alpha1"
41+
certificatesapiv1 "k8s.io/api/certificates/v1"
4142
certificatesapiv1beta1 "k8s.io/api/certificates/v1beta1"
4243
coordinationapiv1 "k8s.io/api/coordination/v1"
4344
coordinationapiv1beta1 "k8s.io/api/coordination/v1beta1"
@@ -606,6 +607,7 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig {
606607
autoscalingapiv2beta2.SchemeGroupVersion,
607608
batchapiv1.SchemeGroupVersion,
608609
batchapiv1beta1.SchemeGroupVersion,
610+
certificatesapiv1.SchemeGroupVersion,
609611
certificatesapiv1beta1.SchemeGroupVersion,
610612
coordinationapiv1.SchemeGroupVersion,
611613
coordinationapiv1beta1.SchemeGroupVersion,

pkg/master/storageversionhashdata/data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ var GVRToStorageVersionHash = map[string]string{
6262
"autoscaling/v2beta2/horizontalpodautoscalers": "oQlkt7f5j/A=",
6363
"batch/v1/jobs": "mudhfqk/qZY=",
6464
"batch/v1beta1/cronjobs": "h/JlFAZkyyY=",
65+
"certificates.k8s.io/v1/certificatesigningrequests": "UQh3YTCDIf0=",
6566
"certificates.k8s.io/v1beta1/certificatesigningrequests": "UQh3YTCDIf0=",
6667
"coordination.k8s.io/v1beta1/leases": "/sY7hl8ol1U=",
6768
"coordination.k8s.io/v1/leases": "/sY7hl8ol1U=",

0 commit comments

Comments
 (0)