forked from kubevirt/kubevirt
/
kubevirt.go
173 lines (149 loc) · 6.71 KB
/
kubevirt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
* 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 2018 Red Hat, Inc.
*
*/
package kubecli
//go:generate mockgen -source $GOFILE -package=$GOPACKAGE -destination=generated_mock_$GOFILE
/*
ATTENTION: Rerun code generators when interface signatures are modified.
*/
import (
"io"
"time"
secv1 "github.com/openshift/client-go/security/clientset/versioned/typed/security/v1"
autov1 "k8s.io/api/autoscaling/v1"
extclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
k8smetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/discovery"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
networkclient "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned"
cdiclient "kubevirt.io/containerized-data-importer/pkg/client/clientset/versioned"
"kubevirt.io/kubevirt/pkg/api/v1"
)
type KubevirtClient interface {
VirtualMachineInstance(namespace string) VirtualMachineInstanceInterface
VirtualMachineInstanceMigration(namespace string) VirtualMachineInstanceMigrationInterface
ReplicaSet(namespace string) ReplicaSetInterface
VirtualMachine(namespace string) VirtualMachineInterface
KubeVirt(namespace string) KubeVirtInterface
ServerVersion() *ServerVersion
RestClient() *rest.RESTClient
CdiClient() cdiclient.Interface
NetworkClient() networkclient.Interface
ExtensionsClient() extclient.Interface
SecClient() secv1.SecurityV1Interface
DiscoveryClient() discovery.DiscoveryInterface
kubernetes.Interface
Config() *rest.Config
}
type kubevirt struct {
master string
kubeconfig string
restClient *rest.RESTClient
config *rest.Config
cdiClient *cdiclient.Clientset
networkClient *networkclient.Clientset
extensionsClient *extclient.Clientset
secClient *secv1.SecurityV1Client
discoveryClient *discovery.DiscoveryClient
*kubernetes.Clientset
}
func (k kubevirt) Config() *rest.Config {
return k.config
}
func (k kubevirt) CdiClient() cdiclient.Interface {
return k.cdiClient
}
func (k kubevirt) NetworkClient() networkclient.Interface {
return k.networkClient
}
func (k kubevirt) ExtensionsClient() extclient.Interface {
return k.extensionsClient
}
func (k kubevirt) SecClient() secv1.SecurityV1Interface {
return k.secClient
}
func (k kubevirt) DiscoveryClient() discovery.DiscoveryInterface {
return k.discoveryClient
}
func (k kubevirt) RestClient() *rest.RESTClient {
return k.restClient
}
type StreamOptions struct {
In io.Reader
Out io.Writer
}
type StreamInterface interface {
Stream(options StreamOptions) error
}
type VirtualMachineInstanceInterface interface {
Get(name string, options *k8smetav1.GetOptions) (*v1.VirtualMachineInstance, error)
List(opts *k8smetav1.ListOptions) (*v1.VirtualMachineInstanceList, error)
Create(instance *v1.VirtualMachineInstance) (*v1.VirtualMachineInstance, error)
Update(*v1.VirtualMachineInstance) (*v1.VirtualMachineInstance, error)
Delete(name string, options *k8smetav1.DeleteOptions) error
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.VirtualMachineInstance, err error)
SerialConsole(name string, timeout time.Duration) (StreamInterface, error)
VNC(name string) (StreamInterface, error)
}
type ReplicaSetInterface interface {
Get(name string, options k8smetav1.GetOptions) (*v1.VirtualMachineInstanceReplicaSet, error)
List(opts k8smetav1.ListOptions) (*v1.VirtualMachineInstanceReplicaSetList, error)
Create(*v1.VirtualMachineInstanceReplicaSet) (*v1.VirtualMachineInstanceReplicaSet, error)
Update(*v1.VirtualMachineInstanceReplicaSet) (*v1.VirtualMachineInstanceReplicaSet, error)
Delete(name string, options *k8smetav1.DeleteOptions) error
GetScale(replicaSetName string, options k8smetav1.GetOptions) (*autov1.Scale, error)
UpdateScale(replicaSetName string, scale *autov1.Scale) (*autov1.Scale, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.VirtualMachineInstanceReplicaSet, err error)
}
type VMIPresetInterface interface {
Get(name string, options k8smetav1.GetOptions) (*v1.VirtualMachineInstancePreset, error)
List(opts k8smetav1.ListOptions) (*v1.VirtualMachineInstancePresetList, error)
Create(*v1.VirtualMachineInstancePreset) (*v1.VirtualMachineInstancePreset, error)
Update(*v1.VirtualMachineInstancePreset) (*v1.VirtualMachineInstancePreset, error)
Delete(name string, options *k8smetav1.DeleteOptions) error
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.VirtualMachineInstancePreset, err error)
}
// VirtualMachineInterface provides convenience methods to work with
// virtual machines inside the cluster
type VirtualMachineInterface interface {
Get(name string, options *k8smetav1.GetOptions) (*v1.VirtualMachine, error)
List(opts *k8smetav1.ListOptions) (*v1.VirtualMachineList, error)
Create(*v1.VirtualMachine) (*v1.VirtualMachine, error)
Update(*v1.VirtualMachine) (*v1.VirtualMachine, error)
Delete(name string, options *k8smetav1.DeleteOptions) error
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.VirtualMachine, err error)
Restart(name string) error
}
type VirtualMachineInstanceMigrationInterface interface {
Get(name string, options *k8smetav1.GetOptions) (*v1.VirtualMachineInstanceMigration, error)
List(opts *k8smetav1.ListOptions) (*v1.VirtualMachineInstanceMigrationList, error)
Create(*v1.VirtualMachineInstanceMigration) (*v1.VirtualMachineInstanceMigration, error)
Update(*v1.VirtualMachineInstanceMigration) (*v1.VirtualMachineInstanceMigration, error)
Delete(name string, options *k8smetav1.DeleteOptions) error
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.VirtualMachineInstanceMigration, err error)
}
type KubeVirtInterface interface {
Get(name string, options *k8smetav1.GetOptions) (*v1.KubeVirt, error)
List(opts *k8smetav1.ListOptions) (*v1.KubeVirtList, error)
Create(instance *v1.KubeVirt) (*v1.KubeVirt, error)
Update(*v1.KubeVirt) (*v1.KubeVirt, error)
Delete(name string, options *k8smetav1.DeleteOptions) error
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.KubeVirt, err error)
}