config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextOptionSSHAddPrivateKeys          = "SSH_ADD_PRIVATE_KEYS"
	ContextOptionGPGAgentForwarding         = "GPG_AGENT_FORWARDING"
	ContextOptionGitSSHSignatureForwarding  = "GIT_SSH_SIGNATURE_FORWARDING"
	ContextOptionSSHInjectDockerCredentials = "SSH_INJECT_DOCKER_CREDENTIALS"
	ContextOptionSSHInjectGitCredentials    = "SSH_INJECT_GIT_CREDENTIALS"
	ContextOptionExitAfterTimeout           = "EXIT_AFTER_TIMEOUT"
	ContextOptionTelemetry                  = "TELEMETRY"
	ContextOptionAgentURL                   = "AGENT_URL"
	ContextOptionDotfilesURL                = "DOTFILES_URL"
	ContextOptionDotfilesScript             = "DOTFILES_SCRIPT"
	ContextOptionSSHAgentForwarding         = "SSH_AGENT_FORWARDING"
	ContextOptionSSHConfigPath              = "SSH_CONFIG_PATH"
	ContextOptionSSHConfigIncludePath       = "SSH_CONFIG_INCLUDE_PATH"
	ContextOptionAgentInjectTimeout         = "AGENT_INJECT_TIMEOUT"
	ContextOptionRegistryCache              = "REGISTRY_CACHE"
	ContextOptionSSHStrictHostKeyChecking   = "SSH_STRICT_HOST_KEY_CHECKING"
)
View Source
const (
	BoolTrue  = "true"
	BoolFalse = "false"
)

BoolTrue and BoolFalse are the string representations used for boolean configuration values throughout the application (env vars, options, agent config).

View Source
const (
	// EnvBinaryPath is set to the path of the Devsy binary.
	EnvBinaryPath = "DEVSY"

	// EnvHome overrides the default Devsy home directory.
	EnvHome = "DEVSY_HOME"

	// EnvConfig overrides the default config file path.
	EnvConfig = "DEVSY_CONFIG"

	// EnvUI indicates the desktop UI is active.
	EnvUI = "DEVSY_UI"

	// EnvDebug enables debug logging.
	EnvDebug = "DEVSY_DEBUG"

	// EnvDisableTelemetry disables telemetry collection.
	EnvDisableTelemetry = "DEVSY_DISABLE_TELEMETRY"

	// EnvAgentURL overrides the agent download URL.
	EnvAgentURL = "DEVSY_AGENT_URL"

	// EnvAgentPreferDownload forces agent binary download even if a local copy exists.
	EnvAgentPreferDownload = "DEVSY_AGENT_PREFER_DOWNLOAD"

	// EnvOS is set to the host operating system (runtime.GOOS).
	EnvOS = "DEVSY_OS"

	// EnvArch is set to the host architecture (runtime.GOARCH).
	EnvArch = "DEVSY_ARCH"

	// EnvLogLevel is set to the current log level.
	EnvLogLevel = "DEVSY_LOG_LEVEL"

	// EnvWorkspaceID is the current workspace identifier.
	EnvWorkspaceID = "DEVSY_WORKSPACE_ID"

	// EnvWorkspaceUID is the current workspace unique identifier.
	EnvWorkspaceUID = "DEVSY_WORKSPACE_UID"

	// EnvWorkspaceDaemonConfig holds the workspace daemon configuration.
	EnvWorkspaceDaemonConfig = "DEVSY_WORKSPACE_DAEMON_CONFIG"

	// EnvWorkspaceCredentialsPort is the workspace credentials server port.
	EnvWorkspaceCredentialsPort = "DEVSY_WORKSPACE_CREDENTIALS_PORT" // #nosec G101

	// EnvCredentialsServerPort is the credentials server port on the host side.
	EnvCredentialsServerPort = "DEVSY_CREDENTIALS_SERVER_PORT" // #nosec G101

	// EnvGitHelperPort is the git credential helper forwarding port.
	EnvGitHelperPort = "DEVSY_GIT_HELPER_PORT"

	// EnvCraneName overrides the crane binary name.
	EnvCraneName = "DEVSY_CRANE_NAME"

	// EnvPlatformOptions holds serialized platform options.
	EnvPlatformOptions = "DEVSY_PLATFORM_OPTIONS"

	// EnvFlagsUp holds extra flags for the up command.
	EnvFlagsUp = "DEVSY_FLAGS_UP"

	// EnvFlagsSSH holds extra flags for the ssh command.
	EnvFlagsSSH = "DEVSY_FLAGS_SSH"

	// EnvFlagsDelete holds extra flags for the delete command.
	EnvFlagsDelete = "DEVSY_FLAGS_DELETE"

	// EnvFlagsStatus holds extra flags for the status command.
	EnvFlagsStatus = "DEVSY_FLAGS_STATUS"

	// EnvSubdomain is the subdomain configuration for Devsy Pro.
	EnvSubdomain = "DEVSY_SUBDOMAIN"

	// EnvPrefix is the base prefix for all Devsy environment variables.
	EnvPrefix = "DEVSY_"

	// EnvIDEPrefix is the prefix for IDE-specific option env vars (append IDE name + "_").
	EnvIDEPrefix = EnvPrefix + "IDE_"

	// EnvProviderPrefix is the prefix for provider-specific option env vars (append provider name + "_").
	EnvProviderPrefix = EnvPrefix + "PROVIDER_"

	// EnvProviderWorkspaceID is the workspace identifier passed to providers.
	EnvProviderWorkspaceID = "WORKSPACE_ID"

	// EnvProviderWorkspaceUID is the workspace UID passed to providers.
	EnvProviderWorkspaceUID = "WORKSPACE_UID"

	// EnvProviderWorkspacePicture is the workspace picture URL passed to providers.
	EnvProviderWorkspacePicture = "WORKSPACE_PICTURE"

	// EnvProviderWorkspaceFolder is the workspace folder path passed to providers.
	EnvProviderWorkspaceFolder = "WORKSPACE_FOLDER"

	// EnvProviderWorkspaceContext is the workspace context passed to providers.
	EnvProviderWorkspaceContext = "WORKSPACE_CONTEXT"

	// EnvProviderWorkspaceOrigin is the workspace origin passed to providers.
	EnvProviderWorkspaceOrigin = "WORKSPACE_ORIGIN"

	// EnvProviderWorkspaceSource is the workspace source passed to providers.
	EnvProviderWorkspaceSource = "WORKSPACE_SOURCE"

	// EnvProviderWorkspaceProvider is the workspace provider name passed to providers.
	EnvProviderWorkspaceProvider = "WORKSPACE_PROVIDER"

	// EnvProviderMachineID is the machine identifier passed to providers.
	EnvProviderMachineID = "MACHINE_ID"

	// EnvProviderMachineContext is the machine context passed to providers.
	EnvProviderMachineContext = "MACHINE_CONTEXT"

	// EnvProviderMachineFolder is the machine folder path passed to providers.
	EnvProviderMachineFolder = "MACHINE_FOLDER"

	// EnvProviderMachineProvider is the machine provider name passed to providers.
	EnvProviderMachineProvider = "MACHINE_PROVIDER"

	// EnvProviderID is the provider identifier passed to providers.
	EnvProviderID = "PROVIDER_ID"

	// EnvProviderContext is the provider context passed to providers.
	EnvProviderContext = "PROVIDER_CONTEXT"

	// EnvProviderFolder is the provider folder path passed to providers.
	EnvProviderFolder = "PROVIDER_FOLDER"

	// EnvLoftProject is the Devsy project name for pro features.
	EnvLoftProject = "DEVSY_PROJECT"

	// EnvLoftFilterByOwner enables filtering by owner in Devsy.
	EnvLoftFilterByOwner = "DEVSY_FILTER_BY_OWNER"

	// EnvDevcontainerID is the devcontainer identifier.
	EnvDevcontainerID = "DEVCONTAINER_ID"
)

Environment variable constants used throughout the application. All constants follow the EnvXxx naming convention.

View Source
const (
	// IgnoreFileName is the name of the devsy ignore file.
	IgnoreFileName = "." + BinaryName + "ignore"

	// SSHSignatureHelperPath is the path to the SSH signature helper script.
	SSHSignatureHelperPath = "/usr/local/bin/" + BinaryName + "-ssh-signature"

	// SSHSignatureHelperName is the name used in git config for the SSH signature program.
	SSHSignatureHelperName = BinaryName + "-ssh-signature"

	// DockerCredentialHelperName is the docker credential helper binary name.
	DockerCredentialHelperName = "docker-credential-" + BinaryName

	// DevContainerResultPath is where devcontainer results are written.
	DevContainerResultPath = "/var/run/" + BinaryName + "/result.json"

	// DaemonProcessName is the name used for the fallback background daemon process
	// PID file and lock file in os.TempDir().
	DaemonProcessName = BinaryName + ".daemon"
)
View Source
const (
	// ProductName is the display name for the product.
	ProductName = "Devsy"

	// ProductNamePro is the display name for the Pro product.
	ProductNamePro = ProductName + " Pro"

	// DaemonServiceDescription is the system daemon service description.
	DaemonServiceDescription = ProductName + " Agent Service"
)
View Source
const (
	RepoOwner         = "devsy-org"
	RepoName          = "devsy"
	RepoSlug          = RepoOwner + "/" + RepoName
	GitHubRepoURL     = "https://github.com/" + RepoSlug
	GitHubReleasesURL = GitHubRepoURL + "/releases"
	GitHubAPIUserURL  = "https://api.github.com/users/" + RepoOwner
	ProviderPrefix    = RepoName + "-provider-"

	// ProReleaseName is the Helm release / product name for Devsy Pro.
	ProReleaseName = RepoName + "-pro"

	// BinaryName is the CLI binary base name used in downloads and SSH host suffixes.
	BinaryName = RepoName

	// SSHHostSuffix is appended to workspace IDs for SSH config host entries.
	SSHHostSuffix = "." + BinaryName

	// WebsiteBaseURL is the project website used for asset URLs.
	WebsiteBaseURL = "https://" + RepoName + ".sh"

	// WebsiteAssetsURL is the base URL for icon/image assets.
	WebsiteAssetsURL = WebsiteBaseURL + "/assets"
)
View Source
const ConfigDirName = "." + RepoName

ConfigDirName is the hidden directory name used for Devsy configuration.

View Source
const DefaultContext = "default"

Variables

View Source
var ConfigFile = "config.yaml"
View Source
var ContextOptions = []ContextOption{
	{
		Name:        ContextOptionSSHAddPrivateKeys,
		Description: "Specifies if Devsy should automatically add ssh-keys to the ssh-agent",
		Default:     "true",
		Enum:        []string{"true", "false"},
	},
	{
		Name:        ContextOptionExitAfterTimeout,
		Description: "Specifies if Devsy should exit the process after the browser has been idle for a minute",
		Default:     "true",
		Enum:        []string{"true", "false"},
	},
	{
		Name:        ContextOptionGPGAgentForwarding,
		Description: "Specifies if Devsy should do gpg-agent forwarding by default for ssh",
		Default:     "false",
		Enum:        []string{"true", "false"},
	},
	{
		Name:        ContextOptionGitSSHSignatureForwarding,
		Description: "Specifies if Devsy should automatically detect ssh signature git setting and inject ssh signature helper",
		Default:     "true",
		Enum:        []string{"true", "false"},
	},
	{
		Name:        ContextOptionSSHInjectDockerCredentials,
		Description: "Specifies if Devsy should inject docker credentials into the workspace",
		Default:     "true",
		Enum:        []string{"true", "false"},
	},
	{
		Name:        ContextOptionSSHInjectGitCredentials,
		Description: "Specifies if Devsy should inject git credentials into the workspace",
		Default:     "true",
		Enum:        []string{"true", "false"},
	},
	{
		Name:        ContextOptionSSHAgentForwarding,
		Description: "Specifies if Devsy should do agent forwarding by default into the workspace",
		Default:     "true",
		Enum:        []string{"true", "false"},
	},
	{
		Name:        ContextOptionTelemetry,
		Description: "Specifies if Devsy should send telemetry information",
		Default:     "true",
		Enum:        []string{"true", "false"},
	},
	{
		Name:        ContextOptionAgentURL,
		Description: "Specifies the agent url to use for Devsy",
	},
	{
		Name:        ContextOptionDotfilesURL,
		Description: "Specifies the dotfiles repo url to use for Devsy",
	},
	{
		Name:        ContextOptionDotfilesScript,
		Description: "Specifies the script to run after cloning dotfiles repo to install them",
	},
	{
		Name:        ContextOptionSSHConfigPath,
		Description: "Specifies the path where the ssh config should be written to",
	},
	{
		Name:        ContextOptionSSHConfigIncludePath,
		Description: "Specifies an alternate path where Devsy host entries should be written. Use this when your main SSH config is read-only (e.g., managed by Nix). Your main SSH config should have an Include directive pointing to this file.",
	},
	{
		Name:        ContextOptionAgentInjectTimeout,
		Description: "Specifies the timeout to inject the agent",
		Default:     "20",
	},
	{
		Name:        ContextOptionRegistryCache,
		Description: "Specifies the registry to use as a build cache, e.g. gcr.io/my-project/my-dev-env",
		Default:     "",
	},
	{
		Name:        ContextOptionSSHStrictHostKeyChecking,
		Description: "Enables strict ssh host key checking for all operations",
		Default:     "false",
		Enum:        []string{"true", "false"},
	},
}

Functions

func GetConfigDir

func GetConfigDir() (string, error)

func GetConfigPath

func GetConfigPath() (string, error)

func MergeContextOptions

func MergeContextOptions(contextConfig *ContextConfig, environ []string)

func ParseTimeOption

func ParseTimeOption(cfg *Config, opt string) time.Duration

func ResetPathManager added in v1.1.0

func ResetPathManager()

ResetPathManager clears the singleton so the next DefaultPathManager call creates a fresh instance. Intended for tests only.

func SaveConfig

func SaveConfig(config *Config) error

func SetPathManager added in v1.1.0

func SetPathManager(pm PathManager)

SetPathManager replaces the singleton PathManager (for testing).

Types

type Config

type Config struct {
	// DefaultContext is the default context to use. Defaults to "default"
	DefaultContext string `json:"defaultContext,omitempty"`

	// Contexts holds the config contexts
	Contexts map[string]*ContextConfig `json:"contexts,omitempty"`

	// Origin holds the path where this config was loaded from
	Origin string `json:"-"`

	// OriginalContext is the original default context
	OriginalContext string `json:"-"`
}

func CloneConfig

func CloneConfig(config *Config) *Config

func LoadConfig

func LoadConfig(contextOverride string, providerOverride string) (*Config, error)

func (*Config) ContextOption

func (c *Config) ContextOption(option string) string

func (*Config) Current

func (c *Config) Current() *ContextConfig

func (*Config) DynamicProviderOptionDefinitions

func (c *Config) DynamicProviderOptionDefinitions(provider string) OptionDefinitions

func (*Config) IDEOptions

func (c *Config) IDEOptions(ide string) map[string]OptionValue

func (*Config) ProviderOptions

func (c *Config) ProviderOptions(provider string) map[string]OptionValue

type ContextConfig

type ContextConfig struct {
	// DefaultProvider is the default provider to use
	DefaultProvider string `json:"defaultProvider,omitempty"`

	// DefaultIDE holds default ide configuration
	DefaultIDE string `json:"defaultIde,omitempty"`

	// Options are additional context options
	Options map[string]OptionValue `json:"options,omitempty"`

	// IDEs holds the ide configuration
	IDEs map[string]*IDEConfig `json:"ides,omitempty"`

	// Providers holds the provider configuration
	Providers map[string]*ProviderConfig `json:"providers,omitempty"`

	// OriginalProvider is the original default provider
	OriginalProvider string `json:"-"`
}

func (*ContextConfig) DynamicProviderOptionDefinitions

func (c *ContextConfig) DynamicProviderOptionDefinitions(provider string) OptionDefinitions

func (*ContextConfig) IDEOptions

func (c *ContextConfig) IDEOptions(ide string) map[string]OptionValue

func (*ContextConfig) IsSingleMachine

func (c *ContextConfig) IsSingleMachine(provider string) bool

func (*ContextConfig) ProviderOptions

func (c *ContextConfig) ProviderOptions(provider string) map[string]OptionValue

type ContextOption

type ContextOption struct {
	// Name of the context option
	Name string `json:"name,omitempty"`

	// Description is the description of the context option
	Description string `json:"description,omitempty"`

	// Default is the default value of the context option
	Default string `json:"default,omitempty"`

	// Enum of the allowed values
	Enum []string `json:"enum,omitempty"`
}

type IDE

type IDE string
const (
	IDENone            IDE = "none"
	IDEVSCode          IDE = "vscode"
	IDEVSCodeInsiders  IDE = "vscode-insiders"
	IDEOpenVSCode      IDE = "openvscode"
	IDEIntellij        IDE = "intellij"
	IDEGoland          IDE = "goland"
	IDERustRover       IDE = "rustrover"
	IDEPyCharm         IDE = "pycharm"
	IDEPhpStorm        IDE = "phpstorm"
	IDECLion           IDE = "clion"
	IDERubyMine        IDE = "rubymine"
	IDERider           IDE = "rider"
	IDEWebStorm        IDE = "webstorm"
	IDEDataSpell       IDE = "dataspell"
	IDEFleet           IDE = "fleet"
	IDEJupyterNotebook IDE = "jupyternotebook"
	IDECursor          IDE = "cursor"
	IDEPositron        IDE = "positron"
	IDECodium          IDE = "codium"
	IDEZed             IDE = "zed"
	IDERStudio         IDE = "rstudio"
	IDEWindsurf        IDE = "windsurf"
	IDEAntigravity     IDE = "antigravity"
	IDEBob             IDE = "bob"
)

type IDEConfig

type IDEConfig struct {
	// Options are additional ide options
	Options map[string]OptionValue `json:"options,omitempty"`
}

type IDEGroup

type IDEGroup string
const (
	IDEGroupPrimary   IDEGroup = "Primary"
	IDEGroupJetBrains IDEGroup = "JetBrains"
	IDEGroupOther     IDEGroup = "Other"
)

type OptionDefinitions

type OptionDefinitions = map[string]*types.Option

type OptionValue

type OptionValue struct {
	// Value is the value of the option
	Value string `json:"value,omitempty"`

	// UserProvided signals that this value was user provided
	UserProvided bool `json:"userProvided,omitempty"`

	// Filled is the time when this value was filled
	Filled *types.Time `json:"filled,omitempty"`

	// Children are the child options
	Children []string `json:"children,omitempty"`
}

type PathManager added in v1.1.0

type PathManager interface {
	// Top-level XDG category directories.
	ConfigDir() (string, error)
	DataDir() (string, error)
	CacheDir() (string, error)
	StateDir() (string, error)
	RuntimeDir() (string, error)

	// Config paths.
	ConfigFilePath() (string, error)

	// Data sub-paths (context-relative).
	ContextDir(context string) (string, error)
	WorkspacesDir(context string) (string, error)
	WorkspaceDir(context, workspaceID string) (string, error)
	MachinesDir(context string) (string, error)
	MachineDir(context, machineID string) (string, error)
	ProvidersDir(context string) (string, error)
	ProviderDir(context, providerName string) (string, error)
	ProviderBinariesDir(context, providerName string) (string, error)
	ProviderDaemonDir(context, providerName string) (string, error)
	ProInstancesDir(context string) (string, error)
	ProInstanceDir(context, proInstanceHost string) (string, error)
	LocksDir(context string) (string, error)

	// Cache sub-paths.
	AgentCacheDir() (string, error)
	ProviderDownloadCacheDir() (string, error)
	FeatureCacheDir(hashedID string) (string, error)
	PlatformCacheDir() (string, error)
	SSHKeysDir() (string, error)

	// Runtime sub-paths.
	DaemonPIDFile() (string, error)
	DaemonLockFile() (string, error)
	DaemonStreamsFile() (string, error)
	ProcessPIDFile(name string) (string, error)
	ProcessLockFile(name string) (string, error)
	ProcessStreamsFile(name string) (string, error)

	// State sub-paths.
	LogDir() (string, error)
}

PathManager centralises all filesystem path computation for the Devsy CLI. Per-OS implementations supply the five top-level directory methods; every sub-path is derived from those by the shared basePathManager.

func DefaultPathManager added in v1.1.0

func DefaultPathManager() PathManager

DefaultPathManager returns the process-wide singleton PathManager.

func NewPathManager added in v1.1.0

func NewPathManager() PathManager

NewPathManager returns a new PathManager for the current platform.

type ProviderConfig

type ProviderConfig struct {
	// Initialized holds if the provider was initialized correctly.
	Initialized bool `json:"initialized,omitempty"`

	// SingleMachine signals Devsy if a single machine should be used for this provider.
	SingleMachine bool `json:"singleMachine,omitempty"`

	// Options are the configured provider options
	Options map[string]OptionValue `json:"options,omitempty"`

	// DynamicOptions are the unresolved dynamic provider options
	DynamicOptions OptionDefinitions `json:"dynamicOptions,omitempty"`

	// CreationTimestamp is the timestamp when this provider was added
	CreationTimestamp types.Time `json:"creationTimestamp"`
}

Jump to

Keyboard shortcuts

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