func init() { groupMeta, err := latest.RegisterGroup("componentconfig") if err != nil { glog.V(4).Infof("%v", err) return } registeredGroupVersions := registered.GroupVersionsForGroup("componentconfig") groupVersion := registeredGroupVersions[0] *groupMeta = latest.GroupMeta{ GroupVersion: groupVersion, Codec: runtime.CodecFor(api.Scheme, groupVersion.String()), } var versions []string worstToBestGroupVersions := []unversioned.GroupVersion{} for i := len(registeredGroupVersions) - 1; i >= 0; i-- { versions = append(versions, registeredGroupVersions[i].Version) worstToBestGroupVersions = append(worstToBestGroupVersions, registeredGroupVersions[i]) } groupMeta.Versions = versions groupMeta.GroupVersions = registeredGroupVersions groupMeta.SelfLinker = runtime.SelfLinker(accessor) // the list of kinds that are scoped at the root of the api hierarchy // if a kind is not enumerated here, it is assumed to have a namespace scope rootScoped := sets.NewString() ignoredKinds := sets.NewString() groupMeta.RESTMapper = api.NewDefaultRESTMapper(worstToBestGroupVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) api.RegisterRESTMapper(groupMeta.RESTMapper) groupMeta.InterfacesFor = interfacesFor }
func init() { groupMeta, err := latest.RegisterGroup("") if err != nil { glog.V(4).Infof("%v", err) return } // Use the first API version in the list of registered versions as the latest. registeredGroupVersions := registered.GroupVersionsForGroup("") groupVersion := registeredGroupVersions[0] *groupMeta = latest.GroupMeta{ GroupVersion: groupVersion, Codec: runtime.CodecFor(api.Scheme, groupVersion.String()), } var versions []string worstToBestGroupVersions := []unversioned.GroupVersion{} for i := len(registeredGroupVersions) - 1; i >= 0; i-- { versions = append(versions, registeredGroupVersions[i].Version) worstToBestGroupVersions = append(worstToBestGroupVersions, registeredGroupVersions[i]) } groupMeta.Versions = versions groupMeta.GroupVersions = registeredGroupVersions groupMeta.SelfLinker = runtime.SelfLinker(accessor) // the list of kinds that are scoped at the root of the api hierarchy // if a kind is not enumerated here, it is assumed to have a namespace scope rootScoped := sets.NewString( "Node", "Namespace", "PersistentVolume", "ComponentStatus", ) // these kinds should be excluded from the list of resources ignoredKinds := sets.NewString( "ListOptions", "DeleteOptions", "Status", "PodLogOptions", "PodExecOptions", "PodAttachOptions", "PodProxyOptions", "ThirdPartyResource", "ThirdPartyResourceData", "ThirdPartyResourceList") mapper := api.NewDefaultRESTMapper(worstToBestGroupVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) // setup aliases for groups of resources mapper.AddResourceAlias("all", userResources...) groupMeta.RESTMapper = mapper api.RegisterRESTMapper(groupMeta.RESTMapper) groupMeta.InterfacesFor = interfacesFor }
// Based on: https://github.com/openshift/origin/blob/master/pkg/api/compatibility_test.go // // TestCompatibility reencodes the input using the codec for the given // version and checks for the presence of the expected keys and absent // keys in the resulting JSON. func TestCompatibility( t *testing.T, version string, input []byte, validator func(obj runtime.Object) validation.ErrorList, expectedKeys map[string]string, absentKeys []string, ) { // Decode codec := runtime.CodecFor(api.Scheme, version) obj, err := codec.Decode(input) if err != nil { t.Fatalf("Unexpected error: %v", err) } // Validate errs := validator(obj) if len(errs) != 0 { t.Fatalf("Unexpected validation errors: %v", errs) } // Encode output, err := codec.Encode(obj) if err != nil { t.Fatalf("Unexpected error: %v", err) } // Validate old and new fields are encoded generic := map[string]interface{}{} if err := json.Unmarshal(output, &generic); err != nil { t.Fatalf("Unexpected error: %v", err) } hasError := false for k, expectedValue := range expectedKeys { keys := strings.Split(k, ".") if actualValue, ok, err := getJSONValue(generic, keys...); err != nil || !ok { t.Errorf("Unexpected error for %s: %v", k, err) hasError = true } else if !reflect.DeepEqual(expectedValue, fmt.Sprintf("%v", actualValue)) { hasError = true t.Errorf("Unexpected value for %v: expected %v, got %v", k, expectedValue, actualValue) } } for _, absentKey := range absentKeys { keys := strings.Split(absentKey, ".") actualValue, ok, err := getJSONValue(generic, keys...) if err == nil || ok { t.Errorf("Unexpected value found for for key %s: %v", absentKey, actualValue) hasError = true } } if hasError { printer := new(kubectl.JSONPrinter) printer.PrintObj(obj, os.Stdout) t.Logf("2: Encoded value: %#v", string(output)) } }
*/ package api import ( "github.com/jordic/k8s/cloudsqlip/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource" "github.com/jordic/k8s/cloudsqlip/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/unversioned" "github.com/jordic/k8s/cloudsqlip/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion" "github.com/jordic/k8s/cloudsqlip/Godeps/_workspace/src/k8s.io/kubernetes/pkg/fields" "github.com/jordic/k8s/cloudsqlip/Godeps/_workspace/src/k8s.io/kubernetes/pkg/labels" "github.com/jordic/k8s/cloudsqlip/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime" ) // Codec is the identity codec for this package - it can only convert itself // to itself. var Codec = runtime.CodecFor(Scheme, "") func init() { Scheme.AddDefaultingFuncs( func(obj *unversioned.ListOptions) { if obj.LabelSelector.Selector == nil { obj.LabelSelector = unversioned.LabelSelector{labels.Everything()} } if obj.FieldSelector.Selector == nil { obj.FieldSelector = unversioned.FieldSelector{fields.Everything()} } }, ) Scheme.AddConversionFuncs( func(in *unversioned.Time, out *unversioned.Time, s conversion.Scope) error { // Cannot deep copy these, because time.Time has unexported fields.
See the License for the specific language governing permissions and limitations under the License. */ package v1alpha1 import ( "github.com/jordic/k8s/cloudsqlip/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api" "github.com/jordic/k8s/cloudsqlip/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/unversioned" "github.com/jordic/k8s/cloudsqlip/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime" ) // SchemeGroupVersion is group version used to register these objects var SchemeGroupVersion = unversioned.GroupVersion{Group: "metrics", Version: "v1alpha1"} var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion.String()) func init() { // Register the API. addKnownTypes() } // Adds the list of known types to api.Scheme. func addKnownTypes() { api.Scheme.AddKnownTypes(SchemeGroupVersion, &RawNode{}, &RawPod{}, ) } func (*RawNode) IsAnAPIObject() {}