Skip to content

Commit

Permalink
Merge pull request kubevirt#2578 from slintes/openapi
Browse files Browse the repository at this point in the history
Clean up and fix types.go
  • Loading branch information
slintes authored Nov 4, 2019
2 parents f13a823 + e52eecc commit 9223d49
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 273 deletions.
14 changes: 12 additions & 2 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5919,6 +5919,9 @@
},
"v1.VirtualMachine": {
"description": "VirtualMachine handles the VirtualMachines that are not running\nor are in a stopped state\nThe VirtualMachine contains the template to create the\nVirtualMachineInstance. It also mirrors the running state of the created\nVirtualMachineInstance in its status.",
"required": [
"spec"
],
"properties": {
"apiVersion": {
"description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources",
Expand Down Expand Up @@ -5976,6 +5979,9 @@
},
"v1.VirtualMachineInstance": {
"description": "VirtualMachineInstance is *the* VirtualMachineInstance Definition. It represents a virtual machine in the runtime environment of kubernetes.",
"required": [
"spec"
],
"properties": {
"apiVersion": {
"description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources",
Expand Down Expand Up @@ -6093,6 +6099,9 @@
},
"v1.VirtualMachineInstanceMigration": {
"description": "VirtualMachineInstanceMigration represents the object tracking a VMI's migration\nto another host in the cluster",
"required": [
"spec"
],
"properties": {
"apiVersion": {
"description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources",
Expand Down Expand Up @@ -6336,6 +6345,9 @@
},
"v1.VirtualMachineInstanceReplicaSet": {
"description": "VirtualMachineInstance is *the* VirtualMachineInstance Definition. It represents a virtual machine in the runtime environment of kubernetes.",
"required": [
"spec"
],
"properties": {
"apiVersion": {
"description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources",
Expand Down Expand Up @@ -6599,7 +6611,6 @@
"v1.VirtualMachineList": {
"description": "VirtualMachineList is a list of virtualmachines",
"required": [
"metadata",
"items"
],
"properties": {
Expand All @@ -6608,7 +6619,6 @@
"type": "string"
},
"items": {
"description": "Items is a list of VirtualMachines",
"type": "array",
"items": {
"$ref": "#/definitions/v1.VirtualMachine"
Expand Down
3 changes: 1 addition & 2 deletions staging/src/kubevirt.io/client-go/api/v1/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ go_library(
"defaults.go",
"doc.go",
"openapi_generated.go",
"register.go",
"schema.go",
"schema_swagger_generated.go",
"types.go",
Expand All @@ -20,10 +21,8 @@ go_library(
"//staging/src/kubevirt.io/client-go/precond:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/k8s.io/api/autoscaling/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
Expand Down
52 changes: 13 additions & 39 deletions staging/src/kubevirt.io/client-go/api/v1/openapi_generated.go

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

111 changes: 111 additions & 0 deletions staging/src/kubevirt.io/client-go/api/v1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* This file is part of the KubeVirt project
*
* 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.
*
* Copyright 2019 Red Hat, Inc.
*
*/
package v1

import (
extv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/kubernetes/scheme"
)

// GroupName is the group name use in this package
const GroupName = "kubevirt.io"
const SubresourceGroupName = "subresources.kubevirt.io"

var (
ApiLatestVersion = "v1alpha3"
ApiSupportedWebhookVersions = []string{"v1alpha3"}
ApiStorageVersion = "v1alpha3"
ApiSupportedVersions = []extv1beta1.CustomResourceDefinitionVersion{
{
Name: "v1alpha3",
Served: true,
Storage: true,
},
}
)

var (
// GroupVersion is the latest group version for the KubeVirt api
GroupVersion = schema.GroupVersion{Group: GroupName, Version: ApiLatestVersion}

// StorageGroupVersion is the group version our api is persistented internally as
StorageGroupVersion = schema.GroupVersion{Group: GroupName, Version: ApiStorageVersion}

// GroupVersions is group version list used to register these objects
// The preferred group version is the first item in the list.
GroupVersions = []schema.GroupVersion{GroupVersion}

// SubresourceGroupVersions is group version list used to register these objects
// The preferred group version is the first item in the list.
SubresourceGroupVersions = []schema.GroupVersion{{Group: SubresourceGroupName, Version: "v1alpha3"}}

// SubresourceStorageGroupVersion is the group version our api is persistented internally as
SubresourceStorageGroupVersion = schema.GroupVersion{Group: SubresourceGroupName, Version: ApiStorageVersion}
)

var (
// GroupVersionKind
VirtualMachineInstanceGroupVersionKind = schema.GroupVersionKind{Group: GroupName, Version: GroupVersion.Version, Kind: "VirtualMachineInstance"}
VirtualMachineInstanceReplicaSetGroupVersionKind = schema.GroupVersionKind{Group: GroupName, Version: GroupVersion.Version, Kind: "VirtualMachineInstanceReplicaSet"}
VirtualMachineInstancePresetGroupVersionKind = schema.GroupVersionKind{Group: GroupName, Version: GroupVersion.Version, Kind: "VirtualMachineInstancePreset"}
VirtualMachineGroupVersionKind = schema.GroupVersionKind{Group: GroupName, Version: GroupVersion.Version, Kind: "VirtualMachine"}
VirtualMachineInstanceMigrationGroupVersionKind = schema.GroupVersionKind{Group: GroupName, Version: GroupVersion.Version, Kind: "VirtualMachineInstanceMigration"}
KubeVirtGroupVersionKind = schema.GroupVersionKind{Group: GroupName, Version: GroupVersion.Version, Kind: "KubeVirt"}
)

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
Scheme = runtime.NewScheme()
AddToScheme = SchemeBuilder.AddToScheme
Codecs = serializer.NewCodecFactory(Scheme)
ParameterCodec = runtime.NewParameterCodec(Scheme)
)

func init() {
AddToScheme(Scheme)
AddToScheme(scheme.Scheme)
}

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {

for _, groupVersion := range GroupVersions {
scheme.AddKnownTypes(groupVersion,
&VirtualMachineInstance{},
&VirtualMachineInstanceList{},
&VirtualMachineInstanceReplicaSet{},
&VirtualMachineInstanceReplicaSetList{},
&VirtualMachineInstancePreset{},
&VirtualMachineInstancePresetList{},
&VirtualMachineInstanceMigration{},
&VirtualMachineInstanceMigrationList{},
&VirtualMachine{},
&VirtualMachineList{},
&KubeVirt{},
&KubeVirtList{},
)
metav1.AddToGroupVersion(scheme, groupVersion)
}

return nil
}
Loading

0 comments on commit 9223d49

Please sign in to comment.