config

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config provides the base configuration for Axiom related functionality like URLs and credentials for API access.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingToken is raised when a token is not provided. Set it manually
	// using the `axiom.SetToken` option when constructing a client or export
	// `AXIOM_TOKEN`.
	ErrMissingToken = errors.New("missing token")

	// ErrMissingOrganizationID is raised when an organization ID is not
	// provided. Set it manually using the `axiom.SetOrganizationID` option when
	// constructing a client or export `AXIOM_ORG_ID`.
	ErrMissingOrganizationID = errors.New("missing organization id")

	// ErrInvalidToken is returned when the token is invalid.
	ErrInvalidToken = errors.New("invalid token")
)

Functions

func CloudURL

func CloudURL() *url.URL

CloudURL is the url of the cloud hosted version of Axiom.

func IsAPIToken

func IsAPIToken(token string) bool

IsAPIToken returns true if the given access token is an API token.

func IsPersonalToken

func IsPersonalToken(token string) bool

IsPersonalToken returns true if the given access token is a personal token.

func IsValidToken

func IsValidToken(token string) bool

IsValidToken returns true if the given access token is a valid Axiom access token.

Types

type Config

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

Config is the configuration for Axiom related functionality. It should never be created manually but always via the `Default` function.

func Default

func Default() Config

Default returns a default configuration with the base URL set.

func (Config) BaseURL

func (c Config) BaseURL() *url.URL

BaseURL returns the base URL.

func (*Config) IncorporateEnvironment

func (c *Config) IncorporateEnvironment() error

IncorporateEnvironment loads configuration from environment variables. It will reject invalid values.

func (*Config) Options

func (c *Config) Options(options ...Option) error

Options applies options to the configuration.

func (Config) OrganizationID

func (c Config) OrganizationID() string

OrganizationID returns the organization ID.

func (*Config) SetBaseURL

func (c *Config) SetBaseURL(baseURL *url.URL)

SetBaseURL sets the base URL.

func (*Config) SetOrganizationID

func (c *Config) SetOrganizationID(organizationID string)

SetOrganizationID sets the organization ID.

func (*Config) SetToken added in v0.13.1

func (c *Config) SetToken(token string)

SetToken sets the token.

func (Config) Token added in v0.13.1

func (c Config) Token() string

Token returns the token.

func (Config) Validate

func (c Config) Validate() error

Validate the configuration.

type Option

type Option func(config *Config) error

An Option modifies the configuration. It is not safe for concurrent use.

func SetOrganizationID

func SetOrganizationID(organizationID string) Option

SetOrganizationID specifies the organization ID to use.

func SetToken added in v0.13.1

func SetToken(token string) Option

SetToken specifies the token to use.

func SetURL

func SetURL(baseURL string) Option

SetURL specifies the base URL to use.

Jump to

Keyboard shortcuts

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