types

package
v0.6.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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"
	NO_SOURCE               = "-" // No source url is provided
)
View Source
const (
	TL_CONTEXT                  = "TL_context"
	TL_DEFER_MAP                = "TL_defer_map"
	TL_CURRENT_MODULE_FULL_PATH = "TL_current_module_full_path"
	TL_PLUGIN_API_FAILED_ERROR  = "TL_plugin_api_failed_error"
)
View Source
const (
	CONTAINER_SOURCE_AUTO         = "auto"
	CONTAINER_SOURCE_NIXPACKS     = "nixpacks"
	CONTAINER_SOURCE_IMAGE_PREFIX = "image:"
)

Variables

This section is empty.

Functions

func RollingFileLogger

func RollingFileLogger(config *LogConfig, logType string) io.Writer

Types

type AccountLink struct {
	Plugin      string `json:"plugin"`
	AccountName string `json:"account_name"`
}

AccountLink links the account to use for each plugin

type AppApproveResponse

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 (
	AppAuthnNone    AppAuthnType = "none"    // No auth
	AppAuthnDefault AppAuthnType = "default" // Use whatever auth is the default for the system
	AppAuthnSystem  AppAuthnType = "system"  // Use the system admin user
)

type AppCreateResponse

type AppCreateResponse struct {
	DryRun         bool            `json:"dry_run"`
	ApproveResults []ApproveResult `json:"approve_results"`
}

type AppDeleteResponse

type AppDeleteResponse struct {
	DryRun  bool      `json:"dry_run"`
	AppInfo []AppInfo `json:"app_info"`
}

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

func (ae *AppEntry) AppPathDomain() AppPathDomain

func (*AppEntry) String

func (ae *AppEntry) String() string

type AppFile

type AppFile struct {
	Name string
	Etag string
	Size int64
}

type AppGetResponse

type AppGetResponse struct {
	AppEntry AppEntry `json:"app_entry"`
}

type AppId

type AppId string

AppId is the identifier for an App

type AppInfo

type AppInfo struct {
	AppPathDomain
	Id      AppId
	IsDev   bool
	MainApp AppId
}

AppInfo is the basic info for an app

func CreateAppInfo

func CreateAppInfo(id AppId, path, domain string, isDev bool, mainApp AppId) AppInfo

type AppLinkAccountResponse

type AppLinkAccountResponse struct {
	DryRun              bool            `json:"dry_run"`
	StagedUpdateResults []AppPathDomain `json:"staged_update_results"`
	PromoteResults      []AppPathDomain `json:"promote_results"`
}

type AppListResponse

type AppListResponse struct {
	Apps []AppResponse `json:"apps"`
}

type AppMetadata

type AppMetadata struct {
	VersionMetadata VersionMetadata   `json:"version_metadata"`
	Loads           []string          `json:"loads"`
	Permissions     []Permission      `json:"permissions"`
	Accounts        []AccountLink     `json:"accounts"`
	ParamValues     map[string]string `json:"param_values"`
	Spec            AppSpec           `json:"spec"`
	SpecFiles       *SpecFiles        `json:"spec_files"`
}

AppMetadata contains the configuration for an app. App configurations are version controlled.

type AppPathDomain

type AppPathDomain struct {
	Path   string
	Domain string
}

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

func (a AppPathDomain) String() string

type AppPreviewResponse

type AppPreviewResponse struct {
	DryRun        bool          `json:"dry_run"`
	Success       bool          `json:"success"`
	ApproveResult ApproveResult `json:"approve_result"`
}

type AppPromoteResponse

type AppPromoteResponse struct {
	DryRun         bool            `json:"dry_run"`
	PromoteResults []AppPathDomain `json:"promote_results"`
}

type AppReloadResponse

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

type AppResponse struct {
	AppEntry
	StagedChanges bool `json:"staged_changes"`
}

type AppSettings

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 AppSpec

type AppSpec string

type AppStagedUpdateResponse

type AppStagedUpdateResponse struct {
	DryRun              bool            `json:"dry_run"`
	StagedUpdateResults any             `json:"staged_update_results"`
	PromoteResults      []AppPathDomain `json:"promote_results"`
}

type AppUpdateMetadataResponse

type AppUpdateMetadataResponse struct {
	DryRun              bool            `json:"dry_run"`
	StagedUpdateResults []AppPathDomain `json:"staged_update_results"`
	PromoteResults      []AppPathDomain `json:"promote_results"`
}

type AppUpdateSettingsResponse

type AppUpdateSettingsResponse struct {
	DryRun        bool            `json:"dry_run"`
	UpdateResults []AppPathDomain `json:"update_results"`
}

type AppVersion

type AppVersion struct {
	Active          bool
	AppId           AppId
	Version         int
	PreviousVersion int
	UserId          string
	Metadata        *AppMetadata
	CreateTime      time.Time
}

type AppVersionFilesResponse

type AppVersionFilesResponse struct {
	Files []AppFile `json:"files"`
}

type AppVersionListResponse

type AppVersionListResponse struct {
	Versions []AppVersion `json:"versions"`
}

type AppVersionSwitchResponse

type AppVersionSwitchResponse struct {
	DryRun      bool `json:"dry_run"`
	FromVersion int  `json:"from_version"`
	ToVersion   int  `json:"to_version"`
}

type ApproveResult

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 AuthConfig

type AuthConfig struct {
	Key          string   `toml:"key"`           // the client id
	Secret       string   `toml:"secret"`        // the client secret
	OrgUrl       string   `toml:"org_url"`       // the org url, used for Okta
	Domain       string   `toml:"domain"`        // the domain, used for Auth0
	DiscoveryUrl string   `toml:"discovery_url"` // the discovery url, used for OIDC
	HostedDomain string   `toml:"hosted_domain"` // the hosted domain, used for Google
	Scopes       []string `toml:"scopes"`        // oauth scopes
}

AuthConfig is the configuration for the Authentication provider

type BoolValue

type BoolValue int
const (
	BoolValueUndefined BoolValue = iota
	BoolValueTrue
	BoolValueFalse
)

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

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"`
	Spec        AppSpec           `json:"spec"`
	ParamValues map[string]string `json:"param_values"`
}

CreateAppRequest is the request body for creating an app

type GitAuthEntry

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 HttpConfig

type HttpConfig struct {
	Host string `toml:"host"`
	Port int    `toml:"port"`
}

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"`
	AccessLogging bool   `toml:"access_logging"`
}

LogConfig is the configuration for the Logger

type Logger

type Logger struct {
	*zerolog.Logger
}

func NewLogger

func NewLogger(config *LogConfig) *Logger

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

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

type PluginContext struct {
	Logger    *Logger
	AppId     AppId
	StoreInfo *starlark_type.StoreInfo
	Config    PluginSettings
}

type PluginSettings

type PluginSettings map[string]any

type RequestError

type RequestError struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

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"`
	AppDefaultAuthType  string `toml:"app_default_auth_type"`
	SessionSecret       string `toml:"session_secret"`
	SessionMaxAge       int    `toml:"session_max_age"`
	SessionHttpsOnly    bool   `toml:"session_https_only"`
	CallbackUrl         string `toml:"callback_url"`
}

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"`
	Auth        map[string]AuthConfig     `toml:"auth"`
	ProfileMode string                    `toml:"profile_mode"`
}

ServerConfig is the configuration for the Clace Server

type SpecFiles

type SpecFiles map[string]string

SpecFiles is a map of file names to file data. JSON encoding uses base 64 encoding of file text

func (*SpecFiles) MarshalJSON

func (t *SpecFiles) MarshalJSON() ([]byte, error)

func (*SpecFiles) UnmarshalJSON

func (t *SpecFiles) UnmarshalJSON(data []byte) error

type StringValue

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"`
	ContainerCommand          string `toml:"container_command"`
}

SystemConfig is the system level configuration

type Transaction

type Transaction struct {
	*sql.Tx
}

Transaction is a wrapper around sql.Tx

func (*Transaction) IsInitialized

func (t *Transaction) IsInitialized() bool

type UpdateAppMetadataRequest

type UpdateAppMetadataRequest struct {
	Spec StringValue `json:"spec"`
}

UpdateAppMetadataRequest is the request body for updating an app metadata

type UpdateAppRequest

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"`
	Spec               StringValue `json:"spec"`
}

UpdateAppRequest is the request body for updating an app settings

func CreateUpdateAppMetadataRequest

func CreateUpdateAppMetadataRequest() UpdateAppRequest

func CreateUpdateAppRequest

func CreateUpdateAppRequest() UpdateAppRequest

type VersionMetadata

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL