Documentation
¶
Index ¶
- Constants
- Variables
- func NewConfigCmd() *cobra.Command
- func WithConfiguration(ctx context.Context, cfg *Configuration) context.Context
- type Configuration
- type Profile
- type ProfilesFile
- type Service
- func (s *Service) AddProfile(profile Profile) error
- func (s *Service) GetActiveConfiguration() (*Configuration, error)
- func (s *Service) GetActiveProfile() (*Profile, error)
- func (s *Service) GetProfiles() ([]Profile, error)
- func (s *Service) RemoveProfile(profileName string) error
- func (s *Service) SetActiveProfile(profileName string) error
- func (s *Service) UpdateProfile(name string, updateFn func(*Configuration)) error
Constants ¶
const ( // ConfigDirName is the name of the directory containing Dash0 configuration ConfigDirName = ".dash0" // ProfilesFileName is the name of the file containing profile configurations ProfilesFileName = "profiles.json" // ActiveProfileFileName is the name of the file containing the active profile name ActiveProfileFileName = "activeProfile" )
Variables ¶
var ( // ErrNoActiveProfile is returned when there is no active profile ErrNoActiveProfile = errors.New("no active profile configured; run 'dash0 config profiles create <name> --api-url <url> --auth-token <token>' to create one") // ErrProfileNotFound is returned when a requested profile is not found ErrProfileNotFound = errors.New("profile not found") )
Functions ¶
func WithConfiguration ¶
func WithConfiguration(ctx context.Context, cfg *Configuration) context.Context
WithConfiguration returns a new context with the configuration stored
Types ¶
type Configuration ¶
type Configuration struct {
ApiUrl string `json:"apiUrl" yaml:"apiUrl"`
AuthToken string `json:"authToken" yaml:"authToken"`
OtlpUrl string `json:"otlpUrl,omitempty" yaml:"otlpUrl,omitempty"`
Dataset string `json:"dataset,omitempty" yaml:"dataset,omitempty"`
}
Configuration represents a Dash0 configuration
func FromContext ¶
func FromContext(ctx context.Context) *Configuration
FromContext retrieves the configuration from context, or nil if not present
func ResolveConfiguration ¶
func ResolveConfiguration(apiUrl, authToken string) (*Configuration, error)
ResolveConfiguration loads configuration with override handling. It loads the active profile, applies environment variable and flag overrides, and validates the result. Parameters:
- apiUrl: Command-line flag for API URL (empty if not provided)
- authToken: Command-line flag for auth token (empty if not provided)
Returns:
- Configuration with all overrides applied
- Error if configuration couldn't be loaded or is invalid
func ResolveConfigurationWithOtlp ¶ added in v1.1.0
func ResolveConfigurationWithOtlp(apiUrl, authToken, otlpUrl, dataset string) (*Configuration, error)
ResolveConfigurationWithOtlp loads configuration with override handling including OTLP URL and dataset. Parameters:
- apiUrl: Command-line flag for API URL (empty if not provided)
- authToken: Command-line flag for auth token (empty if not provided)
- otlpUrl: Command-line flag for OTLP URL (empty if not provided)
- dataset: Command-line flag for dataset (empty if not provided)
Returns:
- Configuration with all overrides applied
- Error if configuration couldn't be loaded or is invalid
type Profile ¶
type Profile struct {
Name string `json:"name" yaml:"name"`
Configuration Configuration `json:"configuration" yaml:"configuration"`
}
Profile represents a configuration profile
type ProfilesFile ¶
type ProfilesFile struct {
Profiles []Profile `json:"profiles" yaml:"profiles"`
}
ProfilesFile represents the file storing multiple profiles
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles configuration operations
func NewService ¶
NewService creates a new configuration service
func (*Service) AddProfile ¶
AddProfile adds a new profile to the configuration
func (*Service) GetActiveConfiguration ¶
func (s *Service) GetActiveConfiguration() (*Configuration, error)
GetActiveConfiguration returns the currently active configuration Environment variables take precedence over the active profile
func (*Service) GetActiveProfile ¶
GetActiveProfile returns the currently active profile
func (*Service) GetProfiles ¶
GetProfiles returns all available profiles
func (*Service) RemoveProfile ¶
RemoveProfile removes a profile from the configuration
func (*Service) SetActiveProfile ¶
SetActiveProfile sets the active profile
func (*Service) UpdateProfile ¶ added in v1.1.0
func (s *Service) UpdateProfile(name string, updateFn func(*Configuration)) error
UpdateProfile finds a profile by name and applies the updateFn to its configuration, then saves. Returns ErrProfileNotFound if no profile with the given name exists.