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 RollingFileLogger(config *LogConfig, logType string) io.Writer
- func SetProcessGroup(cmd *exec.Cmd)
- func UnmarshalStarlark(x starlark.Value) (val interface{}, err error)
- func UnquoteStarlark(x starlark.Value) (string, error)
- type AccountLink
- type AppApproveResponse
- type AppAuthnType
- type AppCreateResponse
- type AppDeleteResponse
- type AppEntry
- type AppFile
- type AppGetResponse
- type AppId
- type AppInfo
- type AppLinkAccountResponse
- type AppListResponse
- type AppMetadata
- type AppPathDomain
- type AppPreviewResponse
- type AppPromoteResponse
- type AppReloadResponse
- type AppResponse
- type AppSettings
- type AppStagedUpdateResponse
- type AppUpdateSettingsResponse
- type AppVersion
- type AppVersionFilesResponse
- type AppVersionListResponse
- type AppVersionSwitchResponse
- type ApproveResult
- type BoolValue
- type ClientConfig
- type CompressedReader
- type CreateAppRequest
- type GitAuthEntry
- type GlobalConfig
- type HttpClient
- type HttpConfig
- type HttpsConfig
- type Index
- type LogConfig
- type Logger
- type Marshaler
- type MetadataConfig
- type NewPluginFunc
- type Permission
- type PluginContext
- type PluginFunc
- type PluginInfo
- type PluginMap
- type PluginResponse
- func (r *PluginResponse) Attr(name string) (starlark.Value, error)
- func (r *PluginResponse) AttrNames() []string
- func (r *PluginResponse) Freeze()
- func (r *PluginResponse) Hash() (uint32, error)
- func (r *PluginResponse) String() string
- func (r *PluginResponse) Truth() starlark.Bool
- func (r *PluginResponse) Type() string
- func (r *PluginResponse) UnmarshalStarlarkType() (any, error)
- type PluginSettings
- type ReadableFS
- type RequestError
- type SecurityConfig
- type ServerConfig
- type StarlarkType
- func (s *StarlarkType) Attr(attr string) (starlark.Value, error)
- func (s *StarlarkType) AttrNames() []string
- func (s *StarlarkType) Freeze()
- func (s *StarlarkType) Hash() (uint32, error)
- func (s *StarlarkType) SetField(name string, val starlark.Value) error
- func (s *StarlarkType) String() string
- func (s *StarlarkType) Truth() starlark.Bool
- func (s *StarlarkType) Type() string
- func (s *StarlarkType) UnmarshalStarlarkType() (any, error)
- type StoreField
- type StoreInfo
- type StoreType
- type StringValue
- type SystemConfig
- type Transport
- type TypeBuilder
- type TypeName
- type TypeUnmarshaler
- type Unmarshaler
- type UpdateAppRequest
- type VersionMetadata
- type WritableFS
Constants ¶
const ( ApplicationJson = "application/json" ClaceServiceLocation = "clace" )
const ( PASSWORD_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#%^&*()_-+=<>?/|" PASSWORD_LENGTH = 16 BCRYPT_COST = 10 )
const ( ID_PREFIX_APP_PROD = "app_prd_" ID_PREFIX_APP_DEV = "app_dev_" ID_PREFIX_APP_STAGE = "app_stg_" ID_PREFIX_APP_PREVIEW = "app_pre_" INTERNAL_URL_PREFIX = "/_clace" APP_INTERNAL_URL_PREFIX = "/_clace_app" INTERNAL_APP_DELIM = "_cl_" STAGE_SUFFIX = INTERNAL_APP_DELIM + "stage" PREVIEW_SUFFIX = INTERNAL_APP_DELIM + "preview" )
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 RollingFileLogger ¶ added in v0.1.8
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 AccountLink ¶ added in v0.4.0
AccountLink links the account to use for each plugin
type AppApproveResponse ¶ added in v0.3.0
type AppApproveResponse struct { DryRun bool `json:"dry_run"` StagedUpdateResults []ApproveResult `json:"staged_update_results"` PromoteResults []AppPathDomain `json:"promote_results"` }
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 AppCreateResponse ¶ added in v0.3.0
type AppCreateResponse struct { DryRun bool `json:"dry_run"` ApproveResults []ApproveResult `json:"approve_results"` }
type AppDeleteResponse ¶ added in v0.3.0
type AppEntry ¶
type AppEntry struct { Id AppId `json:"id"` Path string `json:"path"` MainApp AppId `json:"main_app"` // the id of the app that this app is linked to Domain string `json:"domain"` SourceUrl string `json:"source_url"` IsDev bool `json:"is_dev"` UserID string `json:"user_id"` CreateTime *time.Time `json:"create_time"` UpdateTime *time.Time `json:"update_time"` Settings AppSettings `json:"settings"` // settings are not version controlled Metadata AppMetadata `json:"metadata"` // metadata is version controlled }
AppEntry is the application configuration in the DB
func (*AppEntry) AppPathDomain ¶ added in v0.3.0
func (ae *AppEntry) AppPathDomain() AppPathDomain
type AppGetResponse ¶ added in v0.4.0
type AppGetResponse struct {
AppEntry AppEntry `json:"app_entry"`
}
type AppInfo ¶ added in v0.3.0
type AppInfo struct { AppPathDomain Id AppId IsDev bool MainApp AppId }
AppInfo is the basic info for an app
type AppLinkAccountResponse ¶ added in v0.4.0
type AppLinkAccountResponse struct { DryRun bool `json:"dry_run"` StagedUpdateResults []AppPathDomain `json:"staged_update_results"` PromoteResults []AppPathDomain `json:"promote_results"` }
type AppListResponse ¶ added in v0.3.0
type AppListResponse struct {
Apps []AppResponse `json:"apps"`
}
type AppMetadata ¶ added in v0.3.0
type AppMetadata struct { VersionMetadata VersionMetadata `json:"version_metadata"` Loads []string `json:"loads"` Permissions []Permission `json:"permissions"` Accounts []AccountLink `json:"accounts"` }
AppMetadata contains the configuration for an app. App configurations are version controlled.
type AppPathDomain ¶
AppPathDomain is a unique identifier for an app, consisting of the path and domain
func CreateAppPathDomain ¶
func CreateAppPathDomain(path, domain string) AppPathDomain
func (AppPathDomain) String ¶ added in v0.3.0
func (a AppPathDomain) String() string
type AppPreviewResponse ¶ added in v0.3.0
type AppPreviewResponse struct { DryRun bool `json:"dry_run"` Success bool `json:"success"` ApproveResult ApproveResult `json:"approve_result"` }
type AppPromoteResponse ¶ added in v0.3.0
type AppPromoteResponse struct { DryRun bool `json:"dry_run"` PromoteResults []AppPathDomain `json:"promote_results"` }
type AppReloadResponse ¶ added in v0.3.0
type AppReloadResponse struct { DryRun bool `json:"dry_run"` ReloadResults []AppPathDomain `json:"reload_results"` ApproveResults []ApproveResult `json:"approve_results"` PromoteResults []AppPathDomain `json:"promote_results"` }
type AppResponse ¶ added in v0.3.0
type AppSettings ¶ added in v0.3.0
type AppSettings struct { AuthnType AppAuthnType `json:"authn_type"` GitAuthName string `json:"git_auth_name"` StageWriteAccess bool `json:"stage_write_access"` PreviewWriteAccess bool `json:"preview_write_access"` }
AppSettings contains the settings for an app. Settings are not version controlled.
type AppStagedUpdateResponse ¶ added in v0.4.1
type AppStagedUpdateResponse struct { DryRun bool `json:"dry_run"` StagedUpdateResults any `json:"staged_update_results"` PromoteResults []AppPathDomain `json:"promote_results"` }
type AppUpdateSettingsResponse ¶ added in v0.3.0
type AppUpdateSettingsResponse struct { DryRun bool `json:"dry_run"` UpdateResults []AppPathDomain `json:"update_results"` }
type AppVersion ¶ added in v0.4.1
type AppVersionFilesResponse ¶ added in v0.4.1
type AppVersionFilesResponse struct {
Files []AppFile `json:"files"`
}
type AppVersionListResponse ¶ added in v0.4.1
type AppVersionListResponse struct {
Versions []AppVersion `json:"versions"`
}
type AppVersionSwitchResponse ¶ added in v0.4.1
type ApproveResult ¶ added in v0.3.0
type ApproveResult struct { Id AppId `json:"id"` AppPathDomain AppPathDomain `json:"app_path_domain"` 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"` }
ApproveResult represents the result of an app approval 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 CompressedReader ¶ added in v0.3.0
type CreateAppRequest ¶
type CreateAppRequest struct { SourceUrl string `json:"source_url"` IsDev bool `json:"is_dev"` AppAuthn AppAuthnType `json:"app_authn"` GitBranch string `json:"git_branch"` GitCommit string `json:"git_commit"` GitAuthName string `json:"git_auth_name"` }
CreateAppRequest is the request body for creating an app
type GitAuthEntry ¶ added in v0.3.0
type GitAuthEntry struct { UserID string `toml:"user_id"` // the user id of the user, defaults to "git" https://github.com/src-d/go-git/issues/637 KeyFilePath string `toml:"key_file_path"` // the path to the private key file Password string `toml:"password"` // the password for the private key file }
GitAuth is a github auth config entry
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 NewPluginFunc ¶ added in v0.4.0
type NewPluginFunc func(pluginContext *PluginContext) (any, error)
type Permission ¶
type Permission struct { Plugin string `json:"plugin"` Method string `json:"method"` Arguments []string `json:"arguments"` IsRead *bool `json:"is_read,omitempty"` // Whether the call is a Read operation or Write operation. }
Permission represents a permission granted to an app to run a plugin method with the given arguments
type PluginContext ¶ added in v0.4.0
type PluginContext struct { Logger *Logger AppId AppId StoreInfo *StoreInfo Config PluginSettings }
type PluginFunc ¶ added in v0.4.0
PluginFunc is the Clace plugin function mapping to starlark function
type PluginInfo ¶ added in v0.4.0
type PluginInfo struct { ModuleName string // exec PluginPath string // exec.in FuncName string // run IsRead bool HandlerName string Builder NewPluginFunc }
PluginFuncInfo is the Clace plugin function info for the starlark function
type PluginMap ¶ added in v0.4.0
type PluginMap map[string]*PluginInfo
PluginMap is the plugin function mapping to PluginFuncs
type PluginResponse ¶ added in v0.4.0
type PluginResponse struct {
// contains filtered or unexported fields
}
PluginResponse is a starlark.Value that represents the response to a plugin request
func NewErrorCodeResponse ¶ added in v0.4.0
func NewErrorCodeResponse(errorCode int, err error, value any) *PluginResponse
func NewErrorResponse ¶ added in v0.4.0
func NewErrorResponse(err error) *PluginResponse
func NewResponse ¶ added in v0.4.0
func NewResponse(value any) *PluginResponse
func (*PluginResponse) Attr ¶ added in v0.4.0
func (r *PluginResponse) Attr(name string) (starlark.Value, error)
func (*PluginResponse) AttrNames ¶ added in v0.4.0
func (r *PluginResponse) AttrNames() []string
func (*PluginResponse) Freeze ¶ added in v0.4.0
func (r *PluginResponse) Freeze()
func (*PluginResponse) Hash ¶ added in v0.4.0
func (r *PluginResponse) Hash() (uint32, error)
func (*PluginResponse) String ¶ added in v0.4.0
func (r *PluginResponse) String() string
func (*PluginResponse) Truth ¶ added in v0.4.0
func (r *PluginResponse) Truth() starlark.Bool
func (*PluginResponse) Type ¶ added in v0.4.0
func (r *PluginResponse) Type() string
func (*PluginResponse) UnmarshalStarlarkType ¶ added in v0.4.0
func (r *PluginResponse) UnmarshalStarlarkType() (any, error)
type PluginSettings ¶ added in v0.4.0
type ReadableFS ¶ added in v0.2.0
type ReadableFS interface { fs.FS fs.ReadFileFS fs.GlobFS // Stat returns the stats for the named file. Stat(name string) (fs.FileInfo, error) Reset() // Used to reset the file system transaction for the DbFs, no-op for others StaticFiles() []string // Return list of static files }
WritableFS is the interface for the writable underlying file system used by AppFS
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 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"` GitAuth map[string]GitAuthEntry `toml:"git_auth"` Plugins map[string]PluginSettings `toml:"plugin"` }
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 StarlarkType ¶ added in v0.4.0
type StarlarkType struct {
// contains filtered or unexported fields
}
StarlarkType represents a Starlark type created from the schema type definition.
func NewStarlarkType ¶ added in v0.4.0
func NewStarlarkType(name string, data map[string]starlark.Value) *StarlarkType
func (*StarlarkType) Attr ¶ added in v0.4.0
func (s *StarlarkType) Attr(attr string) (starlark.Value, error)
func (*StarlarkType) AttrNames ¶ added in v0.4.0
func (s *StarlarkType) AttrNames() []string
func (*StarlarkType) Freeze ¶ added in v0.4.0
func (s *StarlarkType) Freeze()
func (*StarlarkType) Hash ¶ added in v0.4.0
func (s *StarlarkType) Hash() (uint32, error)
func (*StarlarkType) SetField ¶ added in v0.4.0
func (s *StarlarkType) SetField(name string, val starlark.Value) error
func (*StarlarkType) String ¶ added in v0.4.0
func (s *StarlarkType) String() string
func (*StarlarkType) Truth ¶ added in v0.4.0
func (s *StarlarkType) Truth() starlark.Bool
func (*StarlarkType) Type ¶ added in v0.4.0
func (s *StarlarkType) Type() string
func (*StarlarkType) UnmarshalStarlarkType ¶ added in v0.4.0
func (s *StarlarkType) UnmarshalStarlarkType() (any, error)
type StoreField ¶ added in v0.4.0
type StoreType ¶ added in v0.4.0
type StoreType struct { Name string Fields []StoreField Indexes []Index }
type StringValue ¶ added in v0.3.0
type StringValue string
const (
StringValueUndefined StringValue = "<CL_UNDEFINED>"
)
type SystemConfig ¶
type SystemConfig struct { TailwindCSSCommand string `toml:"tailwindcss_command"` 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 TypeBuilder ¶ added in v0.4.0
type TypeBuilder struct { Name string Fields []StoreField }
type TypeUnmarshaler ¶ added in v0.4.0
type TypeUnmarshaler interface { // UnmarshalStarlark unmarshals a starlark object to go object UnmarshalStarlarkType() (any, error) }
Unmarshaler is the interface use to unmarshal starlark custom types.
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.
type UpdateAppRequest ¶ added in v0.3.0
type UpdateAppRequest struct { AuthnType StringValue `json:"authn_type"` GitAuthName StringValue `json:"git_auth_name"` StageWriteAccess BoolValue `json:"stage_write_access"` PreviewWriteAccess BoolValue `json:"preview_write_access"` }
UpdateAppRequest is the request body for updating an app settings
func CreateUpdateAppRequest ¶ added in v0.3.0
func CreateUpdateAppRequest() UpdateAppRequest
type VersionMetadata ¶ added in v0.3.0
type VersionMetadata struct { Version int `json:"version"` PreviousVersion int `json:"previous_version"` GitBranch string `json:"git_branch"` GitCommit string `json:"git_commit"` GitMessage string `json:"git_message"` }
VersionMetadata contains the metadata for an app
type WritableFS ¶ added in v0.2.0
type WritableFS interface { ReadableFS Write(name string, bytes []byte) error Remove(name string) error }
WritableFS is the interface for the writable underlying file system used by AppFS