Documentation ¶
Index ¶
- Variables
- func Apply(config Config, resources Resources) error
- func Diff(config Config, resources Resources) error
- func Export(config Config, exportDir string, resources Resources) error
- func Get(config Config, UID string) error
- func List(config Config, resources Resources) error
- func Listen(config Config, UID, filename string) error
- func Preview(config Config, resources Resources, opts *PreviewOpts) error
- func Show(config Config, resources Resources) error
- func Watch(config Config, watchDir string, parser Parser) error
- type APIErr
- type Config
- type ExtendedImporter
- type Handler
- type ListenHandler
- type MultiResourceHandler
- type Notifier
- func (n *Notifier) Added(resource Resource)
- func (n *Notifier) Error(resource *Resource, msg string)
- func (n *Notifier) HasChanges(resource Resource, diff string)
- func (n *Notifier) Info(resource *Resource, msg string)
- func (n *Notifier) NoChanges(resource Resource)
- func (n *Notifier) NotFound(resource Resource)
- func (n *Notifier) NotSupported(resource Resource, behaviour string)
- func (n *Notifier) Updated(resource Resource)
- func (n *Notifier) Warn(resource *Resource, msg string)
- type Parser
- type PreviewHandler
- type PreviewOpts
- type Provider
- type Registry
- type Resource
- type ResourceList
- type Resources
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is used to signal a missing resource
var ErrNotImplemented = errors.New("not implemented")
ErrNotImplemented signals a feature that is not supported by a provider
Functions ¶
Types ¶
type ExtendedImporter ¶
type ExtendedImporter struct {
// contains filtered or unexported fields
}
ExtendedImporter does stuff
type Handler ¶
type Handler interface { APIVersion() string Kind() string GetJSONPaths() []string GetExtension() string // Parse parses an interface{} object into a struct for this resource type Parse(path string, i interface{}) (ResourceList, error) // Unprepare removes unnecessary elements from a remote resource ready for presentation/comparison Unprepare(resource Resource) *Resource // Prepare gets a resource ready for dispatch to the remote endpoint Prepare(existing, resource Resource) *Resource // Get retrieves JSON for a resource from an endpoint, by UID GetByUID(UID string) (*Resource, error) // GetRepresentation renders Jsonnet to Grizzly resources, rendering as a string GetRepresentation(uid string, resource Resource) (string, error) // GetRemoteRepresentation retrieves a resource from the endpoint and renders to a string GetRemoteRepresentation(uid string) (string, error) // GetRemote retrieves a resource as a datastructure GetRemote(uid string) (*Resource, error) // Add pushes a new resource to the endpoint Add(resource Resource) error // Update pushes an existing resource to the endpoint Update(existing, resource Resource) error }
Handler describes a handler for a single API resource handled by a single provider
type ListenHandler ¶
type ListenHandler interface { // Listen watches a resource and update local file on changes Listen(notifier Notifier, UID, filename string) error }
ListenHandler describes a handler that has the ability to watch a single resource for changes, and write changes to that resource to a local file
type MultiResourceHandler ¶
type MultiResourceHandler interface { // Diff compares local resources with remote equivalents and output result Diff(notifier Notifier, resources ResourceList) error // Apply local resources to remote endpoint Apply(notifier Notifier, resources ResourceList) error }
MultiResourceHandler describes a handler that can handle multiple resources in one go. This could be because it needs to see all resources before sending, or because the endpoint API supports batching of resources.
type Notifier ¶
type Notifier struct{}
Notifier provides Handlers terminal agnostic mechanisms to announce results of actions
func (*Notifier) HasChanges ¶
HasChanges announces that a resource has changed, and displays the differences
func (*Notifier) NotSupported ¶
NotSupported announces that a behaviour is not supported by a handler
type PreviewHandler ¶
type PreviewHandler interface { // Preview renders Jsonnet then pushes them to the endpoint if previews are possible Preview(resource Resource, notifier Notifier, opts *PreviewOpts) error }
PreviewHandler describes a handler that has the ability to render a preview of a resource
type PreviewOpts ¶
type PreviewOpts struct {
ExpiresSeconds int
}
PreviewOpts Options to Configure a Preview
type Provider ¶
type Provider interface { Group() string Version() string APIVersion() string GetHandlers() []Handler }
Provider describes a single Endpoint Provider
type Registry ¶
type Registry struct { Providers []Provider Handlers []Handler HandlerByName map[string]Handler HandlerByPath map[string]Handler }
Registry records providers
func NewProviderRegistry ¶
func NewProviderRegistry() Registry
NewProviderRegistry returns a new registry instance
func (*Registry) GetHandler ¶
GetHandler returns a single provider based upon a JSON path
func (*Registry) RegisterProvider ¶
RegisterProvider will register a new provider
type Resource ¶
type Resource struct { UID string `json:"uid"` Filename string `json:"filename"` Handler Handler `json:"handler"` Detail interface{} `json:"detail"` JSONPath string `json:"path"` }
Resource represents a single Resource destined for a single endpoint
func (*Resource) APIVersion ¶
APIVersion returns the group and version of the provider of the resource
func (*Resource) GetRemoteRepresentation ¶
GetRemoteRepresentation Gets the string representation for this resource
func (*Resource) GetRepresentation ¶
GetRepresentation Gets the string representation for this resource
func (*Resource) MatchesTarget ¶
MatchesTarget identifies whether a resource is in a target list
type ResourceList ¶
ResourceList represents a set of named resources