Documentation ¶
Index ¶
- Constants
- Variables
- func Link(path string, params Params) string
- type Auth
- type Client
- type EventHandler
- type Finder
- type Handler
- type LibClient
- type NodeBuilder
- type NotFoundError
- type Param
- type Params
- type Ref
- type RefNotUniqueError
- type Resolver
- type ResourceNotResolvedError
- type RestClient
- type Tree
- type TreeNode
- type Watch
Constants ¶
View Source
const ( ProvidersRoot = "providers" ProviderParam = "provider" DetailParam = "detail" NsParam = "namespace" NameParam = "name" )
Root - all routes.
View Source
const ( // Explains reason behind status code. ReasonHeader = "X-Reason" // Explains 404 caused by provider not found in // inventory as opposed to the requested resource // not found within the provider in the inventory. UnknownProvider = "ProviderNotFound" )
Reply Header.
Variables ¶
View Source
var DefaultAuth = Auth{ TTL: time.Second * 10, }
Default auth provider.
View Source
var Settings = &settings.Settings
Application settings.
Functions ¶
Types ¶
type Auth ¶
type Auth struct { // k8s API writer. Writer client.Writer // Cached token TTL. TTL time.Duration // contains filtered or unexported fields }
Authorized by k8s bearer token SAR. Token must have "*" on the provider CR.
type Client ¶
type Client interface { // Finder Finder() Finder // Get a resource. // The `resource` must be a pointer to a resource object. // Returns: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr Get(resource interface{}, id string) error // List a collection. // The `list` must be a pointer to a slice of resource object. // Returns: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr List(list interface{}, param ...Param) error // Watch a collection. // Returns: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr Watch(resource interface{}, h EventHandler) (*Watch, error) // Get a resource by ref. // Returns: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr Find(resource interface{}, ref Ref) error // Find a VM by ref. // Returns the matching resource and: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr VM(ref *Ref) (interface{}, error) // Find a Workload by ref. // Returns the matching resource and: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr Workload(ref *Ref) (interface{}, error) // Find a Network by ref. // Returns the matching resource and: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr Network(ref *Ref) (interface{}, error) // Find storage by ref. // Returns the matching resource and: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr Storage(ref *Ref) (interface{}, error) // Find host by ref. // Returns the matching resource and: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr Host(ref *Ref) (interface{}, error) }
REST Client.
type Finder ¶
type Finder interface { // Finder with client. With(client Client) Finder // Find a resource by ref. // Returns: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr ByRef(resource interface{}, ref Ref) error // Find a VM by ref. // Returns the matching resource and: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr VM(ref *Ref) (interface{}, error) // Find a workload by ref. // Returns the matching resource and: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr Workload(ref *Ref) (interface{}, error) // Find a Network by ref. // Returns the matching resource and: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr Network(ref *Ref) (interface{}, error) // Find storage by ref. // Returns the matching resource and: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr Storage(ref *Ref) (interface{}, error) // Find host by ref. // Returns the matching resource and: // ProviderNotSupportedErr // ProviderNotReadyErr // NotFoundErr // RefNotUniqueErr Host(ref *Ref) (interface{}, error) }
Resource Finder.
type Handler ¶
type Handler struct { libweb.Parity libweb.Watched libweb.Paged // Container Container *libcontainer.Container // Provider referenced in the request. Provider *api.Provider // Collector responsible for the provider. Collector libcontainer.Collector // Resources detail level. Detail int }
Base handler.
func (*Handler) PathMatch ¶
Match (compare) paths. Determine if the relative path is contained in the absolute path.
func (*Handler) PathMatchRoot ¶
Match (compare) paths. Determine if the paths have the same root.
type NodeBuilder ¶
Node builder.
type NotFoundError ¶
type NotFoundError struct {
Ref
}
Resource not found.
func (NotFoundError) Error ¶
func (r NotFoundError) Error() string
type RefNotUniqueError ¶
type RefNotUniqueError struct {
Ref
}
Reference matches multiple resources.
func (RefNotUniqueError) Error ¶
func (r RefNotUniqueError) Error() string
type Resolver ¶
type Resolver interface { // Find the API path for the specified resource. Path(resource interface{}, id string) (string, error) }
Resolves resources to API paths.
type ResourceNotResolvedError ¶
type ResourceNotResolvedError struct {
Object interface{}
}
Resource kind cannot be resolved.
func (ResourceNotResolvedError) Error ¶
func (r ResourceNotResolvedError) Error() string
type RestClient ¶
type RestClient struct { LibClient Resolver // Host <host>:<port> Host string // Parameters Params Params }
REST API client.
func (*RestClient) Get ¶
func (c *RestClient) Get(resource interface{}, id string) (status int, err error)
Get a resource.
func (*RestClient) List ¶
func (c *RestClient) List(list interface{}, param ...Param) (status int, err error)
List resources in a collection.
func (*RestClient) Watch ¶
func (c *RestClient) Watch(resource interface{}, h EventHandler) (status int, w *Watch, err error)
Watch a resource.
type Tree ¶
type Tree struct { NodeBuilder // Depth limit. Depth int }
Tree.
Click to show internal directories.
Click to hide internal directories.