This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
340 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
|
||
/* | ||
Note: This file is autogenerated! Do not edit it manually! | ||
Edit client_image_template.go instead, and run | ||
hack/generate-client.sh afterwards. | ||
*/ | ||
|
||
package client | ||
|
||
import ( | ||
"github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha1" | ||
"github.com/weaveworks/ignite/pkg/storage" | ||
) | ||
|
||
// ImageClient is an interface for accessing Image-specific API objects | ||
type ImageClient interface { | ||
storage.Cache | ||
|
||
// Get returns a Image object based on a reference string; which can either | ||
// match the Image's Name or UID, or be a prefix of the UID | ||
Get(ref string) (*v1alpha1.Image, error) | ||
// Set saves a Image into the persistent storage | ||
Set(image *v1alpha1.Image) error | ||
// Delete deletes the API object from the storage | ||
Delete(uid string) error | ||
// List returns a list of all Images available | ||
List() ([]*v1alpha1.Image, error) | ||
} | ||
|
||
// Images returns the ImageClient for the Client instance | ||
func (c *Client) Images() ImageClient { | ||
if c.imageClient == nil { | ||
c.imageClient = newImageClient(c.storage) | ||
} | ||
return c.imageClient | ||
} | ||
|
||
// Images is a shorthand for accessing Images using the default client | ||
func Images() ImageClient { | ||
return DefaultClient.Images() | ||
} | ||
|
||
// imageClient is a struct implementing the ImageClient interface | ||
// It uses a shared storage instance passed from the Client | ||
type imageClient struct { | ||
storage.Cache | ||
storage storage.Storage | ||
} | ||
|
||
// newImageClient builds the imageClient struct using the storage implementation | ||
// It automatically fetches all metadata for all API types of the specific kind into the cache | ||
func newImageClient(s storage.Storage) ImageClient { | ||
c, err := s.GetCache(v1alpha1.ImageKind) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return &imageClient{storage: s, Cache: c} | ||
} | ||
|
||
// Get returns a Image object based on a reference string; which can either | ||
// match the Image's Name or UID, or be a prefix of the UID | ||
func (c *imageClient) Get(ref string) (*v1alpha1.Image, error) { | ||
meta, err := c.MatchOne(ref) | ||
if err != nil { | ||
return nil, err | ||
} | ||
image := &v1alpha1.Image{ObjectMeta: meta.ObjectMeta} | ||
if err := c.storage.Get(image); err != nil { | ||
return nil, err | ||
} | ||
return image, nil | ||
} | ||
|
||
// Set saves a Image into the persistent storage | ||
func (c *imageClient) Set(image *v1alpha1.Image) error { | ||
return c.storage.Set(image) | ||
} | ||
|
||
// Delete deletes the API object from the storage | ||
func (c *imageClient) Delete(uid string) error { | ||
return c.storage.Delete(v1alpha1.ImageKind, uid) | ||
} | ||
|
||
// List returns a list of all Images available | ||
func (c *imageClient) List() ([]*v1alpha1.Image, error) { | ||
list, err := c.storage.List(v1alpha1.ImageKind) | ||
if err != nil { | ||
return nil, err | ||
} | ||
result := []*v1alpha1.Image{} | ||
for _, item := range list { | ||
result = append(result, item.(*v1alpha1.Image)) | ||
} | ||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
|
||
/* | ||
Note: This file is autogenerated! Do not edit it manually! | ||
Edit client_kernel_template.go instead, and run | ||
hack/generate-client.sh afterwards. | ||
*/ | ||
|
||
package client | ||
|
||
import ( | ||
"github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha1" | ||
"github.com/weaveworks/ignite/pkg/storage" | ||
) | ||
|
||
// KernelClient is an interface for accessing Kernel-specific API objects | ||
type KernelClient interface { | ||
storage.Cache | ||
|
||
// Get returns a Kernel object based on a reference string; which can either | ||
// match the Kernel's Name or UID, or be a prefix of the UID | ||
Get(ref string) (*v1alpha1.Kernel, error) | ||
// Set saves a Kernel into the persistent storage | ||
Set(kernel *v1alpha1.Kernel) error | ||
// Delete deletes the API object from the storage | ||
Delete(uid string) error | ||
// List returns a list of all Kernels available | ||
List() ([]*v1alpha1.Kernel, error) | ||
} | ||
|
||
// Kernels returns the KernelClient for the Client instance | ||
func (c *Client) Kernels() KernelClient { | ||
if c.kernelClient == nil { | ||
c.kernelClient = newKernelClient(c.storage) | ||
} | ||
return c.kernelClient | ||
} | ||
|
||
// Kernels is a shorthand for accessing Kernels using the default client | ||
func Kernels() KernelClient { | ||
return DefaultClient.Kernels() | ||
} | ||
|
||
// kernelClient is a struct implementing the KernelClient interface | ||
// It uses a shared storage instance passed from the Client | ||
type kernelClient struct { | ||
storage.Cache | ||
storage storage.Storage | ||
} | ||
|
||
// newKernelClient builds the kernelClient struct using the storage implementation | ||
// It automatically fetches all metadata for all API types of the specific kind into the cache | ||
func newKernelClient(s storage.Storage) KernelClient { | ||
c, err := s.GetCache(v1alpha1.KernelKind) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return &kernelClient{storage: s, Cache: c} | ||
} | ||
|
||
// Get returns a Kernel object based on a reference string; which can either | ||
// match the Kernel's Name or UID, or be a prefix of the UID | ||
func (c *kernelClient) Get(ref string) (*v1alpha1.Kernel, error) { | ||
meta, err := c.MatchOne(ref) | ||
if err != nil { | ||
return nil, err | ||
} | ||
kernel := &v1alpha1.Kernel{ObjectMeta: meta.ObjectMeta} | ||
if err := c.storage.Get(kernel); err != nil { | ||
return nil, err | ||
} | ||
return kernel, nil | ||
} | ||
|
||
// Set saves a Kernel into the persistent storage | ||
func (c *kernelClient) Set(kernel *v1alpha1.Kernel) error { | ||
return c.storage.Set(kernel) | ||
} | ||
|
||
// Delete deletes the API object from the storage | ||
func (c *kernelClient) Delete(uid string) error { | ||
return c.storage.Delete(v1alpha1.KernelKind, uid) | ||
} | ||
|
||
// List returns a list of all Kernels available | ||
func (c *kernelClient) List() ([]*v1alpha1.Kernel, error) { | ||
list, err := c.storage.List(v1alpha1.KernelKind) | ||
if err != nil { | ||
return nil, err | ||
} | ||
result := []*v1alpha1.Kernel{} | ||
for _, item := range list { | ||
result = append(result, item.(*v1alpha1.Kernel)) | ||
} | ||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
|
||
/* | ||
Note: This file is autogenerated! Do not edit it manually! | ||
Edit client_vm_template.go instead, and run | ||
hack/generate-client.sh afterwards. | ||
*/ | ||
|
||
package client | ||
|
||
import ( | ||
"github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha1" | ||
"github.com/weaveworks/ignite/pkg/storage" | ||
) | ||
|
||
// VMClient is an interface for accessing VM-specific API objects | ||
type VMClient interface { | ||
storage.Cache | ||
|
||
// Get returns a VM object based on a reference string; which can either | ||
// match the VM's Name or UID, or be a prefix of the UID | ||
Get(ref string) (*v1alpha1.VM, error) | ||
// Set saves a VM into the persistent storage | ||
Set(vm *v1alpha1.VM) error | ||
// Delete deletes the API object from the storage | ||
Delete(uid string) error | ||
// List returns a list of all VMs available | ||
List() ([]*v1alpha1.VM, error) | ||
} | ||
|
||
// VMs returns the VMClient for the Client instance | ||
func (c *Client) VMs() VMClient { | ||
if c.vmClient == nil { | ||
c.vmClient = newVMClient(c.storage) | ||
} | ||
return c.vmClient | ||
} | ||
|
||
// VMs is a shorthand for accessing VMs using the default client | ||
func VMs() VMClient { | ||
return DefaultClient.VMs() | ||
} | ||
|
||
// vmClient is a struct implementing the VMClient interface | ||
// It uses a shared storage instance passed from the Client | ||
type vmClient struct { | ||
storage.Cache | ||
storage storage.Storage | ||
} | ||
|
||
// newVMClient builds the vmClient struct using the storage implementation | ||
// It automatically fetches all metadata for all API types of the specific kind into the cache | ||
func newVMClient(s storage.Storage) VMClient { | ||
c, err := s.GetCache(v1alpha1.VMKind) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return &vmClient{storage: s, Cache: c} | ||
} | ||
|
||
// Get returns a VM object based on a reference string; which can either | ||
// match the VM's Name or UID, or be a prefix of the UID | ||
func (c *vmClient) Get(ref string) (*v1alpha1.VM, error) { | ||
meta, err := c.MatchOne(ref) | ||
if err != nil { | ||
return nil, err | ||
} | ||
vm := &v1alpha1.VM{ObjectMeta: meta.ObjectMeta} | ||
if err := c.storage.Get(vm); err != nil { | ||
return nil, err | ||
} | ||
return vm, nil | ||
} | ||
|
||
// Set saves a VM into the persistent storage | ||
func (c *vmClient) Set(vm *v1alpha1.VM) error { | ||
return c.storage.Set(vm) | ||
} | ||
|
||
// Delete deletes the API object from the storage | ||
func (c *vmClient) Delete(uid string) error { | ||
return c.storage.Delete(v1alpha1.VMKind, uid) | ||
} | ||
|
||
// List returns a list of all VMs available | ||
func (c *vmClient) List() ([]*v1alpha1.VM, error) { | ||
list, err := c.storage.List(v1alpha1.VMKind) | ||
if err != nil { | ||
return nil, err | ||
} | ||
result := []*v1alpha1.VM{} | ||
for _, item := range list { | ||
result = append(result, item.(*v1alpha1.VM)) | ||
} | ||
return result, nil | ||
} |
Oops, something went wrong.