Documentation ¶
Index ¶
- Variables
- func Apply(registry Registry, resources Resources, continueOnError bool, ...) error
- func DetectEnvelope(data any) bool
- func Diff(registry Registry, resources Resources, onlySpec bool, outputFormat string) error
- func EventToColoredText(event Event) string
- func EventToPlainText(event Event) string
- func Export(registry Registry, exportDir string, resources Resources, onlySpec bool, ...) error
- func Format(registry Registry, resourcePath string, resource *Resource, format string, ...) ([]byte, string, string, error)
- func Get(registry Registry, UID string, onlySpec bool, outputFormat string) error
- func List(registry Registry, resources Resources, format string) error
- func ListRemote(registry Registry, targets []string, format string) error
- func Pluraliser(count int, name string) string
- func Pull(registry Registry, resourcePath string, onlySpec bool, outputFormat string, ...) error
- func SendError(w http.ResponseWriter, msg string, err error, code int)
- func Serve(registry Registry, parser WatchParser, resourcePath string, port int, ...) error
- func Show(registry Registry, resources Resources, outputFormat string) error
- func Snapshot(registry Registry, resources Resources, expiresSeconds int) error
- func ValidateEnvelope(data any) error
- func Watch(registry Registry, watchDir string, parser WatchParser, ...) error
- func WriteFile(filename string, content []byte) error
- type APIErr
- type BaseHandler
- func (h *BaseHandler) APIVersion() string
- func (h *BaseHandler) Detect(map[string]any) bool
- func (h *BaseHandler) GetUID(resource Resource) (string, error)
- func (h *BaseHandler) Kind() string
- func (h *BaseHandler) Prepare(existing, resource Resource) *Resource
- func (h *BaseHandler) Sort(resources Resources) Resources
- func (h *BaseHandler) Unprepare(resource Resource) *Resource
- func (h *BaseHandler) UsesFolders() bool
- type ChainParser
- type ErrorPrimitiveReached
- type Event
- type EventFormatter
- type EventSeverity
- type EventType
- type FilteredParser
- type FormatParser
- type Handler
- type JSONParser
- type JsonnetParser
- type ListenHandler
- type ParseError
- type Parser
- type ParserOpt
- type ParserOptions
- type Provider
- type ProxyEndpoint
- type ProxyHandler
- type ProxyProvider
- type Registry
- func (r *Registry) Detect(data any) string
- func (r *Registry) GetHandler(kind string) (Handler, error)
- func (r *Registry) GetProxyProvider() (*ProxyProvider, error)
- func (r *Registry) HandlerMatchesTarget(handler Handler, targets []string) bool
- func (r *Registry) ResourceMatchesTarget(kind string, UID string, targets []string) bool
- func (r *Registry) Sort(resources Resources) Resources
- type Resource
- func (r *Resource) APIVersion() string
- func (r *Resource) DeleteSpecKey(key string)
- func (r *Resource) GetMetadata(key string) string
- func (r *Resource) GetSpecString(key string) (string, bool)
- func (r *Resource) GetSpecValue(key string) interface{}
- func (r *Resource) HasMetadata(key string) bool
- func (r *Resource) Kind() string
- func (r *Resource) Name() string
- func (r *Resource) Ref() ResourceRef
- func (r *Resource) SetMetadata(key, value string)
- func (r *Resource) SetSource(source Source)
- func (r *Resource) SetSpecString(key, value string)
- func (r *Resource) SetSpecValue(key string, value interface{})
- func (r *Resource) Spec() map[string]interface{}
- func (r *Resource) SpecAsJSON() (string, error)
- func (r Resource) String() string
- func (r *Resource) YAML() (string, error)
- type ResourceRef
- type Resources
- type Server
- type SnapshotHandler
- type Source
- type Summary
- type WatchParser
- type WriterRecorder
- type YAMLParser
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is used to signal a missing resource ErrNotFound = errors.New("not found") // ErrNotImplemented signals a feature that is not supported by a provider ErrNotImplemented = errors.New("not implemented") // ErrHandlerNotFound indicates that no handler was found for a particular resource Kind. ErrHandlerNotFound = errors.New("handler not found") )
var ( ResourceAdded = EventType{ID: "resource-added", Severity: Notice, HumanReadable: "added"} ResourceNotChanged = EventType{ID: "resource-not-changed", Severity: Info, HumanReadable: "unchanged"} ResourceNotFound = EventType{ID: "resource-not-found", Severity: Info, HumanReadable: "not found"} ResourceUpdated = EventType{ID: "resource-updated", Severity: Notice, HumanReadable: "updated"} ResourcePulled = EventType{ID: "resource-pulled", Severity: Notice, HumanReadable: "pulled"} ResourceFailure = EventType{ID: "resource-failure", Severity: Error, HumanReadable: "failed"} )
Functions ¶
func Apply ¶
func Apply(registry Registry, resources Resources, continueOnError bool, eventsRecorder eventsRecorder) error
Apply pushes resources to endpoints
func DetectEnvelope ¶ added in v0.4.0
DetectEnvelope identifies whether this resource is enveloped or not
func EventToColoredText ¶ added in v0.4.1
func EventToPlainText ¶ added in v0.4.1
func Export ¶
func Export(registry Registry, exportDir string, resources Resources, onlySpec bool, outputFormat string) error
Export renders Jsonnet resources then saves them to a directory
func ListRemote ¶ added in v0.2.0
ListRetmote outputs the keys of remote resources
func Pluraliser ¶ added in v0.4.1
Pluraliser returns a string describing the count of items, with a plural 's' appended if the count of items is greater than one.
func Pull ¶ added in v0.2.0
func Pull(registry Registry, resourcePath string, onlySpec bool, outputFormat string, targets []string, continueOnError bool, eventsRecorder eventsRecorder) error
Pull pulls remote resources and stores them in the local file system. The given resourcePath must be a directory, where all resources will be stored. If opts.JSONSpec is true, which is only applicable for dashboards, saves the spec as a JSON file.
func SendError ¶ added in v0.4.1
func SendError(w http.ResponseWriter, msg string, err error, code int)
func Serve ¶ added in v0.4.0
func Serve(registry Registry, parser WatchParser, resourcePath string, port int, openBrowser, onlySpec bool, outputFormat string) error
Serve starts an HTTP server that can be used to navigate Grizzly resources, as well as allowing visualisation of resources handed to Grizzly. If pure files, they can be saved too.
func ValidateEnvelope ¶ added in v0.4.0
ValidateEnvelope confirms that this resource is a complete enveloped resource
Types ¶
type BaseHandler ¶ added in v0.4.0
type BaseHandler struct { Provider Provider // contains filtered or unexported fields }
func NewBaseHandler ¶ added in v0.4.0
func NewBaseHandler(provider Provider, kind string, usesFolders bool) BaseHandler
func (*BaseHandler) APIVersion ¶ added in v0.4.0
func (h *BaseHandler) APIVersion() string
func (*BaseHandler) GetUID ¶ added in v0.4.0
func (h *BaseHandler) GetUID(resource Resource) (string, error)
func (*BaseHandler) Kind ¶ added in v0.4.0
func (h *BaseHandler) Kind() string
func (*BaseHandler) Prepare ¶ added in v0.4.0
func (h *BaseHandler) Prepare(existing, resource Resource) *Resource
func (*BaseHandler) Sort ¶ added in v0.4.0
func (h *BaseHandler) Sort(resources Resources) Resources
func (*BaseHandler) Unprepare ¶ added in v0.4.0
func (h *BaseHandler) Unprepare(resource Resource) *Resource
func (*BaseHandler) UsesFolders ¶ added in v0.4.0
func (h *BaseHandler) UsesFolders() bool
type ChainParser ¶ added in v0.4.1
type ChainParser struct {
// contains filtered or unexported fields
}
func NewChainParser ¶ added in v0.4.1
func NewChainParser(formatParsers []FormatParser, continueOnError bool) *ChainParser
func (*ChainParser) Parse ¶ added in v0.4.1
func (parser *ChainParser) Parse(resourcePath string, options ParserOptions) (Resources, error)
type ErrorPrimitiveReached ¶ added in v0.4.0
type ErrorPrimitiveReached struct {
// contains filtered or unexported fields
}
ErrorPrimitiveReached occurs when walkJSON reaches the end of nested dicts without finding a valid resource
func (ErrorPrimitiveReached) Error ¶ added in v0.4.0
func (e ErrorPrimitiveReached) Error() string
func (ErrorPrimitiveReached) WithContainingObj ¶ added in v0.4.0
func (e ErrorPrimitiveReached) WithContainingObj(obj map[string]any, err error) ErrorPrimitiveReached
type EventFormatter ¶ added in v0.4.1
type EventSeverity ¶ added in v0.4.1
type EventSeverity uint8
const ( Info EventSeverity = iota Notice Error )
type EventType ¶ added in v0.4.1
type EventType struct { Severity EventSeverity ID string HumanReadable string }
type FilteredParser ¶ added in v0.4.1
type FilteredParser struct {
// contains filtered or unexported fields
}
func NewFilteredParser ¶ added in v0.4.1
func NewFilteredParser(registry Registry, decorated Parser, targets []string) *FilteredParser
func (*FilteredParser) Parse ¶ added in v0.4.1
func (parser *FilteredParser) Parse(resourcePath string, options ParserOptions) (Resources, error)
type FormatParser ¶ added in v0.4.1
type Handler ¶
type Handler interface { APIVersion() string Kind() string // ResourceFilePath returns the location on disk where a resource should be updated ResourceFilePath(resource Resource, filetype string) string // Parse parses a manifest object into a struct for this resource type Parse(m map[string]any) (*Resource, 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 // Retrieves a UID for a resource GetUID(resource Resource) (string, error) // GetSpecUID retrieves a UID from the spec of a raw resource GetSpecUID(resource Resource) (string, error) // Get retrieves JSON for a resource from an endpoint, by UID GetByUID(UID string) (*Resource, error) // GetRemote retrieves a remote equivalent of a remote resource GetRemote(resource Resource) (*Resource, error) // ListRemote retrieves as list of UIDs of all remote resources ListRemote() ([]string, 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 // Validate gets or build the uid of corresponding resource Validate(resource Resource) error // Sort sorts resources as defined by the handler Sort(resources Resources) Resources // UsesFolders identifies whether this resource lives within a folder UsesFolders() bool // Detects whether a spec-only resource is of this kind Detect(map[string]any) bool }
Handler describes a handler for a single API resource handled by a single provider
type JSONParser ¶ added in v0.4.1
type JSONParser struct {
// contains filtered or unexported fields
}
func NewJSONParser ¶ added in v0.4.1
func NewJSONParser(registry Registry) *JSONParser
func (*JSONParser) Accept ¶ added in v0.4.1
func (parser *JSONParser) Accept(file string) bool
func (*JSONParser) Parse ¶ added in v0.4.1
func (parser *JSONParser) Parse(file string, options ParserOptions) (Resources, error)
Parse evaluates a JSON file and parses it into resources
type JsonnetParser ¶ added in v0.4.1
type JsonnetParser struct {
// contains filtered or unexported fields
}
func NewJsonnetParser ¶ added in v0.4.1
func NewJsonnetParser(registry Registry, jsonnetPaths []string) *JsonnetParser
func (*JsonnetParser) Accept ¶ added in v0.4.1
func (parser *JsonnetParser) Accept(file string) bool
func (*JsonnetParser) Parse ¶ added in v0.4.1
func (parser *JsonnetParser) Parse(file string, options ParserOptions) (Resources, error)
Parse evaluates a jsonnet file and parses it into an object tree
type ListenHandler ¶
type ListenHandler interface { // Listen watches a resource and update local file on changes Listen(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 ParseError ¶ added in v0.4.1
func (ParseError) Error ¶ added in v0.4.1
func (err ParseError) Error() string
type Parser ¶
type Parser interface {
Parse(resourcePath string, options ParserOptions) (Resources, error)
}
type ParserOpt ¶ added in v0.4.1
type ParserOpt func(config *parsersConfig)
func ParserContinueOnError ¶ added in v0.4.1
type ParserOptions ¶ added in v0.4.1
type Provider ¶
type Provider interface { Name() string Group() string Version() string APIVersion() string GetHandlers() []Handler }
Provider describes a single Endpoint Provider
type ProxyEndpoint ¶ added in v0.4.0
type ProxyHandler ¶ added in v0.4.0
type ProxyHandler interface { // RegisterHandlers registers HTTP handlers for proxy events GetProxyEndpoints(p Server) []ProxyEndpoint // ProxyURL returns a URL path for a resource on the proxy ProxyURL(Resource) (string, error) }
ProxyHandler describes a handler that can be used to edit resources live via a proxied UI
type ProxyProvider ¶ added in v0.4.0
type ProxyProvider interface {
SetupProxy() (*httputil.ReverseProxy, error)
}
type Registry ¶
ProviderSet records providers
func NewRegistry ¶ added in v0.4.0
NewRegistry returns an empty registry
func (*Registry) GetHandler ¶
GetHandler returns a single provider based upon a JSON path
func (*Registry) GetProxyProvider ¶ added in v0.4.0
func (r *Registry) GetProxyProvider() (*ProxyProvider, error)
func (*Registry) HandlerMatchesTarget ¶ added in v0.4.0
HandlerMatchesTarget identifies whether a handler is in a target list
func (*Registry) ResourceMatchesTarget ¶ added in v0.4.0
ResourceMatchesTarget identifies whether a resource is in a target list
type Resource ¶
Resource represents a single Resource destined for a single endpoint
func NewResource ¶ added in v0.2.0
NewResource returns a new Resource object
func ResourceFromMap ¶ added in v0.4.0
func (*Resource) APIVersion ¶
APIVersion returns the group and version of the provider of the resource
func (*Resource) DeleteSpecKey ¶ added in v0.2.0
func (*Resource) GetMetadata ¶ added in v0.2.0
func (*Resource) GetSpecString ¶ added in v0.2.0
func (*Resource) GetSpecValue ¶ added in v0.2.0
func (*Resource) HasMetadata ¶ added in v0.2.0
func (*Resource) Ref ¶ added in v0.4.1
func (r *Resource) Ref() ResourceRef
func (*Resource) SetMetadata ¶ added in v0.2.0
func (*Resource) SetSpecString ¶ added in v0.2.0
func (*Resource) SetSpecValue ¶ added in v0.2.0
func (*Resource) SpecAsJSON ¶ added in v0.2.0
type ResourceRef ¶ added in v0.4.1
func NewResourceRef ¶ added in v0.4.1
func NewResourceRef(kind string, name string) ResourceRef
func (ResourceRef) Equal ¶ added in v0.4.1
func (ref ResourceRef) Equal(other ResourceRef) bool
func (ResourceRef) String ¶ added in v0.4.1
func (ref ResourceRef) String() string
type Resources ¶
type Resources []Resource
Resources represents a set of resources
type Server ¶ added in v0.4.1
type Server struct { Port int Registry Registry Parser WatchParser UserAgent string ResourcePath string OpenBrowser bool OnlySpec bool OutputFormat string // contains filtered or unexported fields }
func NewGrizzlyServer ¶ added in v0.4.0
func (*Server) ProxyRequestHandler ¶ added in v0.4.1
func (p *Server) ProxyRequestHandler(w http.ResponseWriter, r *http.Request)
ProxyRequestHandler handles the http request using proxy
func (*Server) RootHandler ¶ added in v0.4.1
func (p *Server) RootHandler(w http.ResponseWriter, _ *http.Request)
type SnapshotHandler ¶ added in v0.4.1
type SnapshotHandler interface { // Snapshot pushes a resource as a snapshot with an expiry Snapshot(resource Resource, expiresSeconds int) error }
SnapshotHandler describes a handler that has the ability to push a resource as a snapshot
type WatchParser ¶ added in v0.2.0
WatchParser encapsulates the action of parsing a resource (jsonnet or otherwise)
type WriterRecorder ¶ added in v0.4.1
type WriterRecorder struct {
// contains filtered or unexported fields
}
func NewWriterRecorder ¶ added in v0.4.1
func NewWriterRecorder(out io.Writer, eventFormatter EventFormatter) *WriterRecorder
func (*WriterRecorder) Record ¶ added in v0.4.1
func (recorder *WriterRecorder) Record(event Event)
func (*WriterRecorder) Summary ¶ added in v0.4.1
func (recorder *WriterRecorder) Summary() Summary
type YAMLParser ¶ added in v0.4.1
type YAMLParser struct {
// contains filtered or unexported fields
}
func NewYAMLParser ¶ added in v0.4.1
func NewYAMLParser(registry Registry) *YAMLParser
func (*YAMLParser) Accept ¶ added in v0.4.1
func (parser *YAMLParser) Accept(file string) bool
func (*YAMLParser) Parse ¶ added in v0.4.1
func (parser *YAMLParser) Parse(file string, options ParserOptions) (Resources, error)
Parse evaluates a YAML file and parses it into resources