conf

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AkamaiClusterAmsterdam  = "nl-ams-1.linodeobjects.com"
	AkamaiClusterAtlanta    = "us-southeast-1.linodeobjects.com"
	AkamaiClusterChennai    = "in-maa-1.linodeobjects.com"
	AkamaiClusterChicago    = "us-ord-1.linodeobjects.com"
	AkamaiClusterFrankfurt  = "eu-central-1.linodeobjects.com"
	AkamaiClusterJakarta    = "id-cgk-1.linodeobjects.com"
	AkamaiClusterLosAngeles = "us-lax-1.linodeobjects.com"
	AkamaiClusterMiami      = "us-mia-1.linodeobjects.com"
	AkamaiClusterMilan      = "it-mil-1.linodeobjects.com"
	AkamaiClusterNewark     = "us-east-1.linodeobjects.com"
	AkamaiClusterOsaka      = "jp-osa-1.linodeobjects.com"
	AkamaiClusterParis      = "fr-par-1.linodeobjects.com"
	AkamaiClusterSaoPaulo   = "br-gru-1.linodeobjects.com"
	AkamaiClusterSeattle    = "us-sea-1.linodeobjects.com"
	AkamaiClusterSingapore  = "ap-south-1.linodeobjects.com"
	AkamaiClusterStockholm  = "se-sto-1.linodeobjects.com"
	AkamaiClusterAshburn    = "us-iad-1.linodeobjects.com"
)
View Source
const (
	AkamaiRegionAmsterdam  = "nl-ams-1"
	AkamaiRegionAtlanta    = "us-southeast-1"
	AkamaiRegionChennai    = "in-maa-1"
	AkamaiRegionChicago    = "us-ord-1"
	AkamaiRegionFrankfurt  = "eu-central-1"
	AkamaiRegionJakarta    = "id-cgk-1"
	AkamaiRegionLosAngeles = "us-lax-1"
	AkamaiRegionMiami      = "us-mia-1"
	AkamaiRegionMilan      = "it-mil-1"
	AkamaiRegionNewark     = "us-east-1"
	AkamaiRegionOsaka      = "jp-osa-1"
	AkamaiRegionParis      = "fr-par-1"
	AkamaiRegionSaoPaulo   = "br-gru-1"
	AkamaiRegionSeattle    = "us-sea-1"
	AkamaiRegionSingapore  = "ap-south-1"
	AkamaiRegionStockholm  = "se-sto-1"
	AkamaiRegionAshburn    = "us-iad-1"
)
View Source
const (
	AwsACLPrivate                = "private"
	AwsACLPublicRead             = "public-read"
	AwsACLPublicReadWrite        = "public-read-write"
	AwsACLAuthenticatedRead      = "authenticated-read"
	AwsACLAwsExecRead            = "aws-exec-read"
	AwsACLBucketOwnerRead        = "bucket-owner-read"
	AwsACLBucketOwnerFullControl = "bucket-owner-full-control"
)
View Source
const (
	AwsClassStandard           = "STANDARD"
	AwsClassReducedRedundancy  = "REDUCED_REDUNDANCY"
	AwsClassGlacierIR          = "GLACIER_IR"
	AwsClassSnow               = "SNOW"
	AwsClassStandardIA         = "STANDARD_IA"
	AwsClassOneZoneIA          = "ONEZONE_IA"
	AwsClassIntelligentTiering = "INTELLIGENT_TIERING"
	AwsClassGlacier            = "GLACIER"
	AwsClassDeepArchive        = "DEEP_ARCHIVE"
)
View Source
const (
	InvalidAWSACL                   = "invalid aws acl"
	ErrorAWSProfileAndKeys          = "both aws profile and keys are specified, use profile or keys"
	ErrorAWSKeyOrSecretNotSpecified = "profile should specified both key and secret"
)
View Source
const (
	ErrorOCICompartmentNotSpecified = "oracle cloud compartment will be tenancy root"
	ErrorOCIAuthNotSpecified        = "oracle cloud auth not specified"
	ErrorOCIStorageNotSpecified     = "oracle cloud storage tier is not valid"
)
View Source
const (
	OracleStorageTierStandard         = "standard"
	OracleStorageTierInfrequentAccess = "infrequentaccess" // the case is strange because of the
	OracleStorageTierArchive          = "archive"
)
View Source
const (
	InvalidNamingMethod    = "invalid object naming method"
	InvalidStorageClass    = "invalid storage class"
	InvalidOverwriteMethod = "invalid overwrite method"
	InvalidTagChars        = "invalid characters removed from tag"

	ErrorProfilePath    = "error determining profile path"
	ErrorOpeningProfile = "error opening profile"
	ErrorReadingYaml    = "error reading yaml"

	ErrorLoggingFilepathNotSpecified = "path to log file not specified"
	ErrorLoggingFilepath             = "error determining log file path"
	ErrorLoggingLevelTooHigh         = "logging level too high, setting to 5"
	ErrorLoggingLevelTooLow          = "logging level too low, setting to 0"
	ErrorGettingFileInfo             = "error getting file info"
	ErrorFileIsDirectory             = "listed file is a directory"
	ErrorNoFilesSpecified            = "no files, folders, directories specified"
	ErrorNoReadableFiles             = "no readable files or directories specified"
	ErrorUnsupportedProfileVersion   = "profile version not supported"
	ErrorProviderNotSpecified        = "provider not specified"
	ErrorBucketNotSpecified          = "bucket or region not specified"
)
View Source
const (
	Empty = ""
)
View Source
const (
	ErrorAkamaiKeyOrSecretNotSpecified = "akamai access keys not specified"
)
View Source
const (
	OciDefaultProfile = "DEFAULT"
)

Variables

This section is empty.

Functions

func Create

func Create(filename string) (err error)

Create takes a filename as a string, and writes out a sample configuration profile. The file must not exist. The structure is built using a new struct, createProfile, that is based on readConfig

func S

func S(format string, a ...any) string

S is a shortcut for fmt.Sprintf. The only real purpose is to reduce clutter and line lengths.

Types

type AppConfig

type AppConfig struct {
	Provider    *Provider
	Bucket      *Bucket
	Objects     *Objects
	Opts        *Opts
	Tags        map[string]string
	Tag         *TagOpts
	LogOpts     *LogOpts
	Log         *logbot.LogBot
	Files       []string
	Directories []string
}

AppConfig is an application level struct that all profile configuration details are loaded into. Log is an instance zerolog.Logger, which is built in logbot. The Files and Directories structs are the list of files and directories to upload.

func NewAppConfig

func NewAppConfig(file string) (ac *AppConfig, err error)

NewAppConfig will build a new AppConfig object out of the specified yaml file. It creates a readConfig object and called the loadProfile() method to open, read, and unmarshal the yaml file. There is also a validateVersion() method that will eventually be fleshed out to make sure difference profile versions are unmarshalled correctly.

type Bucket

type Bucket struct {
	Create bool
	Name   string
	Region string
}

Bucket contains all details related to the bucket, for any provider. Create is not implemented.

type LogOpts

type LogOpts struct {
	Level    zerolog.Level
	Console  bool
	File     bool
	Filepath string
}

LogOpts contains the logging configuration, but not an instance of logbot.

type Naming

type Naming string

Naming type is a string enum of the supported object naming methods.

const (
	NamingRelative Naming = "relative"
	NamingAbsolute Naming = "absolute"
)

func (Naming) String

func (n Naming) String() string

String returns the string representation of the Naming object. It converts the Naming object to a string by using the underlying string value.

type Objects

type Objects struct {
	NamePrefix string
	RootPrefix string
	Naming     Naming

	// OmitRootDir is used to remove the root directory name from the object's final FormattedKey.
	OmitRootDir bool
}

Objects contain the object naming configuration.

type Opts

type Opts struct {
	MaxParts   int
	MaxUploads int
	Overwrite  Overwrite
}

Opts contains application level configuration options.

type Overwrite

type Overwrite string

Overwrite type is a string enum of the supported overwrite methods. OverwriteChecksum is not implemented. Overwrite.String() will return the string representation of the enum for convenience, either in output or logging.

const (
	OverwriteChecksum Overwrite = "checksum"
	OverwriteNever    Overwrite = "never"
	OverwriteAlways   Overwrite = "always"
)

func (Overwrite) String

func (o Overwrite) String() string

type Provider

type Provider struct {
	Is     ProviderName
	AWS    *ProviderAWS
	OCI    *ProviderOCI
	Akamai *ProviderAkamai
	Key    string
	Secret string
}

Provider represents the configuration for a provider.

Fields: - Is (ProviderName): The name of the provider. (e.g., "AWS", "OCI") - AWS (*ProviderAWS): The configuration for AWS. - OCI (*ProviderOCI): The configuration for OCI. - Key (string): The provider key. - Secret (string): The provider secret.

Usage examples can be found in the surrounding code.

type ProviderAWS

type ProviderAWS struct {
	Profile string
	ACL     types.ObjectCannedACL
	Storage types.StorageClass
	Key     string
	Secret  string
}

ProviderAWS represents the AWS provider configuration.

Fields: - Profile: The profile name used for authentication. - ACL: The access control list for the storage objects. - Storage: The storage class for the objects. - Key: The AWS access key ID. - Secret: The AWS secret access key.

type ProviderAkamai

type ProviderAkamai struct {
	Key      string
	Secret   string
	Endpoint string
}

ProviderAkamai represents the Linode/Akamai provider configuration

type ProviderName

type ProviderName string

ProviderName type is a string enum of the supported providers, meant to make it easier to check AppConfig.Provider.Is when figuring out which provider config fields should be used. ProviderName.String() will return the string representation of the enum for convenience, either in output or logging.

const (
	ProviderNameNone   ProviderName = "none"
	ProviderNameAWS    ProviderName = "aws"
	ProviderNameOCI    ProviderName = "oci"
	ProviderNameAkamai ProviderName = "akamai"
)

func (ProviderName) String

func (p ProviderName) String() string

type ProviderOCI

type ProviderOCI struct {
	Profile     string
	Compartment string
	Storage     objectstorage.StorageTierEnum

	// this is ridiculous, but the OCI SDK has a separate enum for PUT requests.
	PutStorage objectstorage.PutObjectStorageTierEnum
}

ProviderOCI represents the OCI provider configuration.

type TagOpts

type TagOpts struct {
	ChecksumSHA256       bool
	AwsChecksumAlgorithm types.ChecksumAlgorithm
	AwsChecksumMode      types.ChecksumMode
	Origins              bool
}

TagOpts contain the object tagging configuration, but only the ones handled internally by the application. Custom tags are put in a separate map named "Tags" inside the AppConfig struct.

Jump to

Keyboard shortcuts

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