Documentation
¶
Overview ¶
Package workspace loads, validates and saves openarch.yaml, the source of truth of a workspace, and writes the files rendered from it.
Index ¶
- Constants
- Variables
- func DefaultPort(tlsMode string) int
- func FileSchemaVersion(data []byte) (int, error)
- func Find(dir string) (string, error)
- func ParseMemory(s string) (int64, error)
- func ProjectName(s string) string
- type Config
- func (c Config) Has(v string) bool
- func (c Config) HostPorts() []HostPort
- func (c Config) Marshal() []byte
- func (c Config) ServiceNames() []string
- func (c Config) Services() []Service
- func (c Config) TLSEnabled() bool
- func (c Config) URL() string
- func (c Config) Validate() error
- func (c Config) Warnings() []string
- type HostPort
- type Security
- type Service
- type Sizing
- type Storage
- type TLS
Constants ¶
const ( StorageNone = "none" StorageVolume = "volume" StorageBind = "bind" )
Storage modes.
const ( TLSNone = "none" TLSSelfSigned = "self-signed" TLSCustom = "custom" )
TLS modes.
const ( ExposeMongoDB = "mongodb" ExposeOpenSearch = "opensearch" ExposeDebug = "debug" WithDashboards = "dashboards" )
Values for Expose and With.
const ( HashVarApp = "OPENARCH_APP_CONFIG_HASH" HashVarMongoDB = "OPENARCH_MONGODB_CONFIG_HASH" HashVarOpenSearch = "OPENARCH_OPENSEARCH_CONFIG_HASH" HashVarDashboards = "OPENARCH_DASHBOARDS_CONFIG_HASH" HashVarProxy = "OPENARCH_PROXY_CONFIG_HASH" )
Hash variables used in compose.yaml labels.
const ConfigFile = "openarch.yaml"
ConfigFile is the name of the workspace config file.
const DefaultDataDir = "./data"
DefaultDataDir is the data folder used with storage bind.
const DefaultVersion = "1.0.90"
DefaultVersion is the OpenArch image tag tested with this CLI.
const FallbackMemory int64 = 4 << 30
FallbackMemory is the budget used with memory auto when Docker does not report its memory.
const SchemaVersion = 2
SchemaVersion is the version of the openarch.yaml schema written by this CLI. Every new key or changed key needs a new version and a migration in Parse, so that an older CLI stops with a clear error instead of an unknown key.
Variables ¶
var ( StorageModes = []string{StorageNone, StorageVolume, StorageBind} TLSModes = []string{TLSNone, TLSSelfSigned, TLSCustom} ExposeOptions = []string{ExposeMongoDB, ExposeOpenSearch, ExposeDebug} WithOptions = []string{WithDashboards} )
Functions ¶
func DefaultPort ¶
DefaultPort returns the default host port for a TLS mode.
func FileSchemaVersion ¶ added in v0.4.0
FileSchemaVersion returns the schemaVersion of openarch.yaml content, or 0 when the key is missing.
func Find ¶
Find returns the workspace directory: dir if set, then OPENARCH_WORKSPACE, then the current directory.
func ParseMemory ¶
ParseMemory parses "auto" or a size such as 4g or 4096m. It returns 0 for auto.
func ProjectName ¶
ProjectName turns s into a valid Docker Compose project name.
Types ¶
type Config ¶
type Config struct {
SchemaVersion int `yaml:"schemaVersion" json:"schemaVersion"`
Name string `yaml:"name" json:"name"`
Version string `yaml:"version" json:"version"`
Storage Storage `yaml:"storage" json:"storage"`
TLS TLS `yaml:"tls" json:"tls"`
ServerName string `yaml:"serverName" json:"serverName"`
Port int `yaml:"port" json:"port"`
BindIP string `yaml:"bindIP" json:"bindIP"`
Expose []string `yaml:"expose,omitempty" json:"expose,omitempty"`
With []string `yaml:"with,omitempty" json:"with,omitempty"`
Memory string `yaml:"memory" json:"memory"`
Security Security `yaml:"security" json:"security"`
}
Config is the content of openarch.yaml. JSON keys match the YAML keys.
func Parse ¶
Parse decodes and validates openarch.yaml content. name is used in error messages. A file with an older schemaVersion is migrated in memory.
func (Config) HostPorts ¶
HostPorts returns every port the workspace publishes on the host, main port first.
func (Config) ServiceNames ¶
ServiceNames returns the names of Services, in the same order.
func (Config) Services ¶
Services returns the services that compose.yaml defines for c, in start order.
func (Config) TLSEnabled ¶
TLSEnabled reports whether HTTPS is served by the proxy.
type Security ¶ added in v0.4.0
type Security struct {
// BackendAuth turns on authentication in MongoDB and the OpenSearch security plugin.
BackendAuth bool `yaml:"backendAuth" json:"backendAuth"`
// DefaultUsers keeps the users bundled in the OpenArch image (password "password").
DefaultUsers bool `yaml:"defaultUsers" json:"defaultUsers"`
}
Security holds the security features that can be turned off.
type Service ¶
type Service struct {
Name string
// OneShot services run once and exit. Exit code 0 is their healthy state.
OneShot bool
// HashVar is the environment variable that 'openarch up' sets to a hash of
// the files and secrets the service reads at start. The service has a label
// with its value, so a change recreates the container. Empty when unused.
HashVar string
}
Service is a service of the rendered compose.yaml.
type Sizing ¶
type Sizing struct {
// Budget is the memory the sizing was computed for, in bytes.
Budget int64 `json:"budget"`
// OpenArchHeap and OpenSearchHeap are JVM sizes such as 1g or 512m.
OpenArchHeap string `json:"openarchHeap"`
OpenSearchHeap string `json:"opensearchHeap"`
// MongoCacheGB is the WiredTiger cache size in GB.
MongoCacheGB string `json:"mongoCacheGB"`
}
Sizing holds the memory settings of the services.