conf

package
v1.60.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

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

AWS Constants

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 = "you provided AWS profile name and key/secret pair, use profile or keys"
	ErrorAWSMissingAuth    = "must provide a valid AWS key pair"
	ErrorAWSAuthNeeded     = "must provide AWS profile name or key pair"
)
View Source
const (
	GCBucketACLAuthenticatedRead = "authenticatedread"
	GCBucketACLPrivate           = "private"
	GCBucketACLPublicRead        = "publicread"
	GCBucketACLPublicReadWrite   = "publicreadwrite"
	GCBucketACLProjectPrivate    = "projectprivate"
)

Google Cloud Constants

View Source
const (
	GCObjectACLAuthenticatedRead = "authenticatedread"
	GCObjectACLPrivate           = "private"
	GCObjectACLPublicRead        = "publicread"
	GCObjectACLProjectPrivate    = "projectprivate"
	GCObjectACLBucketOwnerFull   = "bucketownerfullcontrol"
	GCObjectACLBucketOwnerRead   = "bucketownerread"
)
View Source
const (
	GCStorageStandard = "STANDARD"
	GCStorageNearline = "NEARLINE"
	GCStorageColdline = "COLDLINE"
	GCStorageArchive  = "ARCHIVE"
)
View Source
const (
	GCLocationTypeRegion = "region"
	GCLocationTypeDual   = "dual-region"
	GCLocationTypeMulti  = "multi-region"
)
View Source
const (
	GCRegionNANE1    = "NORTHAMERICA-NORTHEAST1"
	GCRegionNANE2    = "NORTHAMERICA-NORTHEAST2"
	GCRegionNAS1     = "NORTHAMERICA-SOUTH1"
	GCRegionUSC1     = "US-CENTRAL1"
	GCRegionUSE1     = "US-EAST1"
	GCRegionUSE4     = "US-EAST4"
	GCRegionUSE5     = "US-EAST5"
	GCRegionUSS1     = "US-SOUTH1"
	GCRegionUSW1     = "US-WEST1"
	GCRegionUSW2     = "US-WEST2"
	GCRegionUSW3     = "US-WEST3"
	GCRegionUSW4     = "US-WEST4"
	GCRegionSAE1     = "SOUTHAMERICA-EAST1"
	GCRegionSAW1     = "SOUTHAMERICA-WEST1"
	GCRegionEUC2     = "EUROPE-CENTRAL2"
	GCRegionEUN1     = "EUROPE-NORTH1"
	GCRegionEUSW1    = "EUROPE-SOUTHWEST1"
	GCRegionEUW1     = "EUROPE-WEST1"
	GCRegionEUW2     = "EUROPE-WEST2"
	GCRegionEUW3     = "EUROPE-WEST3"
	GCRegionEUW4     = "EUROPE-WEST4"
	GCRegionEUW6     = "EUROPE-WEST6"
	GCRegionEUW8     = "EUROPE-WEST8"
	GCRegionEUW9     = "EUROPE-WEST9"
	GCRegionEUW12    = "EUROPE-WEST12"
	GCRegionASIAE1   = "ASIA-EAST1"
	GCRegionASIAE2   = "ASIA-EAST2"
	GCRegionASIANE1  = "ASIA-NORTHEAST1"
	GCRegionASIANE2  = "ASIA-NORTHEAST2"
	GCRegionASIANE3  = "ASIA-NORTHEAST3"
	GCRegionASIASE1  = "ASIA-SOUTHEAST1"
	GCRegionASIAS1   = "ASIA-SOUTH1"
	GCRegionASIAS2   = "ASIA-SOUTH2"
	GCRegionASIASE2  = "ASIA-SOUTHEAST2"
	GCRegionMEC1     = "MIDDLEEAST-CENTRAL1"
	GCRegionMEC2     = "MIDDLEEAST-CENTRAL2"
	GCRegionMEW1     = "MIDDLEEAST-WEST1"
	GCRegionAUSSE1   = "AUSTRALIA-SOUTHEAST1"
	GCRegionAUSSE2   = "AUSTRALIA-SOUTHEAST2"
	GCRegionAFRICAS1 = "AFRICA-SOUTH1"
)
View Source
const (
	GCDualAsia = "ASIA1"
	GCDualEur4 = "EUR4"
	GCDualEur5 = "EUR5"
	GCDualEur7 = "EUR7"
	GCDualEur8 = "EUR8"
	GCDualNAM4 = "NAM4"
)
View Source
const (
	GCMultiAsia = "ASIA"
	GCMultiEU   = "EU"
	GCMultiUS   = "US"
)
View Source
const (
	InvalidGCBucketACL    = "invalid google cloud bucket acl"
	InvalidGCObjectACL    = "invalid google cloud object acl"
	InvalidGCLocationType = "invalid google cloud location type"
)
View Source
const (
	LinodeClusterAmsterdam  = "nl-ams-1.linodeobjects.com"
	LinodeClusterAtlanta    = "us-southeast-1.linodeobjects.com"
	LinodeClusterChennai    = "in-maa-1.linodeobjects.com"
	LinodeClusterChicago    = "us-ord-1.linodeobjects.com"
	LinodeClusterFrankfurt  = "eu-central-1.linodeobjects.com"
	LinodeClusterJakarta    = "id-cgk-1.linodeobjects.com"
	LinodeClusterLosAngeles = "us-lax-1.linodeobjects.com"
	LinodeClusterMiami      = "us-mia-1.linodeobjects.com"
	LinodeClusterMilan      = "it-mil-1.linodeobjects.com"
	LinodeClusterNewark     = "us-east-1.linodeobjects.com"
	LinodeClusterOsaka      = "jp-osa-1.linodeobjects.com"
	LinodeClusterParis      = "fr-par-1.linodeobjects.com"
	LinodeClusterSaoPaulo   = "br-gru-1.linodeobjects.com"
	LinodeClusterSeattle    = "us-sea-1.linodeobjects.com"
	LinodeClusterSingapore  = "ap-south-1.linodeobjects.com"
	LinodeClusterStockholm  = "se-sto-1.linodeobjects.com"
	LinodeClusterAshburn    = "us-iad-1.linodeobjects.com"
)

Linode Constants

View Source
const (
	LinodeRegionAmsterdam  = "nl-ams-1"
	LinodeRegionAtlanta    = "us-southeast-1"
	LinodeRegionChennai    = "in-maa-1"
	LinodeRegionChicago    = "us-ord-1"
	LinodeRegionFrankfurt  = "eu-central-1"
	LinodeRegionJakarta    = "id-cgk-1"
	LinodeRegionLosAngeles = "us-lax-1"
	LinodeRegionMiami      = "us-mia-1"
	LinodeRegionMilan      = "it-mil-1"
	LinodeRegionNewark     = "us-east-1"
	LinodeRegionOsaka      = "jp-osa-1"
	LinodeRegionParis      = "fr-par-1"
	LinodeRegionSaoPaulo   = "br-gru-1"
	LinodeRegionSeattle    = "us-sea-1"
	LinodeRegionSingapore  = "ap-south-1"
	LinodeRegionStockholm  = "se-sto-1"
	LinodeRegionAshburn    = "us-iad-1"
)
View Source
const (
	LinodeInvalidRegion = "invalid Linode region provided"
	LinodeAuthNeeded    = "Linode authentication not specified"
)
View Source
const (
	ErrorOCICompartmentNotSpecified = "OCI compartment will be tenancy root"
	ErrorOCIAuthNotSpecified        = "OCI auth not specified"
	ErrorOCIStorageNotSpecified     = "OCI storage tier is not valid"
)
View Source
const (
	OracleStorageTierStandard         = "standard"
	OracleStorageTierInfrequentAccess = "infrequentaccess" // the case is strange because of the
	OracleStorageTierArchive          = "archive"
)
View Source
const (
	InvalidNamingType      = "NamingType should be \"relative\" or \"absolute\""
	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 or directories specified"
	ErrorNoReadableFiles             = "no readable files or directories specified"
	ErrorUnsupportedProfileVersion   = "profile version not supported"
	ErrorProviderNotSpecified        = "no valid provider specified"
	ErrorBucketInfoNotSpecified      = "bucket name or bucket region not specified"
)

Conf Errors

View Source
const (
	Empty = ""
)
View Source
const (
	OciDefaultProfile = "DEFAULT"
)

OCI Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Provider *Provider
	Opts     *Opts
	Bucket   *Bucket
	Objects  *Objects
	TagOpts  *TagOpts
	Tags     Tags
	LogOpts  *LogOpts
	Paths    []string
	Files    []string
	Dirs     []string
	Skip     []string

	Tui *tuipack.LogBot
}

func NewAppConfig

func NewAppConfig() *AppConfig

NewAppConfig returns a new AppConfig object with preconfigured defaults.

func (*AppConfig) ImportFromProfile added in v1.4.0

func (ac *AppConfig) ImportFromProfile(inc *ProfileIncoming) error

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 Builder added in v1.4.0

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

func NewBuilder added in v1.4.0

func NewBuilder(path string) *Builder

func (*Builder) FromYaml added in v1.4.0

func (b *Builder) FromYaml() (*AppConfig, error)

func (*Builder) YamlOut added in v1.4.0

func (b *Builder) YamlOut() error

type LogOpts

type LogOpts struct {
	Level   zerolog.Level
	Console bool
	File    bool
	Logfile 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"
	NamingNone     Naming = "none"
)

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 {
	NamingType Naming
	NamePrefix string
	PathPrefix string

	// 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 {
	MaxUploads     int
	FollowSymlinks bool
	WalkDirs       bool
	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 ProfileIncoming added in v1.4.0

type ProfileIncoming struct {
	Version int `yaml:"Version"`

	Provider struct {
		Use     string `yaml:"Use"`
		Profile string `yaml:"Profile"`
		Key     string `yaml:"Key"`
		Secret  string `yaml:"Secret"`
	} `yaml:"Provider"`

	AWS struct {
		ACL     string `yaml:"ACL"`
		Storage string `yaml:"Storage"`
	} `yaml:"AWS"`

	Google struct {
		Project      string `yaml:"Project"`
		LocationType string `yaml:"LocationType"`
		Storage      string `yaml:"Storage"`
		BucketACL    string `yaml:"BucketACL"`
		ObjectACL    string `yaml:"ObjectACL"`
		ADC          string
	} `yaml:"Google"`

	Linode struct {
		Region string `yaml:"Region"`
	} `yaml:"Linode"`

	OCI struct {
		Compartment string `yaml:"Compartment"`
		Storage     string `yaml:"Storage"`
	} `yaml:"OCI"`

	Bucket struct {
		Create bool   `yaml:"Create"`
		Name   string `yaml:"Name"`
		Region string `yaml:"Region"`
	} `yaml:"Bucket"`

	Options struct {
		MaxUploads       int    `yaml:"MaxUploads"`
		FollowSymlinks   bool   `yaml:"FollowSymlinks"` // TODO: Add Support
		WalkDirs         bool   `yaml:"WalkDirs"`
		OverwriteObjects string `yaml:"OverwriteObjects"`
	} `yaml:"Options"`

	TagOptions struct {
		OriginPath     bool `yaml:"OriginPath"`
		ChecksumSHA256 bool `yaml:"ChecksumSHA256"`
	} `yaml:"Tagging"`

	Tags map[string]string `yaml:"Tags"`

	Objects struct {
		NamingType  string `yaml:"NamingType"`
		NamePrefix  string `yaml:"NamePrefix"`
		PathPrefix  string `yaml:"PathPrefix"`
		OmitRootDir bool   `yaml:"OmitRootDir"`
	} `yaml:"Objects"`

	Logging struct {
		Level   int    `yaml:"Level"`
		Screen  bool   `yaml:"Screen"`
		Console bool   `yaml:"Console"`
		File    bool   `yaml:"File"`
		Logfile string `yaml:"Logfile"`
	} `yaml:"Logging"`

	Files []string `yaml:"Files"`
	Dirs  []string `yaml:"Dirs"`
	Skip  []string `yaml:"Skip"` // TODO: Add Support
}

func NewProfile added in v1.4.0

func NewProfile() *ProfileIncoming

func (*ProfileIncoming) LoadFromYaml added in v1.4.0

func (p *ProfileIncoming) LoadFromYaml(filename string) error

type Provider

type Provider struct {
	Is     ProviderName
	AWS    *ProviderAWS
	Google *ProviderGoogle
	Linode *ProviderLinode
	OCI    *ProviderOCI
}

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. - Google (*ProviderGoogle): The configuration for Google Cloud. - Linode (*ProviderLinode): The configuration for Akamai / Linode. - 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
	Key                  string
	Secret               string
	ACL                  types.ObjectCannedACL
	Storage              types.StorageClass
	AwsChecksumAlgorithm types.ChecksumAlgorithm
	AwsChecksumMode      types.ChecksumMode
}

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 ProviderGoogle added in v1.6.0

type ProviderGoogle struct {
	Project      string
	LocationType string
	Storage      string
	BucketACL    string
	ObjectACL    string
	ADC          string
}

type ProviderLinode added in v1.4.0

type ProviderLinode struct {
	Key       string
	Secret    string
	Endpoint  string
	BucketACL types.BucketCannedACL
	ObjectACL types.ObjectCannedACL
}

ProviderLinode represents the Linode/Akamai provider configuration

type ProviderName

type ProviderName string

ProviderName subtype, for quickly matching providers

const (
	ProviderNameNone   ProviderName = "none"
	ProviderNameAWS    ProviderName = "aws"
	ProviderNameOCI    ProviderName = "oci"
	ProviderNameLinode ProviderName = "linode"
	ProviderNameGoogle ProviderName = "google"
)

func (ProviderName) String

func (pn ProviderName) String() string

type ProviderOCI

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

	PutStorage objectstorage.PutObjectStorageTierEnum
}

ProviderOCI represents the OCI provider configuration.

type TagOpts

type TagOpts struct {
	ChecksumSHA256 bool
	OriginPath     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.

type Tags added in v1.4.0

type Tags map[string]string

func (*Tags) Get added in v1.4.0

func (t *Tags) Get() map[string]string

Jump to

Keyboard shortcuts

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