config

package
v0.17.8 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 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 ErrInvalidToken = errors.New("invalid token")

ErrInvalidToken is returned when the token is invalid.

View Source
var ErrMissingOrganizationID = errors.New("missing organization id")

ErrMissingOrganizationID is raised when an organization ID is not provided. Set it manually using the SetOrganizationID Option or export "AXIOM_ORG_ID".

View Source
var ErrMissingToken = errors.New("missing token")

ErrMissingToken is raised when a token is not provided. Set it manually using the SetToken Option or export "AXIOM_TOKEN".

Functions

func APIURL added in v0.14.0

func APIURL() *url.URL

APIURL is the api url of the hosted version of Axiom.

func IsAPIToken

func IsAPIToken(token string) bool

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

func IsPersonalToken

func IsPersonalToken(token string) bool

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

func IsValidToken

func IsValidToken(token string) bool

IsValidToken returns true if the given token is a valid Axiom 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.

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