Documentation ¶
Index ¶
- Constants
- func GenerateRandomPassword() (string, error)
- func GetDefaultConfigs() (*GlobalConfig, *ClientConfig, *ServerConfig, error)
- func IsEmptyStarlarkString(s starlark.String) bool
- func KillGroup(process *os.Process) error
- func LoadClientConfig(contents string, config *ClientConfig) error
- func LoadGlobalConfig(contents string, config *GlobalConfig) error
- func LoadServerConfig(contents string, config *ServerConfig) error
- func MarshalStarlark(data interface{}) (v starlark.Value, err error)
- func SetProcessGroup(cmd *exec.Cmd)
- func UnmarshalStarlark(x starlark.Value) (val interface{}, err error)
- func UnquoteStarlark(x starlark.Value) (string, error)
- type AppAuthnType
- type AppEntry
- type AppId
- type AppPathDomain
- type AuditResult
- type ClientConfig
- type CreateAppRequest
- type GlobalConfig
- type HttpClient
- type HttpConfig
- type HttpsConfig
- type LogConfig
- type Logger
- type Marshaler
- type Metadata
- type MetadataConfig
- type Permission
- type RequestError
- type Rules
- type SecurityConfig
- type ServerConfig
- type SystemConfig
- type Transport
- type Unmarshaler
Constants ¶
const ( ApplicationJson = "application/json" ClaceServiceLocation = "clace" )
const ( PASSWORD_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#%^&*()_-+=<>?/|" PASSWORD_LENGTH = 16 BCRYPT_COST = 10 )
const ( INTERNAL_URL_PREFIX = "/_clace" APP_INTERNAL_URL_PREFIX = "/_clace_app" )
const DEFAULT_CONFIG = "clace.default.toml"
const Scheme = "http+unix"
Scheme is the URL scheme used for HTTP over UNIX domain sockets.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomPassword ¶
GenerateRandomPassword generates a random password
func GetDefaultConfigs ¶
func GetDefaultConfigs() (*GlobalConfig, *ClientConfig, *ServerConfig, error)
func IsEmptyStarlarkString ¶
IsEmptyStarlarkString checks is a starlark string is empty ("" for a go string) starlark.String.String performs repr-style quotation, which is necessary for the starlark.Value contract but a frequent source of errors in API clients. This helper method makes sure it'll work properly
func LoadClientConfig ¶
func LoadClientConfig(contents string, config *ClientConfig) error
LoadClientConfig load a ClientConfig from the given contents
func LoadGlobalConfig ¶
func LoadGlobalConfig(contents string, config *GlobalConfig) error
LoadGlobalConfig load a GlobalConfig from the given contents
func LoadServerConfig ¶
func LoadServerConfig(contents string, config *ServerConfig) error
LoadServerConfig loads a ServerConfig from the given contents
func MarshalStarlark ¶
MarshalStarlark turns go values into starlark types
func SetProcessGroup ¶
SetProcessGroup sets the process group flag for the command
func UnmarshalStarlark ¶
UnmarshalStarlark decodes a starlark.Value into it's golang counterpart
Types ¶
type AppAuthnType ¶
type AppAuthnType string
AppAuthnType is the app level authentication type
const ( AppAuthnDefault AppAuthnType = "default" // Use whatever auth is the default for the system AppAuthnNone AppAuthnType = "none" // No auth )
type AppEntry ¶
type AppEntry struct { Id AppId `json:"id"` Path string `json:"path"` Domain string `json:"domain"` SourceUrl string `json:"source_url"` FsPath string `json:"fs_path"` IsDev bool `json:"is_dev"` AutoSync bool `json:"auto_sync"` AutoReload bool `json:"auto_reload"` UserID string `json:"user_id"` CreateTime *time.Time `json:"create_time"` UpdateTime *time.Time `json:"update_time"` Rules Rules `json:"rules"` Metadata Metadata `json:"metadata"` Loads []string `json:"loads"` Permissions []Permission `json:"permissions"` }
AppEntry is the application configuration in the DB
type AppPathDomain ¶
AppPathDomain is a unique identifier for an app, consisting of the path and domain
func CreateAppPathDomain ¶
func CreateAppPathDomain(path, domain string) AppPathDomain
type AuditResult ¶
type AuditResult struct { Id AppId `json:"id"` NewLoads []string `json:"new_loads"` NewPermissions []Permission `json:"new_permissions"` ApprovedLoads []string `json:"approved_loads"` ApprovedPermissions []Permission `json:"approved_permissions"` NeedsApproval bool `json:"needs_approval"` }
AuditResult represents the result of an app audit
type ClientConfig ¶
type ClientConfig struct { GlobalConfig SkipCertCheck bool `toml:"skip_cert_check"` AdminPassword string `toml:"admin_password"` }
ClientConfig is the configuration for the Clace Client
func NewClientConfigEmbedded ¶
func NewClientConfigEmbedded() (*ClientConfig, error)
NewClientConfigEmbedded reads the embedded toml file and creates a ClientConfig
type CreateAppRequest ¶
type CreateAppRequest struct { SourceUrl string `json:"source_url"` IsDev bool `json:"is_dev"` AutoSync bool `json:"auto_sync"` AutoReload bool `json:"auto_reload"` AppAuthn AppAuthnType `json:"app_authn"` }
CreateAppRequest is the request body for creating an app
type GlobalConfig ¶
type GlobalConfig struct { ConfigFile string `toml:"config_file"` AdminUser string `toml:"admin_user"` ServerUri string `toml:"server_uri"` }
Config entries shared between client and server
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶
func NewHttpClient(serverUri, user, password string, skipCertCheck bool) *HttpClient
NewHttpClient creates a new HttpClient instance
type HttpConfig ¶
HttpConfig is the configuration for the HTTP server
type HttpsConfig ¶
type HttpsConfig struct { Host string `toml:"host"` Port int `toml:"port"` EnableCertLookup bool `toml:"enable_cert_lookup"` ServiceEmail string `toml:"service_email"` UseStaging bool `toml:"use_staging"` StorageLocation string `toml:"storage_location"` CertLocation string `toml:"cert_location"` }
HttpsConfig is the configuration for the HTTPs server
type LogConfig ¶
type LogConfig struct { Level string `toml:"level"` MaxBackups int `toml:"max_backups"` MaxSizeMB int `toml:"max_size_mb"` Console bool `toml:"console"` File bool `toml:"file"` }
LogConfig is the configuration for the Logger
type Marshaler ¶
type Marshaler interface { // MarshalStarlark marshal a custom type to starlark object. MarshalStarlark() (starlark.Value, error) }
Marshaler is the interface use to marshal starlark custom types.
type MetadataConfig ¶
type MetadataConfig struct { DBConnection string `toml:"db_connection"` AutoUpgrade bool `toml:"auto_upgrade"` }
MetadataConfig is the configuration for the Metadata persistence layer
type Permission ¶
Permission represents a permission granted to an app to run a plugin method with the given arguments
type RequestError ¶
RequestError is the error returned by the API
func CreateRequestError ¶
func CreateRequestError(message string, code int) RequestError
func (RequestError) Error ¶
func (r RequestError) Error() string
type Rules ¶
type Rules struct {
AuthnType AppAuthnType `json:"authn_type"`
}
Rules contains the authentication and authorization rules for an app
type SecurityConfig ¶
type SecurityConfig struct { AdminOverTCP bool `toml:"admin_over_tcp"` AdminPasswordBcrypt string `toml:"admin_password_bcrypt"` }
SecurityConfig is the configuration for Inter process communication
type ServerConfig ¶
type ServerConfig struct { GlobalConfig Http HttpConfig `toml:"http"` Https HttpsConfig `toml:"https"` Security SecurityConfig `toml:"security"` Metadata MetadataConfig `toml:"metadata"` Log LogConfig `toml:"logging"` System SystemConfig `toml:"system"` }
ServerConfig is the configuration for the Clace Server
func NewServerConfigEmbedded ¶
func NewServerConfigEmbedded() (*ServerConfig, error)
NewServerConfigEmbedded reads the embedded toml file and creates a ServerConfig
type SystemConfig ¶
type SystemConfig struct { TailwindCSSCommand string `toml:"tailwindcss_command"` DisableFileHashDevMode bool `toml:"disable_file_hash_dev_mode"` FileWatcherDebounceMillis int `toml:"file_watcher_debounce_millis"` NodePath string `toml:"node_path"` }
SystemConfig is the system level configuration
type Transport ¶
type Transport struct { // DialTimeout is deprecated. Use context instead. DialTimeout time.Duration // RequestTimeout is deprecated and has no effect. RequestTimeout time.Duration // ResponseHeaderTimeout is deprecated. Use context instead. ResponseHeaderTimeout time.Duration // contains filtered or unexported fields }
Transport is a http.RoundTripper that connects to Unix domain sockets.
func (*Transport) RegisterLocation ¶
RegisterLocation registers an URL location and maps it to the given file system path.
Calling RegisterLocation twice for the same location is a programmer error, and causes a panic.
type Unmarshaler ¶
type Unmarshaler interface { // UnmarshalStarlark unmarshal a starlark object to custom type. UnmarshalStarlark(starlark.Value) error }
Unmarshaler is the interface use to unmarshal starlark custom types.