config

package
v0.26.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package config loads ogcode's optional file-based configuration: provider base URLs and API keys, so they can live in a committed/shared file instead of only environment variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureProjectFile

func EnsureProjectFile(dir string) string

EnsureProjectFile creates a blank project-local ogcode.json in dir if no ogcode.json is found in dir or any of its ancestors (see findProjectFile). An existing file — found anywhere in that search — is left untouched, and so is dir itself if creation fails for any reason (e.g. a read-only filesystem): this is a best-effort convenience, never a requirement for startup. Returns the path that was created, or "" if nothing was created.

Types

type Config

type Config struct {
	Providers map[string]ProviderConfig `json:"providers,omitempty"`
}

Config is ogcode's file-based configuration.

func Load

func Load(dir string) *Config

Load reads the global config (~/.config/ogcode/config.json) and the project-local config (ogcode.json, found by searching dir and its parents, stopping once the repo root — the directory holding .git — has been checked), merging them provider-by-provider with project-local values taking precedence. Missing or unreadable files are silently skipped; Load always returns a usable, non-nil Config.

func (*Config) ApplyEnv

func (c *Config) ApplyEnv()

ApplyEnv exports the config's provider settings as environment variables, for each variable that isn't already set. A real environment variable (or one set earlier from a .env file) always wins over the config file.

type ProviderConfig

type ProviderConfig struct {
	BaseURL string `json:"baseUrl,omitempty"`
	APIKey  string `json:"apiKey,omitempty"`
}

ProviderConfig holds per-provider connection overrides.

Jump to

Keyboard shortcuts

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