|
| 1 | +/* |
| 2 | +Copyright 2025 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 install |
| 18 | + |
| 19 | +import ( |
| 20 | + "strings" |
| 21 | + "testing" |
| 22 | + |
| 23 | + "k8s.io/apimachinery/pkg/runtime" |
| 24 | + "k8s.io/apimachinery/pkg/runtime/schema" |
| 25 | +) |
| 26 | + |
| 27 | +func TestTypesExistInAllVersions(t *testing.T) { |
| 28 | + scheme := runtime.NewScheme() |
| 29 | + Install(scheme) |
| 30 | + |
| 31 | + group := "kops.k8s.io" |
| 32 | + internalVersion := schema.GroupVersion{Group: group, Version: runtime.APIVersionInternal} |
| 33 | + internalKindToGoType := scheme.KnownTypes(internalVersion) |
| 34 | + |
| 35 | + internalKinds := make(map[string]bool) |
| 36 | + for kind := range internalKindToGoType { |
| 37 | + internalKinds[kind] = true |
| 38 | + } |
| 39 | + |
| 40 | + for _, version := range []string{"v1alpha2", "v1alpha3"} { |
| 41 | + versionKinds := scheme.KnownTypes(schema.GroupVersion{Group: group, Version: version}) |
| 42 | + for kind := range versionKinds { |
| 43 | + // Ignore ListOptions, DeleteOptions, etc. |
| 44 | + if strings.HasSuffix(kind, "Options") { |
| 45 | + continue |
| 46 | + } |
| 47 | + if !internalKinds[kind] { |
| 48 | + t.Errorf("version %s has kind %s, not found in internal API", version, kind) |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | +} |
0 commit comments