config

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DdbAccessKeyEnvVar = "DDB_AWS_ACCESS_KEY_ID"
	DdbSecretKeyEnvVar = "DDB_AWS_SECRET_ACCESS_KEY"
	DdbRegionEnvVar    = "DDB_AWS_REGION"
)
View Source
const (
	SnsAccessKeyEnvVar = "SNS_AWS_ACCESS_KEY_ID"
	SnsSecretKeyEnvVar = "SNS_AWS_SECRET_ACCESS_KEY"
	SnsRegionEnvVar    = "SNS_AWS_REGION"
)
View Source
const (
	AwsAccessKeyIdSuffix     = "AWS_ACCESS_KEY_ID"
	AwsSecretAccessKeySuffix = "AWS_SECRET_ACCESS_KEY"
	ApiKeySuffix             = "API_KEY"
)
View Source
const (
	ServerApiKeyEnv = "SERVER_API_KEY"
	DefaultTsState  = "/var/lib/texit/tsstate"
)
View Source
const (
	ProvisionWorkflowArnEnvVar   = "PROVISION_NODE_WORKFLOW_ARN"
	DeprovisionWorkflowArnEnvVar = "DEPROVISION_NODE_WORKFLOW_ARN"
	WorkflowAwsAccessKeyEnvVar   = "SFN_AWS_ACCESS_KEY_ID"
	WorkflowAwsSecretKeyEnvVar   = "SFN_AWS_SECRET_ACCESS_KEY"
	WorkflowAwsRegionEnvVar      = "SFN_AWS_REGION"
)
View Source
const (
	TailnetApiKeySuffix = "TAILNET_API_KEY"
)

Variables

View Source
var (
	ErrMissingDatabaseHost = errors.New("missing database host")
	ErrMissingDatabasePort = errors.New("missing database port")
	ErrMissingDatabaseUser = errors.New("missing database user")
	ErrMissingDatabasePass = errors.New("missing database pass")
	ErrMissingDatabaseName = errors.New("missing database name")
)
View Source
var (
	ErrMissingNotifierBroker   = errors.New("missing notifier broker")
	ErrMissingNotifierTopic    = errors.New("missing notifier topic")
	ErrMissiningNotifierRegion = errors.New("missing notifier region")
)
View Source
var (
	ErrMissingProviderAwsAccessKey = fmt.Errorf("missing provider access key")
	ErrMissingProviderAwsSecretKey = fmt.Errorf("missing provider secret key")
	ErrMissingApiKey               = fmt.Errorf("missing api key")
	ErrMissingProviderName         = fmt.Errorf("missing provider name")
)
View Source
var (
	ErrMissingTailnetType            = errors.New("missing tailnet type")
	ErrMissingTailnet                = errors.New("missing tailnet")
	ErrMissingTailnetApiKey          = errors.New("missing tailnet api key")
	ErrMissingUser                   = errors.New("missing headscale user")
	ErrMissingHeadscaleControlServer = errors.New("missing headscale control server")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	LogLevel  string            `yaml:"logLevel"`
	Server    *ServerConfig     `yaml:"server"`
	Tailnets  []*TailnetConfig  `yaml:"tailnets"`
	Database  *DatabaseConfig   `yaml:"database"`
	Providers []*ProviderConfig `yaml:"providers"`
	Notifiers []*NotifierConfig `yaml:"notifiers"`
	Workflow  *WorkflowConfig   `yaml:"workflow"`
}

func LoadFromData added in v0.0.6

func LoadFromData(data []byte) (*Config, error)

func LoadFromFile

func LoadFromFile(path string) (*Config, error)

Loads the application config from a file at the specified path.

type DatabaseConfig

type DatabaseConfig struct {
	// The database engine to use
	Engine DatabaseEngine `yaml:"engine"`
	// The host of the database
	Host string `yaml:"host"`
	// The port of the database
	Port int `yaml:"port"`
	// The username to connect to the database
	Username string `yaml:"username"`
	// The password to connect to the database
	Password string `yaml:"password"`
	// The name of the database
	Database string `yaml:"database"`
	// Location of the database file. For sqlite only
	Location string `yaml:"location"`
	// Whether to use SSL for the connection
	Ssl bool `yaml:"ssl"`
	// The region to use for a ddb table
	Region string `yaml:"region"`
	// The access key to use for a ddb table
	AccessKey string `yaml:"accessKey"`
	// The secret key to use for a ddb table
	SecretKey string `yaml:"secretKey"`
}

Configuration for the database

func NewDefaultDatabaseConfig added in v0.0.9

func NewDefaultDatabaseConfig() *DatabaseConfig

func (*DatabaseConfig) Validate

func (c *DatabaseConfig) Validate() error

type DatabaseEngine

type DatabaseEngine string
const (
	DatabaseEngineSqlite   DatabaseEngine = "sqlite"
	DatabaseEnginePostgres DatabaseEngine = "postgres"
	DatabaseEngineDynamoDb DatabaseEngine = "dynamodb"
)

type NotifierConfig added in v0.0.8

type NotifierConfig struct {
	// the notifier type
	Type NotifierType `yaml:"type"`
	// the notifier name
	Name string `yaml:"name"`
	// the topic to publish to
	Topic string `yaml:"topic"`
	// username for the notifier
	Username string `yaml:"username"`
	// password for the notifier
	Password string `yaml:"password"`
	// Access key for the notifier
	AccessKey string `yaml:"accessKey"`
	// Secret key for the notifier
	SecretKey string `yaml:"secretKey"`
	// the aws region for the notifier
	Region string `yaml:"region"`
	// The broker for the notifier
	Broker string `yaml:"broker"`
}

Configuration for the notifier

func (*NotifierConfig) Validate added in v0.0.8

func (c *NotifierConfig) Validate() error

type NotifierType added in v0.0.8

type NotifierType string
const (
	NotifierTypeMqtt NotifierType = "mqtt"
	NotifierTypeSns  NotifierType = "sns"
)

type ProviderConfig

type ProviderConfig struct {
	// The type of provider, curretly only aws-ecs
	Type ProviderType `yaml:"type"`
	// The access key for the provider. This is only for AWS types.
	AccessKey string `yaml:"accessKey"`
	// The secret key for the provider. This is only for AWS types.
	SecretKey string `yaml:"secretKey"`
	// An api key for the provider.
	ApiKey string `yaml:"apiKey"`
	// The name of the provider.
	Name string `yaml:"name"`
}

Configuration for a provider. Currently only AWS ECS.

func (*ProviderConfig) Validate

func (c *ProviderConfig) Validate() error

func (*ProviderConfig) ValidateHetzner added in v0.0.9

func (c *ProviderConfig) ValidateHetzner() error

type ProviderType

type ProviderType string
const (
	ProviderTypeAwsEcs  ProviderType = "aws-ecs"
	ProviderTypeAwsEc2  ProviderType = "aws-ec2"
	ProviderTypeLinode  ProviderType = "linode"
	ProviderTypeHetzner ProviderType = "hetzner"
)

func (ProviderType) String

func (t ProviderType) String() string

type ServerConfig

type ServerConfig struct {
	// The address to listen on
	Address string `yaml:"address"`
	// If specified, the server will join the tailnet with the config provided
	Tailnet *tsn.Config `yaml:"tailnet"`
	// A static key to use for the API. If not specified, one will be generated.
	APIKey string `yaml:"apiKey"` //TODO: make this better one day
}

Configuration for the server

func (*ServerConfig) Validate

func (c *ServerConfig) Validate() error

type TailnetConfig

type TailnetConfig struct {
	// The type of tailnet, tailscale or headscale
	Type TailnetType `yaml:"type"`
	// The network of the tailnet. On tailscale this is the network id
	Tailnet string `yaml:"tailnet"`
	// The api token to communicate with the tailnet
	ApiKey string `yaml:"apiKey"`
	// The user to register exist nodes for.
	User string `yaml:"user"`
	// the control server to use. This is require for headscale
	ControlServer string `yaml:"controlServer"`
}

Configuration for the tailnet exit nodes will join

func (*TailnetConfig) Validate

func (c *TailnetConfig) Validate() error

type TailnetType

type TailnetType string // tailscale or headscale
const (
	TailnetTypeTailscale TailnetType = "tailscale"
	TailnetTypeHeadscale TailnetType = "headscale"
)

func (TailnetType) String

func (t TailnetType) String() string

type WorkflowConfig added in v0.0.9

type WorkflowConfig struct {
	// the workflow type
	Type WorkflowType `yaml:"type"`

	// sfn provision workflow arn
	ProvisionWorkflowArn string `yaml:"provisionWorkflowArn"`
	// sfn deprovision workflow arn
	DeprovisionWorkflowArn string `yaml:"deprovisionWorkflowArn"`
	// Access key to use when calling sfn
	AccessKey string `yaml:"accessKey"`
	// Secret key to use when calling sfn
	SecretKey string `yaml:"secretKey"`
	// The region to use when calling sfn
	Region string `yaml:"region"`
}

Configuration for the notifier

func NewDefaultWorkflowConfig added in v0.0.9

func NewDefaultWorkflowConfig() *WorkflowConfig

func (*WorkflowConfig) Validate added in v0.0.9

func (c *WorkflowConfig) Validate() error

type WorkflowType added in v0.0.9

type WorkflowType string
const (
	WorkflowTypeLocal WorkflowType = "local"
	WorkflowTypeSfn   WorkflowType = "sfn"
)

Jump to

Keyboard shortcuts

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