cloudconfig

package
v2.0.0-rc.10 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cloudconfig owns cloud.json persistence and runtime configuration primitives shared by the CLI and terminal UI.

Index

Constants

View Source
const (
	LabelSourceNone = "not set"
	LabelSourceFile = "read from cloud.json"
	LabelSourceEnv  = "set via ENGRAM_CLOUD_TOKEN"
)
View Source
const EnvCloudServer = "ENGRAM_CLOUD_SERVER"

EnvCloudServer is the environment variable that overrides cloud.json.server_url.

View Source
const EnvCloudToken = "ENGRAM_CLOUD_TOKEN"

EnvCloudToken is the environment variable that overrides cloud.json.token.

Variables

This section is empty.

Functions

func Path

func Path(dataDir string) string

Path returns the cloud configuration path under dataDir.

func Save

func Save(dataDir string, cfg *Config) error

Save persists cfg, creating dataDir when necessary.

func SourceLabel

func SourceLabel(source Source) string

SourceLabel returns the user-facing label for a token source.

func ValidateServerURL

func ValidateServerURL(raw string) (string, error)

ValidateServerURL accepts HTTP(S) server URLs with a host. Query and fragment components are rejected so stored runtime endpoints remain unambiguous.

Types

type Config

type Config struct {
	ServerURL string `json:"server_url"`
	Token     string `json:"token"`
}

Config is the on-disk cloud.json shape.

func ApplyServerOverride

func ApplyServerOverride(cfg *Config) *Config

ApplyServerOverride applies ENGRAM_CLOUD_SERVER when it is non-empty.

func Load

func Load(dataDir string) (*Config, error)

Load reads cloud.json. A missing file is a valid zero-value configuration.

type Source

type Source int

Source identifies where the effective cloud token came from.

const (
	SourceNone Source = iota
	SourceFile
	SourceEnv
)

func EffectiveToken

func EffectiveToken(dataDir string) (string, Source)

EffectiveToken resolves the environment token before the cloud.json fallback. A malformed configuration is treated as unavailable by this convenience API; callers that must surface parse failures should call Load first.

Jump to

Keyboard shortcuts

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