Skip to content

Commit

Permalink
Ensure every resource in k8s 1.23 (reconcilerio#22)
Browse files Browse the repository at this point in the history
For resources with multiple supported versions, only the recommended
version is included. We can look to include other versions over time.

New resources include:

```
APIVERSION                             KIND
v1                                     Binding
v1                                     ComponentStatus
v1                                     PodTemplate
v1                                     ReplicationController
apiregistration.k8s.io/v1              APIService
apps/v1                                ControllerRevision
authentication.k8s.io/v1               TokenReview
authorization.k8s.io/v1                LocalSubjectAccessReview
authorization.k8s.io/v1                SelfSubjectAccessReview
authorization.k8s.io/v1                SelfSubjectRulesReview
authorization.k8s.io/v1                SubjectAccessReview
certificates.k8s.io/v1                 CertificateSigningRequest
coordination.k8s.io/v1                 Lease
discovery.k8s.io/v1                    EndpointSlice
events.k8s.io/v1                       Event
flowcontrol.apiserver.k8s.io/v1beta1   FlowSchema
flowcontrol.apiserver.k8s.io/v1beta1   PriorityLevelConfiguration
node.k8s.io/v1                         RuntimeClass
policy/v1                              PodDisruptionBudget
policy/v1beta1                         PodSecurityPolicy
scheduling.k8s.io/v1                   PriorityClass
storage.k8s.io/v1                      CSIDriver
storage.k8s.io/v1                      CSINode
storage.k8s.io/v1beta1                 CSIStorageCapacity
storage.k8s.io/v1                      StorageClass
storage.k8s.io/v1                      VolumeAttachment
```

The `dies.dev/apis/rbac` package is deprecated, the content is now at
`dies.dev/apis/authorization/rbac`. Aliases have been created for
backwards compatibility, but will be removed in the future.

Signed-off-by: Scott Andrews <scott@andrews.me>
  • Loading branch information
scothis committed Jan 31, 2022
1 parent 4953ccd commit bbb0c6a
Show file tree
Hide file tree
Showing 111 changed files with 17,879 additions and 4,212 deletions.
2 changes: 1 addition & 1 deletion apis/admissionregistration/v1/zz_generated.die.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/admissionregistration/v1/zz_generated.die_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/apiextensions/v1/zz_generated.die.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/apiextensions/v1/zz_generated.die_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions apis/apiregistration/v1/apiservice.go
@@ -0,0 +1,58 @@
/*
Copyright 2022 the original author or 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 v1

import (
diemetav1 "dies.dev/apis/meta/v1"
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration"
)

// +die:object=true
type _ = apiregistrationv1.APIService

// +die
type _ = apiregistrationv1.APIServiceSpec

func (d *APIServiceSpecDie) TargetDie(fn func(d *ServiceReferenceDie)) *APIServiceSpecDie {
return d.DieStamp(func(r *apiregistrationv1.APIServiceSpec) {
d := ServiceReferenceBlank.DieImmutable(false).DieFeedPtr(r.Service)
fn(d)
r.Service = d.DieReleasePtr()
})
}

// +die
type _ = apiregistrationv1.ServiceReference

// +die
type _ = apiregistrationv1.APIServiceStatus

func (d *APIServiceStatusDie) ConditionsDie(conditions ...*diemetav1.ConditionDie) *APIServiceStatusDie {
return d.DieStamp(func(r *apiregistrationv1.APIServiceStatus) {
r.Conditions = make([]apiregistrationv1.APIServiceCondition, len(conditions))
for i := range conditions {
c := conditions[i].DieRelease()
r.Conditions[i] = apiregistrationv1.APIServiceCondition{
Type: apiregistrationv1.APIServiceConditionType(c.Type),
Status: apiregistrationv1.ConditionStatus(c.Status),
Reason: c.Reason,
Message: c.Message,
LastTransitionTime: c.LastTransitionTime,
}
}
})
}
64 changes: 64 additions & 0 deletions apis/apiregistration/v1/apiservice_test.go
@@ -0,0 +1,64 @@
/*
Copyright 2022 the original author or 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 v1_test

import (
"testing"

dieapiregistrationv1 "dies.dev/apis/apiregistration/v1"
diemetav1 "dies.dev/apis/meta/v1"
"github.com/google/go-cmp/cmp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration"
)

func TestAPIService(t *testing.T) {
tests := []struct {
name string
die *dieapiregistrationv1.APIServiceDie
expected apiregistrationv1.APIService
}{
{
name: "empty",
die: dieapiregistrationv1.APIServiceBlank,
expected: apiregistrationv1.APIService{},
},
{
name: "object metadata",
die: dieapiregistrationv1.APIServiceBlank.
MetadataDie(func(d *diemetav1.ObjectMetaDie) {
d.Namespace("my-namespace")
d.Name("my-name")
}),
expected: apiregistrationv1.APIService{
ObjectMeta: metav1.ObjectMeta{
Namespace: "my-namespace",
Name: "my-name",
},
},
},
}

for _, c := range tests {
t.Run(c.name, func(t *testing.T) {
actual := c.die.DieRelease()
if diff := cmp.Diff(c.expected, actual); diff != "" {
t.Errorf("(-expected, +actual): %s", diff)
}
})
}
}

0 comments on commit bbb0c6a

Please sign in to comment.