...

Text file src/kubevirt.io/api/README.md

Documentation: kubevirt.io/api

     1# KubeVirt API definitions
     2
     3Go definitions of the [KubeVirt](https://github.com/kubevirt/kubevirt) API.
     4
     5## How to use it
     6
     7Add the dependency to your `go.mod`:
     8
     9```bash
    10go get kubevirt.io/api
    11```
    12
    13Then generate the client
    14with [client-gen](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-api-machinery/generating-clientset.md).
    15
    16To download and install the Kubernetes API client code generator `client-gen`, run:
    17
    18```
    19go install k8s.io/code-generator/cmd/client-gen@latest
    20```
    21
    22The following command creates the client inside an example project called `testapi`:
    23
    24```bash
    25client-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
    29include a project specific header to the files just create an empty file.
    30
    31Then run `go get` to fetch any new introduced missing dependencies.
    32
    33Finally make use of the client:
    34
    35```golang
    36cfg, err := clientcmd.BuildConfigFromFlags("", "")
    37if err != nil {
    38	panic(err)
    39}
    40client := versioned.NewForConfigOrDie(cfg)
    41client.KubevirtV1().VirtualMachineInstances(v1.NamespaceAll).List(context.Background(), v1.ListOptions{})
    42```
    43
    44-----
    45KubeVirt API is maintained at https://github.com/kubevirt/kubevirt/tree/main/staging/src/kubevirt.io/api.  
    46The main branch of this repository is updated on every PR merge, release tags are pushed on every release of KubeVirt.
    47
    48## License
    49
    50KubeVirt 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.

View as plain text