workspace

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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

View Source
const (
	StorageNone   = "none"
	StorageVolume = "volume"
	StorageBind   = "bind"
)

Storage modes.

View Source
const (
	TLSNone       = "none"
	TLSSelfSigned = "self-signed"
	TLSCustom     = "custom"
)

TLS modes.

View Source
const (
	ExposeMongoDB    = "mongodb"
	ExposeOpenSearch = "opensearch"
	ExposeDebug      = "debug"
	WithDashboards   = "dashboards"
)

Values for Expose and With.

View Source
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.

View Source
const ConfigFile = "openarch.yaml"

ConfigFile is the name of the workspace config file.

View Source
const DefaultDataDir = "./data"

DefaultDataDir is the data folder used with storage bind.

View Source
const DefaultVersion = "1.0.90"

DefaultVersion is the OpenArch image tag tested with this CLI.

View Source
const FallbackMemory int64 = 4 << 30

FallbackMemory is the budget used with memory auto when Docker does not report its memory.

View Source
const SchemaVersion = 1

SchemaVersion is the version of the openarch.yaml schema written by this CLI.

Variables

Functions

func DefaultPort

func DefaultPort(tlsMode string) int

DefaultPort returns the default host port for a TLS mode.

func Find

func Find(dir string) (string, error)

Find returns the workspace directory: dir if set, then OPENARCH_WORKSPACE, then the current directory.

func ParseMemory

func ParseMemory(s string) (int64, error)

ParseMemory parses "auto" or a size such as 4g or 4096m. It returns 0 for auto.

func ProjectName

func ProjectName(s string) string

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"`
	// InsecureBackends turns off authentication in MongoDB and the OpenSearch security plugin.
	InsecureBackends bool `yaml:"insecureBackends,omitempty" json:"insecureBackends,omitempty"`
	// DefaultUsers keeps the users bundled in the OpenArch image (password "password").
	DefaultUsers bool `yaml:"defaultUsers,omitempty" json:"defaultUsers,omitempty"`
}

Config is the content of openarch.yaml. JSON keys match the YAML keys.

func Default

func Default(name string) Config

Default returns the default config for a workspace called name.

func Load

func Load(path string) (Config, error)

Load reads and validates openarch.yaml from path.

func Parse

func Parse(data []byte, name string) (Config, error)

Parse decodes and validates openarch.yaml content. name is used in error messages.

func (Config) Has

func (c Config) Has(v string) bool

Has reports whether v is in Expose or With.

func (Config) HostPorts

func (c Config) HostPorts() []HostPort

HostPorts returns every port the workspace publishes on the host, main port first.

func (Config) Marshal

func (c Config) Marshal() []byte

Marshal encodes c as openarch.yaml content.

func (Config) ServiceNames

func (c Config) ServiceNames() []string

ServiceNames returns the names of Services, in the same order.

func (Config) Services

func (c Config) Services() []Service

Services returns the services that compose.yaml defines for c, in start order.

func (Config) TLSEnabled

func (c Config) TLSEnabled() bool

TLSEnabled reports whether HTTPS is served by the proxy.

func (Config) URL

func (c Config) URL() string

URL returns the OpenArch URL as seen from the host.

func (Config) Validate

func (c Config) Validate() error

Validate checks every field and returns a usage error for the first problem found.

func (Config) Warnings

func (c Config) Warnings() []string

Warnings returns the risky choices in the config. They do not make it invalid.

type HostPort

type HostPort struct {
	Name string `json:"name"`
	Port int    `json:"port"`
}

HostPort is a port published on the host.

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.

func SizingFor

func SizingFor(budget int64) Sizing

SizingFor returns the memory settings for a budget in bytes. The steps are estimates: the services need about 3 GiB to start, and more memory mostly helps OpenSearch and the OpenArch JVM.

type Storage

type Storage struct {
	Mode    string `yaml:"mode" json:"mode"`
	DataDir string `yaml:"dataDir,omitempty" json:"dataDir,omitempty"`
}

Storage selects where data is kept.

type TLS

type TLS struct {
	Mode string `yaml:"mode" json:"mode"`
	Cert string `yaml:"cert,omitempty" json:"cert,omitempty"`
	Key  string `yaml:"key,omitempty" json:"key,omitempty"`
}

TLS selects how HTTPS is served.

Jump to

Keyboard shortcuts

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