kubevirt.io/api@v1.2.0/README.md (about) 1 # KubeVirt API definitions 2 3 Go definitions of the [KubeVirt](https://github.com/kubevirt/kubevirt) API. 4 5 ## How to use it 6 7 Add the dependency to your `go.mod`: 8 9 ```bash 10 go get kubevirt.io/api 11 ``` 12 13 Then generate the client 14 with [client-gen](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-api-machinery/generating-clientset.md). 15 16 To download and install the Kubernetes API client code generator `client-gen`, run: 17 18 ``` 19 go install k8s.io/code-generator/cmd/client-gen@latest 20 ``` 21 22 The following command creates the client inside an example project called `testapi`: 23 24 ```bash 25 client-gen --input-base="kubevirt.io/api/" --input="core/v1" --output-package="testapi/client" --output-base="../" --clientset-name="versioned" --go-header-file boilerplate.go.txt 26 ``` 27 28 `client-gen` always needs a `boilerplate.go.txt` file. If you don't want to 29 include a project specific header to the files just create an empty file. 30 31 Then run `go get` to fetch any new introduced missing dependencies. 32 33 Finally make use of the client: 34 35 ```golang 36 cfg, err := clientcmd.BuildConfigFromFlags("", "") 37 if err != nil { 38 panic(err) 39 } 40 client := versioned.NewForConfigOrDie(cfg) 41 client.KubevirtV1().VirtualMachineInstances(v1.NamespaceAll).List(context.Background(), v1.ListOptions{}) 42 ``` 43 44 ----- 45 KubeVirt API is maintained at https://github.com/kubevirt/kubevirt/tree/main/staging/src/kubevirt.io/api. 46 The main branch of this repository is updated on every PR merge, release tags are pushed on every release of KubeVirt. 47 48 ## License 49 50 KubeVirt API is distributed under the 51 [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt). 52 53 Copyright 2021 54 55 Licensed under the Apache License, Version 2.0 (the "License"); 56 you may not use this file except in compliance with the License. 57 You may obtain a copy of the License at 58 59 http://www.apache.org/licenses/LICENSE-2.0 60 61 Unless required by applicable law or agreed to in writing, software 62 distributed under the License is distributed on an "AS IS" BASIS, 63 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 64 See the License for the specific language governing permissions and 65 limitations under the License.