config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

View Source
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 NewConfigCmd

func NewConfigCmd() *cobra.Command

NewConfigCmd creates a new config command

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"`
}

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 handles test mode detection, configuration loading, and validation of API URL and auth token 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 outside of test mode

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

func NewService() (*Service, error)

NewService creates a new configuration service

func (*Service) AddProfile

func (s *Service) AddProfile(profile Profile) error

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

func (s *Service) GetActiveProfile() (*Profile, error)

GetActiveProfile returns the currently active profile

func (*Service) GetProfiles

func (s *Service) GetProfiles() ([]Profile, error)

GetProfiles returns all available profiles

func (*Service) RemoveProfile

func (s *Service) RemoveProfile(profileName string) error

RemoveProfile removes a profile from the configuration

func (*Service) SetActiveProfile

func (s *Service) SetActiveProfile(profileName string) error

SetActiveProfile sets the active profile

Jump to

Keyboard shortcuts

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