Documentation ¶
Index ¶
- func BuiltinAssets() afero.Fs
- func CopyDir(srcFs afero.Fs, srcDirPath string, destFs afero.Fs, destDirPath string) error
- func CopyFile(srcFs afero.Fs, srcFilePath string, destFs afero.Fs, destFilePath string) error
- func CopyStructIfPtrSet(base interface{}, overlay interface{})
- func EnsureEmptyDatabaseFolder(dir string) error
- func FS() afero.Fs
- func GetOutboundIP() string
- func MergeMap(to, from map[string]interface{})
- func MergeStringArrays(base *[]string, overlay *[]string) *[]string
- func ParseAddress(datadir string, uri string) (address string, err error)
- func SetGlobal(a *Assets)
- func Validate(c *Configuration) error
- func WriteConfig(filename string, c *Configuration) error
- type App
- type Assets
- func (a *Assets) Abs(p string) string
- func (a *Assets) AddAdmin(username string) error
- func (a *Assets) Close() error
- func (a *Assets) DataAbs(p string) string
- func (a *Assets) DataDir() string
- func (a *Assets) IsAdmin(username string) bool
- func (a *Assets) LogDir() string
- func (a *Assets) PluginDir() string
- func (a *Assets) Reload() error
- func (a *Assets) RemAdmin(username string) error
- func (a *Assets) SwapAdmin(username, newname string) error
- type Configuration
- func (c *Configuration) Copy() *Configuration
- func (c *Configuration) GetAPI() string
- func (c *Configuration) GetActivePlugins() []string
- func (c *Configuration) GetAddr() string
- func (c *Configuration) GetObjectScope(objecttype string) (map[string]string, error)
- func (c *Configuration) GetObjectType(objecttype string) (*ObjectType, bool)
- func (c *Configuration) GetRequestBodyByteLimit() int64
- func (c *Configuration) GetRunTimeout() time.Duration
- func (c *Configuration) GetUserSettingsSchema() map[string]interface{}
- func (c *Configuration) InsertUserSettingsDefaults(prefs map[string]interface{}) (err error)
- func (c *Configuration) UserIsAdmin(username string) bool
- func (c *Configuration) ValidateObjectMeta(objecttype string, meta *map[string]interface{}) error
- func (c *Configuration) ValidateObjectMetaUpdate(objecttype string, meta map[string]interface{}) error
- func (c *Configuration) ValidateObjectMetaWithDefaults(objecttype string, meta map[string]interface{}) error
- func (c *Configuration) ValidateUserSettingsUpdate(prefs map[string]interface{}) (err error)
- type CreateOptions
- type Event
- type JSONSchema
- func (s *JSONSchema) InsertDefaults(data map[string]interface{})
- func (s *JSONSchema) Validate(data map[string]interface{}) error
- func (s *JSONSchema) ValidateAndInsertDefaults(data map[string]interface{}) (err error)
- func (s *JSONSchema) ValidateUpdate(data map[string]interface{}) (err error)
- func (s *JSONSchema) ValidateWithDefaults(data map[string]interface{}) (err error)
- type Object
- type ObjectType
- type Plugin
- type PrintOpen
- type Run
- type RunType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuiltinAssets ¶
BuiltinAssets prepares the assets built into the executable. If no such assets are found, it tries to find an assets folder, and use that, which is useful for debugging and development.
func CopyStructIfPtrSet ¶
func CopyStructIfPtrSet(base interface{}, overlay interface{})
CopyStructIfPtrSet copies all pointer params from overlay to base Does not touch arrays and things that don't have identical types
func EnsureEmptyDatabaseFolder ¶ added in v0.5.0
func GetOutboundIP ¶
func GetOutboundIP() string
https://stackoverflow.com/questions/23558425/how-do-i-get-the-local-ip-address-in-go Get preferred outbound ip of this machine
func MergeStringArrays ¶
MergeStringArrays allows merging arrays of strings, with the result having each element at most once, and special prefix of + being ignored, and - allowing removal from array
func ParseAddress ¶
Extracts the unix socket file and request path
func Validate ¶
func Validate(c *Configuration) error
func WriteConfig ¶
func WriteConfig(filename string, c *Configuration) error
WriteConfig writes the updates available in the given configuration to the given file. It overwrites just the updated values, leaving all others intact
Types ¶
type App ¶
type App struct { Name string `json:"name"` AutoCreate *bool `json:"auto_create,omitempty" hcl:"auto_create"` Unique *bool `json:"unique,omitempty" hcl:"unique"` AccessToken *bool `json:"access_token,omitempty" hcl:"access_token"` Description *string `json:"description,omitempty" hcl:"description"` Icon *string `json:"icon,omitempty" hcl:"icon"` Scope *string `json:"scope,omitempty" hcl:"scope"` Enabled *bool `json:"enabled,omitempty" hcl:"enabled"` Readonly *[]string `json:"readonly,omitempty" hcl:"readonly"` Settings *map[string]interface{} `json:"settings,omitempty"` SettingsSchema *map[string]interface{} `json:"settings_schema,omitempty"` Objects map[string]*Object `json:"objects,omitempty"` On []Event `hcl:"on,block" json:"on,omitempty"` }
App represents a app that is to be created on behalf of a plugin
type Assets ¶
type Assets struct { // FolderPath is the path where the database is installed. // it can be "" if we are running heedy in setup mode, // in which case it runs solely on builtin assets // This is the only thing that needs to be manually initialized. FolderPath string // An override to the configuration. It is merged on top of the root configuration // before any special processing ConfigOverride *Configuration // The active configuration. This is loaded automatically Config *Configuration // The overlay stack. index 0 represents built-in assets. Each index is just that stack element. Stack []afero.Fs // The overlay filesystems that include the builtin assets, as well as all // overrides from active plugins, and user overrides. It is loaded automatically FS afero.Fs // LogFile used for logging (if custom) LogFile *os.File }
Assets holds the information that comes from loading the database folder, merging it with the built-in assets, and combining
func Create ¶
func Create(opt CreateOptions) (*Assets, error)
Create takes a loaded configuration, as well as a target directory, and creates an associated heedy database. Can also optionally pass in the location of a configuration file which will be copied in, replacing the default config.
func Open ¶
func Open(configPath string, override *Configuration) (*Assets, error)
Open opens the assets in a given configuration path
type Configuration ¶
type Configuration struct { sync.RWMutex Addr *string `hcl:"addr" json:"addr,omitempty"` URL *string `hcl:"url" json:"url,omitempty"` API *string `hcl:"api" json:"api,omitempty"` ActivePlugins *[]string `hcl:"active_plugins" json:"active_plugins,omitempty"` AdminUsers *[]string `hcl:"admin_users" json:"admin_users,omitempty"` ForbiddenUsers *[]string `hcl:"forbidden_users" json:"forbidden_users,omitempty"` Language *string `hcl:"language" json:"language,omitempty"` FallbackLanguage *string `hcl:"fallback_language" json:"fallback_language,omitempty"` SQL *string `hcl:"sql" json:"sql,omitempty"` Frontend *string `json:"frontend,omitempty"` Preload *[]string `json:"preload,omitempty" hcl:"preload"` RunTimeout *string `json:"run_timeout,omitempty"` Scope *map[string]string `json:"scope,omitempty" hcl:"scope"` ObjectTypes map[string]ObjectType `json:"type,omitempty" hcl:"type"` RunTypes map[string]RunType `json:"runtype,omitempty"` RequestBodyByteLimit *int64 `hcl:"request_body_byte_limit" json:"request_body_byte_limit,omitempty"` AllowPublicWebsocket *bool `hcl:"allow_public_websocket" json:"allow_public_websocket,omitempty"` WebsocketHeartbeat *string `hcl:"websocket_heartbeat" json:"websocket_heartbeat,omitempty"` WebsocketWriteTimeout *string `hcl:"websocket_write_timeout" json:"websocket_write_timeout,omitempty"` Plugins map[string]*Plugin `json:"plugin,omitempty"` LogLevel *string `json:"log_level,omitempty" hcl:"log_level"` LogDir *string `json:"log_dir,omitempty" hcl:"log_dir"` // Schema for the core heedy settings UserSettingsSchema map[string]interface{} `json:"user_settings_schema,omitempty"` // The verbose option is not possible to set in config, it is passed as an arg. It is only here so that it is passed to plugins Verbose bool `json:"verbose,omitempty"` // contains filtered or unexported fields }
func LoadConfigBytes ¶
func LoadConfigBytes(src []byte, filename string) (*Configuration, error)
LoadConfigBytes loads the configuration from bytes
func LoadConfigFile ¶
func LoadConfigFile(filename string) (*Configuration, error)
LoadConfigFile loads configuration from file
func MergeConfig ¶
func MergeConfig(base *Configuration, overlay *Configuration) *Configuration
Merges two configurations together
func NewConfiguration ¶
func NewConfiguration() *Configuration
func (*Configuration) Copy ¶
func (c *Configuration) Copy() *Configuration
func (*Configuration) GetAPI ¶
func (c *Configuration) GetAPI() string
func (*Configuration) GetActivePlugins ¶
func (c *Configuration) GetActivePlugins() []string
func (*Configuration) GetAddr ¶
func (c *Configuration) GetAddr() string
func (*Configuration) GetObjectScope ¶
func (c *Configuration) GetObjectScope(objecttype string) (map[string]string, error)
GetObjectScope returns the map of scope
func (*Configuration) GetObjectType ¶
func (c *Configuration) GetObjectType(objecttype string) (*ObjectType, bool)
GetObjectType returns the given object type
func (*Configuration) GetRequestBodyByteLimit ¶
func (c *Configuration) GetRequestBodyByteLimit() int64
func (*Configuration) GetRunTimeout ¶
func (c *Configuration) GetRunTimeout() time.Duration
GetRunTimeout gets timeout for exec
func (*Configuration) GetUserSettingsSchema ¶
func (c *Configuration) GetUserSettingsSchema() map[string]interface{}
func (*Configuration) InsertUserSettingsDefaults ¶
func (c *Configuration) InsertUserSettingsDefaults(prefs map[string]interface{}) (err error)
func (*Configuration) UserIsAdmin ¶
func (c *Configuration) UserIsAdmin(username string) bool
UserIsAdmin checks if the given user is an admin
func (*Configuration) ValidateObjectMeta ¶
func (c *Configuration) ValidateObjectMeta(objecttype string, meta *map[string]interface{}) error
ValidateObjectMeta makes sure that objects have valid metadata
func (*Configuration) ValidateObjectMetaUpdate ¶
func (c *Configuration) ValidateObjectMetaUpdate(objecttype string, meta map[string]interface{}) error
ValidateObjectMetaUpdate makes sure that objects have valid metadata update queries
func (*Configuration) ValidateObjectMetaWithDefaults ¶
func (c *Configuration) ValidateObjectMetaWithDefaults(objecttype string, meta map[string]interface{}) error
ValidateObjectMetaWithDefaults validates the object, additionally setting required values to defaults
func (*Configuration) ValidateUserSettingsUpdate ¶
func (c *Configuration) ValidateUserSettingsUpdate(prefs map[string]interface{}) (err error)
type CreateOptions ¶ added in v0.5.1
type CreateOptions struct { Directory string `json:"directory,omitempty"` Config *Configuration `json:"config,omitempty"` ConfigFile string `json:"config_file,omitempty"` Plugins []string `json:"plugins,omitempty"` }
type Event ¶
type Event struct { Event string `hcl:"event,label" json:"event,omitempty"` Type *string `hcl:"type" json:"type,omitempty"` Tags *string `hcl:"tags" json:"tags,omitempty"` Plugin *string `hcl:"plugin" json:"plugin,omitempty"` Key *string `hcl:"key" json:"key,omitempty"` Post *string `hcl:"post" json:"post,omitempty"` }
type JSONSchema ¶
type JSONSchema struct { Schema map[string]interface{} // contains filtered or unexported fields }
func NewSchema ¶
func NewSchema(schema map[string]interface{}) (*JSONSchema, error)
func (*JSONSchema) InsertDefaults ¶
func (s *JSONSchema) InsertDefaults(data map[string]interface{})
func (*JSONSchema) Validate ¶
func (s *JSONSchema) Validate(data map[string]interface{}) error
Validate ensures that the passed data conforms to the given schema
func (*JSONSchema) ValidateAndInsertDefaults ¶
func (s *JSONSchema) ValidateAndInsertDefaults(data map[string]interface{}) (err error)
ValidateAndInsertDefaults both validates the given data, and inserts defaults for any missing values in the root object
func (*JSONSchema) ValidateUpdate ¶
func (s *JSONSchema) ValidateUpdate(data map[string]interface{}) (err error)
ValidateUpdate checks an update struct for validity, and resets deleted defaults
func (*JSONSchema) ValidateWithDefaults ¶
func (s *JSONSchema) ValidateWithDefaults(data map[string]interface{}) (err error)
ValidateWithDefaults assumes that defaults are given for missing entries for validation purposes. Does not modify the input data
type Object ¶
type Object struct { Name string `json:"name"` Type string `json:"type"` Description *string `json:"description,omitempty"` Icon *string `json:"icon,omitempty"` Meta *map[string]interface{} `json:"meta,omitempty"` OwnerScope *string `json:"owner_scope,omitempty"` Tags *string `json:"tags,omitempty"` AutoCreate *bool `json:"auto_create,omitempty" hcl:"auto_create"` On []Event `hcl:"on,block" json:"on,omitempty"` }
Object represents a object that is to be auto-created inside a app on behalf of a plugin
type ObjectType ¶
type ObjectType struct { Frontend *string `json:"frontend,omitempty" hcl:"frontend,block" cty:"frontend"` Routes *map[string]string `json:"routes,omitempty" hcl:"routes" cty:"routes"` MetaSchema *map[string]interface{} `json:"meta_schema,omitempty"` Scope *map[string]string `json:"scope,omitempty" hcl:"scope" cty:"scope"` // contains filtered or unexported fields }
func (*ObjectType) Copy ¶
func (s *ObjectType) Copy() ObjectType
func (*ObjectType) ValidateMeta ¶
func (s *ObjectType) ValidateMeta(meta *map[string]interface{}) (err error)
ValidateMeta checks the given metadata is valid
func (*ObjectType) ValidateMetaUpdate ¶
func (s *ObjectType) ValidateMetaUpdate(meta map[string]interface{}) (err error)
ValidateMetaUpdate validates an update query
func (*ObjectType) ValidateMetaWithDefaults ¶
func (s *ObjectType) ValidateMetaWithDefaults(meta map[string]interface{}) (err error)
ValidateMetaWithDefaults takes a meta value, and adds any required defaults to the root object if a default is provided.
type Plugin ¶
type Plugin struct { Version *string `hcl:"version" json:"version,omitempty"` Description *string `hcl:"description" json:"description,omitempty"` Icon *string `hcl:"icon" json:"icon,omitempty"` Homepage *string `hcl:"homepage" json:"homepage,omitempty"` License *string `hcl:"license" json:"license,omitempty"` HeedyVersion *string `hcl:"heedy_version" json:"heedy_version,omitempty"` Frontend *string `json:"frontend,omitempty" hcl:"frontend,block" cty:"frontend"` Preload *[]string `json:"preload,omitempty" hcl:"preload"` Routes *map[string]string `json:"routes,omitempty"` Events *map[string]string `json:"events,omitempty"` On []Event `hcl:"on,block" json:"on,omitempty"` Run map[string]Run `json:"run,omitempty"` Config map[string]interface{} `json:"config,omitempty"` ConfigSchema map[string]interface{} `json:"config_schema,omitempty"` UserSettingsSchema map[string]interface{} `json:"user_settings_schema,omitempty"` Apps map[string]*App `json:"apps,omitempty"` // contains filtered or unexported fields }