Documentation
¶
Overview ¶
Package vars provides centralized configuration management for the Nexlayer CLI. Deprecated: Use pkg/config instead.
Index ¶
- Constants
- func ExtractVariables(input string) map[string]string
- func GetAPIURL() string
- func GetCacheDir() (string, error)
- func GetConfigDir() (string, error)
- func GetDefaultShell() string
- func GetLogLevel() string
- func GetProjectNamespace() string
- func GetRegistryConfig() (string, string, string)
- func GetToken() string
- func GetUserAgent() string
- func IsDebug() bool
- func IsDevelopment() bool
- func SubstitutePod(pod interface{}, ctx *VariableContext) error
- func SubstituteVariables(input string, ctx *VariableContext) (string, error)
- func ValidateConfig() error
- func ValidateSubstitution(input string, ctx *VariableContext) ([]string, error)
- type Config
- type VariableContext
Constants ¶
const ( // PodReferenceVar represents pod reference variables like <pod-name>.pod PodReferenceVar = "pod-reference" // TemplateVar represents template variables like <% VAR_NAME %> TemplateVar = "template-var" // EnvVar represents environment variables EnvVar = "env-var" )
Variable types
const ( URLVar = "URL" RegistryVar = "REGISTRY" )
Common variables used in templates
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 ExtractVariables ¶
ExtractVariables finds all variable references in a string
func GetCacheDir ¶
GetCacheDir returns the platform-specific cache directory
func GetConfigDir ¶
GetConfigDir returns the platform-specific configuration directory
func GetDefaultShell ¶
func GetDefaultShell() string
GetDefaultShell returns the default shell for the current platform
func GetProjectNamespace ¶
func GetProjectNamespace() string
GetProjectNamespace returns the current project namespace
func GetRegistryConfig ¶
GetRegistryConfig returns the container registry configuration
func GetToken ¶
func GetToken() string
GetToken returns the authentication token from environment or config
func IsDevelopment ¶
func IsDevelopment() bool
IsDevelopment returns true if running in development mode
func SubstitutePod ¶
func SubstitutePod(pod interface{}, ctx *VariableContext) error
SubstitutePod replaces all variables in pod configuration
func SubstituteVariables ¶
func SubstituteVariables(input string, ctx *VariableContext) (string, error)
SubstituteVariables replaces Nexlayer variables in a string
func ValidateConfig ¶
func ValidateConfig() error
ValidateConfig checks if all required configuration is present
func ValidateSubstitution ¶
func ValidateSubstitution(input string, ctx *VariableContext) ([]string, error)
ValidateSubstitution checks if all variables in a string can be substituted
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
type VariableContext ¶
type VariableContext struct {
// Map of pod names to internal DNS names
Pods map[string]string
// Map of variable names to values
Variables map[string]string
// Registry URL for image references
Registry string
// Application URL
URL string
}
VariableContext provides the context for variable substitution
func NewVariableContext ¶
func NewVariableContext() *VariableContext
NewVariableContext creates a new variable context
func (*VariableContext) AddPod ¶
func (c *VariableContext) AddPod(name string)
AddPod adds a pod to the context
func (*VariableContext) SetRegistry ¶
func (c *VariableContext) SetRegistry(registry string)
SetRegistry sets the registry URL
func (*VariableContext) SetURL ¶
func (c *VariableContext) SetURL(url string)
SetURL sets the application URL
func (*VariableContext) SetVariable ¶
func (c *VariableContext) SetVariable(name, value string)
SetVariable sets a variable value