config

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config provides centralized configuration management for the Nexlayer CLI.

Package config provides backward compatibility with the old configuration system. New code should use the pkg/core/config package directly.

Index

Constants

View Source
const (
	// DefaultAPIURL is the default Nexlayer API endpoint
	DefaultAPIURL = "https://api.nexlayer.dev"

	// ConfigFileName is the name of the configuration file
	ConfigFileName = "config.yaml"

	// CacheDir is the directory for caching CLI data
	CacheDir = ".nexlayer"

	// DefaultPort is the default port for local development
	DefaultPort = 3000
)

Configuration constants

Variables

This section is empty.

Functions

func GetAPIURL

func GetAPIURL() string

GetAPIURL returns the configured API URL or the default

func GetCacheDir

func GetCacheDir() (string, error)

GetCacheDir returns the platform-specific cache directory

func GetConfigDir

func GetConfigDir() (string, error)

GetConfigDir returns the platform-specific configuration directory

func GetDefaultShell

func GetDefaultShell() string

GetDefaultShell returns the default shell for the current platform

func GetLogLevel

func GetLogLevel() string

GetLogLevel returns the configured log level

func GetProjectNamespace

func GetProjectNamespace() string

GetProjectNamespace returns the current project namespace

func GetRegistryConfig

func GetRegistryConfig() (string, string, string)

GetRegistryConfig returns the container registry configuration

func GetToken

func GetToken() string

GetToken returns the authentication token from environment or config

func GetUserAgent

func GetUserAgent() string

GetUserAgent returns the CLI user agent string

func IsDebug

func IsDebug() bool

IsDebug returns true if debug mode is enabled

func IsDevelopment

func IsDevelopment() bool

IsDevelopment returns true if running in development mode

func Save

func Save() error

Save saves the current configuration to disk

func ValidateConfig

func ValidateConfig() error

ValidateConfig checks if all required configuration is present

Types

type Config

type Config struct {
	// API configuration
	API struct {
		URL   string `yaml:"url"`
		Token string `yaml:"token"`
	} `yaml:"api"`

	// Project configuration
	Project struct {
		Name      string `yaml:"name"`
		Namespace string `yaml:"namespace"`
		Domain    string `yaml:"domain"`
	} `yaml:"project"`

	// Registry configuration
	Registry struct {
		Type     string `yaml:"type"`     // Container registry type (ghcr, dockerhub, gcr, ecr, artifactory, gitlab)
		URL      string `yaml:"url"`      // Registry URL
		Username string `yaml:"username"` // Registry username
		Region   string `yaml:"region"`   // Registry region (for ECR)
		Project  string `yaml:"project"`  // Registry project ID (for GCR)
	} `yaml:"registry"`

	// Build configuration
	Build struct {
		Context string `yaml:"context"` // Docker build context path
		Tag     string `yaml:"tag"`     // Docker image tag
	} `yaml:"build"`

	// Environment variables
	Env map[string]string `yaml:"env"`
}

Config holds the CLI configuration

func Load

func Load() (*Config, error)

Load loads the configuration from disk

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles configuration management

func NewManager

func NewManager() *Manager

NewManager creates a new configuration manager

func (*Manager) GetAPIEndpoint

func (m *Manager) GetAPIEndpoint(env string) string

GetAPIEndpoint returns the API endpoint for the given environment

func (*Manager) GetDefaultNamespace

func (m *Manager) GetDefaultNamespace() string

GetDefaultNamespace returns the default namespace

func (*Manager) GetString

func (m *Manager) GetString(key string) string

GetString gets a string value from configuration

func (*Manager) GetStringMap

func (m *Manager) GetStringMap(key string) map[string]string

GetStringMap gets a string map from configuration

func (*Manager) Save

func (m *Manager) Save() error

Save saves the configuration to disk

func (*Manager) Set

func (m *Manager) Set(key string, value interface{})

Set sets a configuration value

func (*Manager) SetDefaultNamespace

func (m *Manager) SetDefaultNamespace(namespace string) error

SetDefaultNamespace sets the default namespace

Jump to

Keyboard shortcuts

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