Documentation
¶
Overview ¶
Package client is a Go client for Ignite resources.
For example, to list running VMs (the equivalent of "ignite vm ls"), and update the VM with a new IP address:
package main
import (
"context"
"fmt"
"net"
"github.com/weaveworks/ignite/pkg/client"
)
func main() {
// List VMs managed by Ignite
vmList, err := client.VMs().List()
if err != nil {
panic(err)
}
for _, vm := range vmList {
// Modify the object
vm.Status.IPAddresses = append(vm.Status.IPAddresses, net.IP{127,0,0,1})
// Save the new VM state
if err := client.VMs().Set(vm); err != nil {
panic(err)
}
}
// Get a specific image, and print its size
myImage, err := client.Images().Get("my-image")
if err != nil {
panic(err)
}
fmt.Printf("Image my-vm size: %s\n", myImage.Spec.Source.Size.String())
// Use the dynamic client
myVM, err := client.Dynamic("VM").Get("my-vm")
if err != nil {
panic(err)
}
fmt.Printf("VM my-vm cpus: %d\n", myVM.Spec.CPUs)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultClient = NewClient(storage.DefaultStorage)
DefaultClient is the default client that can be easily used
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a struct providing high-level access to objects in a storage The resource-specific client interfaces are automatically generated based off client_resource_template.go. The auto-generation can be done with hack/client.sh
func (*Client) Dynamic ¶
func (c *Client) Dynamic(kind meta.Kind) (dc DynamicClient)
Dynamic returns the DynamicClient for the Client instance, for the specific kind
func (*Client) Images ¶
func (c *Client) Images() ImageClient
Images returns the ImageClient for the Client instance
func (*Client) Kernels ¶
func (c *Client) Kernels() KernelClient
Kernels returns the KernelClient for the Client instance
type DynamicClient ¶
type DynamicClient interface {
// Get returns an Object matching the UID from the storage
Get(meta.UID) (meta.Object, error)
// Set saves an Object into the persistent storage
Set(meta.Object) error
// Find returns an Object based on the given filter, filters can
// match e.g. the Object's Name, UID or a specific property
Find(filter filterer.BaseFilter) (meta.Object, error)
// FindAll returns multiple Objects based on the given filter, filters can
// match e.g. the Object's Name, UID or a specific property
FindAll(filter filterer.BaseFilter) ([]meta.Object, error)
// Delete deletes an Object from the storage
Delete(uid meta.UID) error
// List returns a list of all Objects available
List() ([]meta.Object, error)
}
DynamicClient is an interface for accessing API types generically
func Dynamic ¶
func Dynamic(kind meta.Kind) DynamicClient
Dynamic is a shorthand for accessing the DynamicClient using the default client
type ImageClient ¶
type ImageClient interface {
// Get returns the Image matching given UID from the storage
Get(meta.UID) (*api.Image, error)
// Set saves the given Image into persistent storage
Set(*api.Image) error
// Find returns the Image matching the given filter, filters can
// match e.g. the Object's Name, UID or a specific property
Find(filter filterer.BaseFilter) (*api.Image, error)
// FindAll returns multiple Images matching the given filter, filters can
// match e.g. the Object's Name, UID or a specific property
FindAll(filter filterer.BaseFilter) ([]*api.Image, error)
// Delete deletes the Image with the given UID from the storage
Delete(uid meta.UID) error
// List returns a list of all Images available
List() ([]*api.Image, error)
}
ImageClient is an interface for accessing Image-specific API objects
func Images ¶
func Images() ImageClient
Images is a shorthand for accessing Images using the default client
type KernelClient ¶
type KernelClient interface {
// Get returns the Kernel matching given UID from the storage
Get(meta.UID) (*api.Kernel, error)
// Set saves the given Kernel into persistent storage
Set(*api.Kernel) error
// Find returns the Kernel matching the given filter, filters can
// match e.g. the Object's Name, UID or a specific property
Find(filter filterer.BaseFilter) (*api.Kernel, error)
// FindAll returns multiple Kernels matching the given filter, filters can
// match e.g. the Object's Name, UID or a specific property
FindAll(filter filterer.BaseFilter) ([]*api.Kernel, error)
// Delete deletes the Kernel with the given UID from the storage
Delete(uid meta.UID) error
// List returns a list of all Kernels available
List() ([]*api.Kernel, error)
}
KernelClient is an interface for accessing Kernel-specific API objects
func Kernels ¶
func Kernels() KernelClient
Kernels is a shorthand for accessing Kernels using the default client
type VMClient ¶
type VMClient interface {
// Get returns the VM matching given UID from the storage
Get(meta.UID) (*api.VM, error)
// Set saves the given VM into persistent storage
Set(*api.VM) error
// Find returns the VM matching the given filter, filters can
// match e.g. the Object's Name, UID or a specific property
Find(filter filterer.BaseFilter) (*api.VM, error)
// FindAll returns multiple VMs matching the given filter, filters can
// match e.g. the Object's Name, UID or a specific property
FindAll(filter filterer.BaseFilter) ([]*api.VM, error)
// Delete deletes the VM with the given UID from the storage
Delete(uid meta.UID) error
// List returns a list of all VMs available
List() ([]*api.VM, error)
}
VMClient is an interface for accessing VM-specific API objects