config

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 8 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"`
	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

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

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.

Jump to

Keyboard shortcuts

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