Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collection ¶
type Collection interface { // WriteText serializes collection in human-friendly text format WriteText(w io.Writer) error // WriteJSON serializes collection into JSON format WriteJSON(w io.Writer) error // WriteYAML serializes collection into YAML format WriteYAML(w io.Writer) error // Resources returns the resources collection in the generic format Resources() ([]teleservices.UnknownResource, error) }
Collection represents printable collection of resources that can serialize itself into various format
type CreateRequest ¶
type CreateRequest struct { // SiteKey is the key of the cluster to route request to. ops.SiteKey // Resource is the resource to create Resource teleservices.UnknownResource // Upsert is whether to update a resource Upsert bool // Owner is the user to create resource for Owner string // Manual defines whether the operation should operate // in manual mode. // This attribute is operation-specific Manual bool // Confirmed defines whether the operation has been explicitly approved. // This attribute is operation-specific Confirmed bool }
CreateRequest describes a request to create a resource
func (CreateRequest) String ¶
func (r CreateRequest) String() string
String returns the request string representation.
type ListRequest ¶
type ListRequest struct { // SiteKey is the key of the cluster to route request to. ops.SiteKey // Kind is kind of the resource Kind string // Name is name of the resource Name string // WithSecrets is whether to display hidden resource fields WithSecrets bool // User is the resource owner User string }
ListRequest describes a request to list resources
func (ListRequest) String ¶
func (r ListRequest) String() string
String returns the request string representation.
type RemoveRequest ¶
type RemoveRequest struct { // SiteKey is the key of the cluster to route request to. ops.SiteKey // Kind is kind of the resource Kind string // Name is name of the resource Name string // Force is whether to suppress not found errors Force bool // Owner is the resource owner Owner string // Manual defines whether the operation should operate // in manual mode. // This attribute is operation-specific Manual bool // Confirmed defines whether the operation has been explicitly approved. // This attribute is operation-specific Confirmed bool }
RemoveRequest describes a request to remove a resource
func (RemoveRequest) String ¶
func (r RemoveRequest) String() string
String returns the request string representation.
type ResourceControl ¶
type ResourceControl struct { // Resources is the specific resource controller Resources }
ResourceControl allows to create/list/remove resources
A list of supported resources is determined by the specific controller it is initialized with.
func NewControl ¶
func NewControl(resources Resources) *ResourceControl
NewControl creates a new resource control instance
func (*ResourceControl) Create ¶
func (r *ResourceControl) Create(ctx context.Context, reader io.Reader, req CreateRequest) (err error)
Create creates all resources found in the provided data
func (*ResourceControl) Get ¶
func (r *ResourceControl) Get(w io.Writer, req ListRequest, format constants.Format) error
Get retrieves the specified resource collection and outputs it
func (*ResourceControl) Remove ¶
func (r *ResourceControl) Remove(ctx context.Context, req RemoveRequest) error
Remove removes the specified resource
type ResourceFunc ¶
type ResourceFunc func(storage.UnknownResource) error
ResourceFunc is a callback that operates on a Gravity resource
type Resources ¶
type Resources interface { // Create creates the provided resource Create(context.Context, CreateRequest) error // GetCollection retrieves a collection of specified resources GetCollection(ListRequest) (Collection, error) // Remove removes the specified resource Remove(context.Context, RemoveRequest) error }
Resources defines methods each specific resource controller should implement
The reason it exists is because gravity and tele CLI tools each support their own set of resources.
type ValidateFunc ¶
type ValidateFunc func(storage.UnknownResource) error
ValidateFunc is a resource validator implemented as a single function
func (ValidateFunc) Validate ¶
func (r ValidateFunc) Validate(res storage.UnknownResource) error
Validate checks whether the specified resource represents a valid resource. Implements Validator
type Validator ¶
type Validator interface { // Validate checks whether the specified resource // represents a valid resource. Validate(storage.UnknownResource) error }
Validator is a service to validate resources