Documentation ¶
Index ¶
- Constants
- Variables
- func Copy(dst *websocket.Conn, src *websocket.Conn) (int64, error)
- func CopyFrom(dst io.Writer, src *websocket.Conn) (written int64, err error)
- func CopyTo(dst *websocket.Conn, src io.Reader) (written int64, err error)
- func DefaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig
- func Dial(address string, tlsConfig *tls.Config) (*websocket.Conn, *http.Response, error)
- func FlagSet() *flag.FlagSet
- func GetConfig() (*restclient.Config, error)
- func GetKubevirtClientConfig() (*rest.Config, error)
- func Init()
- func NewUpgrader() *websocket.Upgrader
- func RequestFromConfig(config *rest.Config, vmi string, namespace string, resource string) (*http.Request, error)
- type AsyncSubresourceError
- type KubeVirtInterface
- type KubevirtClient
- func GetKubevirtClient() (KubevirtClient, error)
- func GetKubevirtClientFromFlags(master string, kubeconfig string) (KubevirtClient, error)
- func GetKubevirtClientFromRESTConfig(config *rest.Config) (KubevirtClient, error)
- func GetKubevirtSubresourceClient() (KubevirtClient, error)
- func GetKubevirtSubresourceClientFromFlags(master string, kubeconfig string) (KubevirtClient, error)
- type ReplicaSetInterface
- type RoundTripCallback
- type SerialConsoleOptions
- type ServerVersion
- type StreamInterface
- type StreamOptions
- type VirtHandlerClient
- type VirtHandlerConn
- type VirtualMachineInstanceInterface
- type VirtualMachineInstanceMigrationInterface
- type VirtualMachineInstancePresetInterface
- type VirtualMachineInterface
- type WebsocketRoundTripper
Constants ¶
const (
ApiGroupName = "/apis/" + v1.SubresourceGroupName
)
const (
WebsocketMessageBufferSize = 10240
)
Variables ¶
var GetKubevirtClientFromClientConfig = func(cmdConfig clientcmd.ClientConfig) (KubevirtClient, error) { config, err := cmdConfig.ClientConfig() if err != nil { return nil, err } return GetKubevirtClientFromRESTConfig(config) }
this function is defined as a closure so iut could be overwritten by unit tests
Functions ¶
func DefaultClientConfig ¶
func DefaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig
DefaultClientConfig creates a clientcmd.ClientConfig with the following hierarchy:
Use the kubeconfig builder. The number of merges and overrides here gets a little crazy. Stay with me.
Merge the kubeconfig itself. This is done with the following hierarchy rules:
CommandLineLocation - this parsed from the command line, so it must be late bound. If you specify this, then no other kubeconfig files are merged. This file must exist.
If $KUBECONFIG is set, then it is treated as a list of files that should be merged.
HomeDirectoryLocation Empty filenames are ignored. Files with non-deserializable content produced errors. The first file to set a particular value or map key wins and the value or map key is never changed. This means that the first file to set CurrentContext will have its context preserved. It also means that if two files specify a "red-user", only values from the first file's red-user are used. Even non-conflicting entries from the second file's "red-user" are discarded.
Determine the context to use based on the first hit in this chain
command line argument - again, parsed from the command line, so it must be late bound
CurrentContext from the merged kubeconfig file
Empty is allowed at this stage
Determine the cluster info and auth info to use. At this point, we may or may not have a context. They are built based on the first hit in this chain. (run it twice, once for auth, once for cluster)
command line argument
If context is present, then use the context value
Empty is allowed
Determine the actual cluster info to use. At this point, we may or may not have a cluster info. Build each piece of the cluster info based on the chain:
command line argument
If cluster info is present and a value for the attribute is present, use it.
If you don't have a server location, bail.
Auth info is build using the same rules as cluster info, EXCEPT that you can only have one authentication technique per auth info. The following conditions result in an error:
If there are two conflicting techniques specified from the command line, fail.
If the command line does not specify one, and the auth info has conflicting techniques, fail.
If the command line specifies one and the auth info specifies another, honor the command line technique.
Use default values and potentially prompt for auth information
However, if it appears that we're running in a kubernetes cluster container environment, then run with the auth info kubernetes mounted for us. Specifically: The env vars KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT are set, and the file /var/run/secrets/kubernetes.io/serviceaccount/token exists and is not a directory.
Initially copied from https://github.com/kubernetes/kubernetes/blob/09f321c80bfc9bca63a5530b56d7a1a3ba80ba9b/pkg/kubectl/cmd/util/factory_client_access.go#L174
func GetConfig ¶
func GetConfig() (*restclient.Config, error)
func GetKubevirtClientConfig ¶
func Init ¶
func Init()
Init adds the default `kubeconfig` and `master` flags. It is not added by default to allow integration into the different controller generators which normally add these flags too.
func NewUpgrader ¶
Types ¶
type AsyncSubresourceError ¶
type AsyncSubresourceError struct { StatusCode int // contains filtered or unexported fields }
func (*AsyncSubresourceError) Error ¶
func (a *AsyncSubresourceError) Error() string
func (*AsyncSubresourceError) GetStatusCode ¶
func (a *AsyncSubresourceError) GetStatusCode() int
type KubeVirtInterface ¶
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) UpdateStatus(*v1.KubeVirt) (*v1.KubeVirt, error) PatchStatus(name string, pt types.PatchType, data []byte) (result *v1.KubeVirt, err error) }
type KubevirtClient ¶
type KubevirtClient interface { VirtualMachineInstance(namespace string) VirtualMachineInstanceInterface VirtualMachineInstanceMigration(namespace string) VirtualMachineInstanceMigrationInterface ReplicaSet(namespace string) ReplicaSetInterface VirtualMachine(namespace string) VirtualMachineInterface KubeVirt(namespace string) KubeVirtInterface VirtualMachineInstancePreset(namespace string) VirtualMachineInstancePresetInterface VirtualMachineSnapshot(namespace string) vmsnapshotv1alpha1.VirtualMachineSnapshotInterface VirtualMachineSnapshotContent(namespace string) vmsnapshotv1alpha1.VirtualMachineSnapshotContentInterface VirtualMachineRestore(namespace string) vmsnapshotv1alpha1.VirtualMachineRestoreInterface ServerVersion() *ServerVersion RestClient() *rest.RESTClient GeneratedKubeVirtClient() generatedclient.Interface NetworkClient() networkclient.Interface ExtensionsClient() extclient.Interface SecClient() secv1.SecurityV1Interface DiscoveryClient() discovery.DiscoveryInterface PrometheusClient() promclient.Interface KubernetesSnapshotClient() k8ssnapshotclient.Interface kubernetes.Interface Config() *rest.Config }
func GetKubevirtClient ¶
func GetKubevirtClient() (KubevirtClient, error)
func GetKubevirtClientFromFlags ¶
func GetKubevirtClientFromFlags(master string, kubeconfig string) (KubevirtClient, error)
func GetKubevirtClientFromRESTConfig ¶
func GetKubevirtClientFromRESTConfig(config *rest.Config) (KubevirtClient, error)
func GetKubevirtSubresourceClient ¶
func GetKubevirtSubresourceClient() (KubevirtClient, error)
func GetKubevirtSubresourceClientFromFlags ¶
func GetKubevirtSubresourceClientFromFlags(master string, kubeconfig string) (KubevirtClient, error)
type ReplicaSetInterface ¶
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) UpdateStatus(*v1.VirtualMachineInstanceReplicaSet) (*v1.VirtualMachineInstanceReplicaSet, error) PatchStatus(name string, pt types.PatchType, data []byte) (result *v1.VirtualMachineInstanceReplicaSet, err error) }
type RoundTripCallback ¶
type SerialConsoleOptions ¶
type ServerVersion ¶
type ServerVersion struct {
// contains filtered or unexported fields
}
type StreamInterface ¶
type StreamInterface interface {
Stream(options StreamOptions) error
}
type VirtHandlerClient ¶
type VirtHandlerClient interface { ForNode(nodeName string) VirtHandlerConn Port(port int) VirtHandlerClient Namespace(namespace string) VirtHandlerClient }
func NewVirtHandlerClient ¶
func NewVirtHandlerClient(client KubevirtClient) VirtHandlerClient
type VirtHandlerConn ¶
type VirtHandlerConn interface { ConnectionDetails() (ip string, port int, err error) ConsoleURI(vmi *virtv1.VirtualMachineInstance) (string, error) VNCURI(vmi *virtv1.VirtualMachineInstance) (string, error) PauseURI(vmi *virtv1.VirtualMachineInstance) (string, error) UnpauseURI(vmi *virtv1.VirtualMachineInstance) (string, error) Pod() (pod *v1.Pod, err error) Put(url string, tlsConfig *tls.Config) error Get(url string, tlsConfig *tls.Config) (string, error) GuestInfoURI(vmi *virtv1.VirtualMachineInstance) (string, error) UserListURI(vmi *virtv1.VirtualMachineInstance) (string, error) FilesystemListURI(vmi *virtv1.VirtualMachineInstance) (string, error) }
type VirtualMachineInstanceInterface ¶
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, options *SerialConsoleOptions) (StreamInterface, error) VNC(name string) (StreamInterface, error) Pause(name string) error Unpause(name string) error GuestOsInfo(name string) (v1.VirtualMachineInstanceGuestAgentInfo, error) UserList(name string) (v1.VirtualMachineInstanceGuestOSUserList, error) FilesystemList(name string) (v1.VirtualMachineInstanceFileSystemList, error) }
type VirtualMachineInstanceMigrationInterface ¶
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) UpdateStatus(*v1.VirtualMachineInstanceMigration) (*v1.VirtualMachineInstanceMigration, error) PatchStatus(name string, pt types.PatchType, data []byte) (result *v1.VirtualMachineInstanceMigration, err error) }
type VirtualMachineInstancePresetInterface ¶
type VirtualMachineInstancePresetInterface 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) }
type VirtualMachineInterface ¶
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) UpdateStatus(*v1.VirtualMachine) (*v1.VirtualMachine, error) PatchStatus(name string, pt types.PatchType, data []byte) (result *v1.VirtualMachine, err error) Restart(name string) error ForceRestart(name string, graceperiod int) error Start(name string) error Stop(name string) error Migrate(name string) error Rename(name string, options *v1.RenameOptions) error }
VirtualMachineInterface provides convenience methods to work with virtual machines inside the cluster
type WebsocketRoundTripper ¶
type WebsocketRoundTripper struct { Dialer *websocket.Dialer Do RoundTripCallback }