config

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 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 (
	// ErrMissingAccessToken is raised when an access token is not provided. Set
	// it manually or export `AXIOM_TOKEN`.
	ErrMissingAccessToken = errors.New("missing access token")

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

	// ErrInvalidToken is returned when the access token is invalid.
	ErrInvalidToken = errors.New("invalid access 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) AccessToken

func (c Config) AccessToken() string

AccessToken returns the access token.

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) SetAccessToken

func (c *Config) SetAccessToken(accessToken string)

SetAccessToken sets the access token.

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) 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 SetAccessToken

func SetAccessToken(accessToken string) Option

SetAccessToken specifies the access token to use.

func SetOrganizationID

func SetOrganizationID(organizationID string) Option

SetOrganizationID specifies the organization ID to use.

func SetURL

func SetURL(baseURL string) Option

SetURL sets the base URL to use.

Jump to

Keyboard shortcuts

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