DRA: bump API v1alpha2 -> v1alpha3
This is in preparation for revamping the resource.k8s.io completely. Because there will be no support for transitioning from v1alpha2 to v1alpha3, the roundtrip test data for that API in 1.29 and 1.30 gets removed. Repeating the version in the import name of the API packages is not really required. It was done for a while to support simpler grepping for usage of alpha APIs, but there are better ways for that now. So during this transition, "resourceapi" gets used instead of "resourcev1alpha3" and the version gets dropped from informer and lister imports. The advantage is that the next bump to v1beta1 will affect fewer source code lines. Only source code where the version really matters (like API registration) retains the versioned import.
This commit is contained in:
@@ -23,7 +23,7 @@ import (
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/apis/resource"
|
||||
"k8s.io/kubernetes/pkg/apis/resource/v1alpha2"
|
||||
"k8s.io/kubernetes/pkg/apis/resource/v1alpha3"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -33,6 +33,6 @@ func init() {
|
||||
// Install registers the API group and adds types to a scheme
|
||||
func Install(scheme *runtime.Scheme) {
|
||||
utilruntime.Must(resource.AddToScheme(scheme))
|
||||
utilruntime.Must(v1alpha2.AddToScheme(scheme))
|
||||
utilruntime.Must(scheme.SetVersionPriority(v1alpha2.SchemeGroupVersion))
|
||||
utilruntime.Must(v1alpha3.AddToScheme(scheme))
|
||||
utilruntime.Must(scheme.SetVersionPriority(v1alpha3.SchemeGroupVersion))
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ func TestResourceVersioner(t *testing.T) {
|
||||
|
||||
func TestCodec(t *testing.T) {
|
||||
claim := internal.ResourceClaim{}
|
||||
data, err := runtime.Encode(legacyscheme.Codecs.LegacyCodec(schema.GroupVersion{Group: "resource.k8s.io", Version: "v1alpha2"}), &claim)
|
||||
data, err := runtime.Encode(legacyscheme.Codecs.LegacyCodec(schema.GroupVersion{Group: "resource.k8s.io", Version: "v1alpha3"}), &claim)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func TestCodec(t *testing.T) {
|
||||
if err := json.Unmarshal(data, &other); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if other.APIVersion != "resource.k8s.io/v1alpha2" || other.Kind != "ResourceClaim" {
|
||||
if other.APIVersion != "resource.k8s.io/v1alpha3" || other.Kind != "ResourceClaim" {
|
||||
t.Errorf("unexpected unmarshalled object %#v", other)
|
||||
}
|
||||
}
|
||||
|
1749
pkg/apis/resource/v1alpha2/zz_generated.conversion.go
generated
1749
pkg/apis/resource/v1alpha2/zz_generated.conversion.go
generated
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha2
|
||||
package v1alpha3
|
||||
|
||||
import (
|
||||
"fmt"
|
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha2
|
||||
package v1alpha3
|
||||
|
||||
import (
|
||||
"k8s.io/api/resource/v1alpha2"
|
||||
"k8s.io/api/resource/v1alpha3"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
@@ -25,8 +25,8 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
return RegisterDefaults(scheme)
|
||||
}
|
||||
|
||||
func SetDefaults_ResourceClaimSpec(obj *v1alpha2.ResourceClaimSpec) {
|
||||
func SetDefaults_ResourceClaimSpec(obj *v1alpha3.ResourceClaimSpec) {
|
||||
if obj.AllocationMode == "" {
|
||||
obj.AllocationMode = v1alpha2.AllocationModeWaitForFirstConsumer
|
||||
obj.AllocationMode = v1alpha3.AllocationModeWaitForFirstConsumer
|
||||
}
|
||||
}
|
@@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha2_test
|
||||
package v1alpha3_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
v1alpha2 "k8s.io/api/resource/v1alpha2"
|
||||
v1alpha3 "k8s.io/api/resource/v1alpha3"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
// ensure types are installed
|
||||
@@ -29,32 +29,32 @@ import (
|
||||
)
|
||||
|
||||
func TestSetDefaultAllocationMode(t *testing.T) {
|
||||
claim := &v1alpha2.ResourceClaim{}
|
||||
claim := &v1alpha3.ResourceClaim{}
|
||||
|
||||
// field should be defaulted
|
||||
defaultMode := v1alpha2.AllocationModeWaitForFirstConsumer
|
||||
output := roundTrip(t, runtime.Object(claim)).(*v1alpha2.ResourceClaim)
|
||||
defaultMode := v1alpha3.AllocationModeWaitForFirstConsumer
|
||||
output := roundTrip(t, runtime.Object(claim)).(*v1alpha3.ResourceClaim)
|
||||
outMode := output.Spec.AllocationMode
|
||||
if outMode != defaultMode {
|
||||
t.Errorf("Expected AllocationMode to be defaulted to: %+v, got: %+v", defaultMode, outMode)
|
||||
}
|
||||
|
||||
// field should not change
|
||||
nonDefaultMode := v1alpha2.AllocationModeImmediate
|
||||
claim = &v1alpha2.ResourceClaim{
|
||||
Spec: v1alpha2.ResourceClaimSpec{
|
||||
nonDefaultMode := v1alpha3.AllocationModeImmediate
|
||||
claim = &v1alpha3.ResourceClaim{
|
||||
Spec: v1alpha3.ResourceClaimSpec{
|
||||
AllocationMode: nonDefaultMode,
|
||||
},
|
||||
}
|
||||
output = roundTrip(t, runtime.Object(claim)).(*v1alpha2.ResourceClaim)
|
||||
output = roundTrip(t, runtime.Object(claim)).(*v1alpha3.ResourceClaim)
|
||||
outMode = output.Spec.AllocationMode
|
||||
if outMode != v1alpha2.AllocationModeImmediate {
|
||||
if outMode != v1alpha3.AllocationModeImmediate {
|
||||
t.Errorf("Expected AllocationMode to remain %+v, got: %+v", nonDefaultMode, outMode)
|
||||
}
|
||||
}
|
||||
|
||||
func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
|
||||
codec := legacyscheme.Codecs.LegacyCodec(v1alpha2.SchemeGroupVersion)
|
||||
codec := legacyscheme.Codecs.LegacyCodec(v1alpha3.SchemeGroupVersion)
|
||||
data, err := runtime.Encode(codec, obj)
|
||||
if err != nil {
|
||||
t.Errorf("%v\n %#v", err, obj)
|
@@ -15,9 +15,9 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/resource
|
||||
// +k8s:conversion-gen-external-types=k8s.io/api/resource/v1alpha2
|
||||
// +k8s:conversion-gen-external-types=k8s.io/api/resource/v1alpha3
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +k8s:defaulter-gen-input=k8s.io/api/resource/v1alpha2
|
||||
// +k8s:defaulter-gen-input=k8s.io/api/resource/v1alpha3
|
||||
|
||||
// Package v1alpha2 is the v1alpha2 version of the resource API.
|
||||
package v1alpha2 // import "k8s.io/kubernetes/pkg/apis/resource/v1alpha2"
|
||||
// Package v1alpha3 is the v1alpha3 version of the resource API.
|
||||
package v1alpha3 // import "k8s.io/kubernetes/pkg/apis/resource/v1alpha3"
|
@@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha2
|
||||
package v1alpha3
|
||||
|
||||
import (
|
||||
"k8s.io/api/resource/v1alpha2"
|
||||
"k8s.io/api/resource/v1alpha3"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
var (
|
||||
localSchemeBuilder = &v1alpha2.SchemeBuilder
|
||||
localSchemeBuilder = &v1alpha3.SchemeBuilder
|
||||
AddToScheme = localSchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
@@ -38,7 +38,7 @@ func init() {
|
||||
const GroupName = "resource.k8s.io"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha3"}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
1749
pkg/apis/resource/v1alpha3/zz_generated.conversion.go
generated
Normal file
1749
pkg/apis/resource/v1alpha3/zz_generated.conversion.go
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -19,10 +19,10 @@ limitations under the License.
|
||||
|
||||
// Code generated by defaulter-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha2
|
||||
package v1alpha3
|
||||
|
||||
import (
|
||||
v1alpha2 "k8s.io/api/resource/v1alpha2"
|
||||
v1alpha3 "k8s.io/api/resource/v1alpha3"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
@@ -30,31 +30,31 @@ import (
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha2.ResourceClaim{}, func(obj interface{}) { SetObjectDefaults_ResourceClaim(obj.(*v1alpha2.ResourceClaim)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha2.ResourceClaimList{}, func(obj interface{}) { SetObjectDefaults_ResourceClaimList(obj.(*v1alpha2.ResourceClaimList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha2.ResourceClaimTemplate{}, func(obj interface{}) { SetObjectDefaults_ResourceClaimTemplate(obj.(*v1alpha2.ResourceClaimTemplate)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha2.ResourceClaimTemplateList{}, func(obj interface{}) {
|
||||
SetObjectDefaults_ResourceClaimTemplateList(obj.(*v1alpha2.ResourceClaimTemplateList))
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha3.ResourceClaim{}, func(obj interface{}) { SetObjectDefaults_ResourceClaim(obj.(*v1alpha3.ResourceClaim)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha3.ResourceClaimList{}, func(obj interface{}) { SetObjectDefaults_ResourceClaimList(obj.(*v1alpha3.ResourceClaimList)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha3.ResourceClaimTemplate{}, func(obj interface{}) { SetObjectDefaults_ResourceClaimTemplate(obj.(*v1alpha3.ResourceClaimTemplate)) })
|
||||
scheme.AddTypeDefaultingFunc(&v1alpha3.ResourceClaimTemplateList{}, func(obj interface{}) {
|
||||
SetObjectDefaults_ResourceClaimTemplateList(obj.(*v1alpha3.ResourceClaimTemplateList))
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ResourceClaim(in *v1alpha2.ResourceClaim) {
|
||||
func SetObjectDefaults_ResourceClaim(in *v1alpha3.ResourceClaim) {
|
||||
SetDefaults_ResourceClaimSpec(&in.Spec)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ResourceClaimList(in *v1alpha2.ResourceClaimList) {
|
||||
func SetObjectDefaults_ResourceClaimList(in *v1alpha3.ResourceClaimList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_ResourceClaim(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ResourceClaimTemplate(in *v1alpha2.ResourceClaimTemplate) {
|
||||
func SetObjectDefaults_ResourceClaimTemplate(in *v1alpha3.ResourceClaimTemplate) {
|
||||
SetDefaults_ResourceClaimSpec(&in.Spec.Spec)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ResourceClaimTemplateList(in *v1alpha2.ResourceClaimTemplateList) {
|
||||
func SetObjectDefaults_ResourceClaimTemplateList(in *v1alpha3.ResourceClaimTemplateList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_ResourceClaimTemplate(a)
|
Reference in New Issue
Block a user