airbox

package
v0.30.4 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvConfigPath is the environment variable that sets the path to the Airbox configuration.
	EnvConfigPath = "AIRBOXCONFIG"
)

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath returns the default path for airbox config.

func NewAPIService

func NewAPIService(ctx context.Context, httpClient http.HTTPDoer, cfg ConfigStore) (api.Service, error)

NewAPIService creates an authenticated API service with all boilerplate handled

func NewConfigInitError

func NewConfigInitError(msg string) error

NewConfigInitError returns an error with config init instructions for the given message.

func NewLoginError

func NewLoginError(msg string) error

NewLoginError returns an error with login instructions for the given message.

func ValidateCompanyIdentifier

func ValidateCompanyIdentifier(companyID string) error

ValidateCompanyIdentifier validates a company identifier for cloud deployment. This validation matches Airbyte platform SSO requirements: only checks for non-empty after trimming whitespace. The platform accepts any characters including spaces and special characters, so we defer complex validation to the server.

func ValidateDataplaneName

func ValidateDataplaneName(name string) error

ValidateDataplaneName validates a dataplane name follows Kubernetes DNS-1123 subdomain rules. These constraints are required because dataplane names become Kubernetes resource names: - Max 63 characters (DNS label limit) - Start with lowercase letter (K8s requirement) - Only lowercase letters, numbers, hyphens (DNS-safe characters) - Cannot end with hyphen (DNS requirement)

func ValidateEndpointURL

func ValidateEndpointURL(endpoint string) error

ValidateEndpointURL performs basic validation on an endpoint URL

Types

type APIServiceFactory

type APIServiceFactory func(ctx context.Context, httpClient http.HTTPDoer, cfg ConfigStore) (api.Service, error)

APIServiceFactory creates authenticated API services with all boilerplate handled

type Auth

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

Auth wraps AuthProvider for marshaling/unmarshaling

func NewAuthWithOAuth2

func NewAuthWithOAuth2(clientID, clientSecret string) Auth

NewAuthWithOAuth2 creates Auth with OAuth2 provider

func NewAuthWithOIDC

func NewAuthWithOIDC(authURL, clientID string) Auth

NewAuthWithOIDC creates Auth with OIDC provider

func (*Auth) GetOAuth2Provider

func (w *Auth) GetOAuth2Provider() (*OAuth2, error)

GetOAuth2Provider returns the provider as an OAuth2Provider or an error

func (*Auth) GetOIDCProvider

func (w *Auth) GetOIDCProvider() (*OIDC, error)

GetOIDCProvider returns the provider as an OIDCProvider or an error

func (*Auth) GetProvider

func (w *Auth) GetProvider() AuthProvider

GetProvider returns the underlying AuthProvider

func (*Auth) MarshalJSON

func (w *Auth) MarshalJSON() ([]byte, error)

MarshalJSON serializes Auth to JSON with type discrimination

func (Auth) MarshalYAML

func (w Auth) MarshalYAML() (interface{}, error)

MarshalYAML implements custom YAML marshaling MarshalYAML serializes Auth to YAML with type discrimination

func (*Auth) UnmarshalJSON

func (w *Auth) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes JSON to Auth with type discrimination

func (*Auth) UnmarshalYAML

func (w *Auth) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements custom YAML unmarshaling UnmarshalYAML deserializes YAML to Auth with type discrimination

func (*Auth) Validate

func (w *Auth) Validate() error

Validate ensures the Auth struct is properly configured Validate checks authentication configuration is valid

type AuthProvider

type AuthProvider interface {
	Type() string
	Validate() error
}

AuthProvider interface for authentication configuration

type Config

type Config struct {
	CurrentContext string            `json:"current-context" yaml:"current-context"`
	Credentials    *auth.Credentials `json:"credentials,omitempty" yaml:"credentials,omitempty"`
	Contexts       []NamedContext    `json:"contexts" yaml:"contexts"`
}

Config represents the airbox configuration file structure.

func (*Config) AddContext

func (c *Config) AddContext(name string, context Context)

AddContext adds or updates a context

func (*Config) GetCredentials

func (c *Config) GetCredentials() (*auth.Credentials, error)

GetCredentials returns the current user credentials

func (*Config) GetCurrentContext

func (c *Config) GetCurrentContext() (*Context, error)

GetCurrentContext returns the current context.

func (*Config) IsAuthenticated

func (c *Config) IsAuthenticated() bool

IsAuthenticated checks if user has credentials (expiry is handled by auth client)

func (*Config) RemoveContext

func (c *Config) RemoveContext(name string) error

RemoveContext removes a context

func (*Config) SetCredentials

func (c *Config) SetCredentials(creds *auth.Credentials)

SetCredentials updates the user credentials in the config (does not save)

func (*Config) SetCurrentContext

func (c *Config) SetCurrentContext(name string) error

SetCurrentContext sets the current context

func (*Config) Validate

func (c *Config) Validate() error

Validate ensures the config structure is valid and coherent.

type ConfigStore

type ConfigStore interface {
	Load() (*Config, error)
	Save(config *Config) error
	GetPath() string
	Exists() bool
}

ConfigStore interface for performing config operations on the store.

type Context

type Context struct {
	AirbyteAPIURL  string `json:"airbyteApiUrl" yaml:"airbyteApiUrl"`
	AirbyteURL     string `json:"airbyteUrl" yaml:"airbyteUrl"`
	OrganizationID string `json:"organizationId" yaml:"organizationId"`
	Edition        string `json:"edition" yaml:"edition"`
	Auth           Auth   `json:"auth" yaml:"auth"`
}

Context represents a single airbox context (org/workspace combination).

func (*Context) Validate

func (c *Context) Validate() error

Validate ensures the context has all required fields and valid URLs.

type CredentialStoreAdapter

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

CredentialStoreAdapter adapts ConfigStore to auth.CredentialsStore

func NewCredentialStoreAdapter

func NewCredentialStoreAdapter(cfg ConfigStore) *CredentialStoreAdapter

NewCredentialStoreAdapter creates a new credentials store adapter

func (*CredentialStoreAdapter) Load

Load implements auth.CredentialsStore

func (*CredentialStoreAdapter) Save

func (a *CredentialStoreAdapter) Save(creds *auth.Credentials) error

Save implements auth.CredentialsStore

type FileConfigStore

type FileConfigStore struct{}

FileConfigStore implements ConfigStore using filesystem.

func (*FileConfigStore) Exists

func (p *FileConfigStore) Exists() bool

Exists checks if the config file exists

func (*FileConfigStore) GetPath

func (p *FileConfigStore) GetPath() string

GetPath returns configuration file path.

func (*FileConfigStore) Load

func (p *FileConfigStore) Load() (*Config, error)

Load and return the configuration from the file store.

func (*FileConfigStore) Save

func (p *FileConfigStore) Save(config *Config) error

Save writes the configuration to the file store.

type NamedContext

type NamedContext struct {
	Name    string  `json:"name" yaml:"name"`
	Context Context `json:"context" yaml:"context"`
}

NamedContext represents a named context entry.

type OAuth2

type OAuth2 struct {
	ClientID     string `yaml:"clientId" json:"clientId"`
	ClientSecret string `yaml:"clientSecret" json:"clientSecret"`
}

OAuth2 configuration for OAuth2 providers

func NewOAuth2

func NewOAuth2(clientID, clientSecret string) *OAuth2

NewOAuth2 creates a new OAuth2 auth configuration

func (*OAuth2) Type

func (o *OAuth2) Type() string

Type returns the authentication type

func (*OAuth2) Validate

func (o *OAuth2) Validate() error

Validate checks OAuth2 configuration is complete

type OAuthEnvConfig

type OAuthEnvConfig struct {
	ClientID     string `envconfig:"AIRBYTE_CLIENT_ID" required:"true"`
	ClientSecret string `envconfig:"AIRBYTE_CLIENT_SECRET" required:"true"`
}

OAuthEnvConfig holds environment-based configuration

func LoadOAuthEnvConfig

func LoadOAuthEnvConfig() (*OAuthEnvConfig, error)

LoadOAuthEnvConfig loads configuration from environment variables

func (*OAuthEnvConfig) ToAuthClient

func (c *OAuthEnvConfig) ToAuthClient(ctx context.Context, httpClient http.HTTPDoer, cfg ConfigStore) (auth.Provider, error)

ToAuthClient creates an authenticated HTTP client from stored credentials

type OIDC

type OIDC struct {
	AuthURL  string `yaml:"authUrl" json:"authUrl"`
	ClientID string `yaml:"clientId" json:"clientId"`
}

OIDC configuration for OIDC providers

func NewOIDC

func NewOIDC(authURL, clientID string) *OIDC

NewOIDC creates a new OIDC auth configuration

func (*OIDC) Type

func (o *OIDC) Type() string

Type returns the authentication type

func (*OIDC) Validate

func (o *OIDC) Validate() error

Validate checks OIDC configuration is complete

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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