Documentation ¶
Overview ¶
Package utils collects various services: simple operations, compression, etc.
Index ¶
- Variables
- func CompressFile(source *os.File, onlyGzip bool) error
- func CopyFile(src, dst string) error
- func DirIsAccessible(filename string) error
- func GetLogLevelOrDebug(levelStr string) zerolog.Level
- func HumanBytes(i int64) (result string)
- func LoadConfig(filename string, config *ConfigStructure) error
- func MD5ChecksumForFile(path string) (string, error)
- func SanitizePath(path string) (result string)
- func SaveConfig(filename string, config *ConfigStructure) error
- func SaveConfigRaw(filename string, conf []byte) error
- func SaveConfigYAML(filename string, config *ConfigStructure) error
- func SetupDefaultLogger(levelStr string)
- func SetupJSONLogger(levelStr string, w io.Writer)
- func StrMapSortedKeys(m map[string]string) []string
- func StrMapsEqual(m1, m2 map[string]string) bool
- func StrSliceDeduplicate(s []string) []string
- func StrSliceHasItem(s []string, item string) bool
- func StrSlicesEqual(s1, s2 []string) bool
- func StrSlicesSubstract(l, r []string) []string
- func StringsIsSubset(subset, full []string, errorFmt string) error
- type AzureEndpoint
- type ChecksumInfo
- type ChecksumWriter
- type ConfigStructure
- type DBConfig
- type FileSystemPublishRoot
- type LocalPoolStorage
- type LogWriter
- type PackagePoolStorage
- type S3PublishRoot
- type SwiftPublishRoot
Constants ¶
This section is empty.
Variables ¶
var AZURE = "azure"
var Config = ConfigStructure{ RootDir: filepath.Join(os.Getenv("HOME"), ".aptly"), DownloadConcurrency: 4, DownloadLimit: 0, Downloader: "default", DatabaseOpenAttempts: -1, Architectures: []string{}, DepFollowSuggests: false, DepFollowRecommends: false, DepFollowAllVariants: false, DepFollowSource: false, GpgProvider: "gpg", GpgDisableSign: false, GpgDisableVerify: false, DownloadSourcePackages: false, PackagePoolStorage: PackagePoolStorage{ Local: &LocalPoolStorage{Path: ""}, }, SkipLegacyPool: false, PpaDistributorID: "ubuntu", PpaCodename: "", FileSystemPublishRoots: map[string]FileSystemPublishRoot{}, S3PublishRoots: map[string]S3PublishRoot{}, SwiftPublishRoots: map[string]SwiftPublishRoot{}, AzurePublishRoots: map[string]AzureEndpoint{}, AsyncAPI: false, EnableMetricsEndpoint: false, LogLevel: "info", LogFormat: "default", ServeInAPIMode: false, EnableSwaggerEndpoint: false, }
Config is configuration for aptly, shared by all modules
var LOCAL = "local"
Functions ¶
func CompressFile ¶
CompressFile compresses file specified by source to .gz & .bz2
It uses internal gzip and external bzip2, see: https://code.google.com/p/go/issues/detail?id=4828
func DirIsAccessible ¶ added in v1.0.0
DirIsAccessible verifies that directory exists and is accessible
func GetLogLevelOrDebug ¶ added in v1.6.0
func HumanBytes ¶ added in v0.5.1
HumanBytes converts bytes to human readable string
func LoadConfig ¶
func LoadConfig(filename string, config *ConfigStructure) error
LoadConfig loads configuration from json file
func MD5ChecksumForFile ¶ added in v1.1.0
MD5ChecksumForFile computes just the MD5 hash and not all the others
func SanitizePath ¶ added in v1.6.0
Remove leading '/', remove '..', '$' and '`'
func SaveConfig ¶
func SaveConfig(filename string, config *ConfigStructure) error
SaveConfig write configuration to json file
func SaveConfigRaw ¶ added in v1.6.0
SaveConfigRaw write configuration to file
func SaveConfigYAML ¶ added in v1.6.0
func SaveConfigYAML(filename string, config *ConfigStructure) error
SaveConfigYAML write configuration to yaml file
func SetupDefaultLogger ¶ added in v1.6.0
func SetupDefaultLogger(levelStr string)
func SetupJSONLogger ¶ added in v1.6.0
func StrMapSortedKeys ¶
StrMapSortedKeys returns keys of map[string]string sorted
func StrMapsEqual ¶
StrMapsEqual compares two map[string]string
func StrSliceDeduplicate ¶
StrSliceDeduplicate removes dups in slice
func StrSliceHasItem ¶
StrSliceHasItem checks item for presence in slice
func StrSlicesEqual ¶
StrSlicesEqual compares two slices for equality
func StrSlicesSubstract ¶
StrSlicesSubstract finds all the strings which are in l but not in r, both slices shoult be sorted
func StringsIsSubset ¶
StringsIsSubset checks that subset is strict subset of full, and returns error formatted with errorFmt otherwise
Types ¶
type AzureEndpoint ¶ added in v1.6.0
type AzureEndpoint struct { Container string `json:"container" yaml:"container"` Prefix string `json:"prefix" yaml:"prefix"` AccountName string `json:"accountName" yaml:"account_name"` AccountKey string `json:"accountKey" yaml:"account_key"` Endpoint string `json:"endpoint" yaml:"endpoint"` }
AzureEndpoint describes single Azure publishing entry point
type ChecksumInfo ¶
ChecksumInfo represents checksums for a single file
func ChecksumsForFile ¶
func ChecksumsForFile(path string) (ChecksumInfo, error)
ChecksumsForFile generates size, MD5, SHA1 & SHA256 checksums for the file at the given path
func ChecksumsForReader ¶ added in v1.6.0
func ChecksumsForReader(rd io.Reader) (ChecksumInfo, error)
ChecksumsForReader generates size, MD5, SHA1 & SHA256 checksums for the given io.Reader
func (*ChecksumInfo) Complete ¶ added in v1.1.0
func (cksum *ChecksumInfo) Complete() bool
Complete checks if all the checksums are present
type ChecksumWriter ¶
type ChecksumWriter struct {
// contains filtered or unexported fields
}
ChecksumWriter is a writer that does checksum calculation on the fly passing data to real writer
func NewChecksumWriter ¶
func NewChecksumWriter() *ChecksumWriter
NewChecksumWriter creates checksum calculator for given writer w
func (*ChecksumWriter) Sum ¶
func (c *ChecksumWriter) Sum() ChecksumInfo
Sum returns caculated ChecksumInfo
type ConfigStructure ¶
type ConfigStructure struct { // General RootDir string `json:"rootDir" yaml:"root_dir"` LogLevel string `json:"logLevel" yaml:"log_level"` LogFormat string `json:"logFormat" yaml:"log_format"` DatabaseOpenAttempts int `json:"databaseOpenAttempts" yaml:"database_open_attempts"` Architectures []string `json:"architectures" yaml:"architectures"` SkipLegacyPool bool `json:"skipLegacyPool" yaml:"skip_legacy_pool"` // OBSOLETE // Dependency following DepFollowSuggests bool `json:"dependencyFollowSuggests" yaml:"dep_follow_suggests"` DepFollowRecommends bool `json:"dependencyFollowRecommends" yaml:"dep_follow_recommends"` DepFollowAllVariants bool `json:"dependencyFollowAllVariants" yaml:"dep_follow_all_variants"` DepFollowSource bool `json:"dependencyFollowSource" yaml:"dep_follow_source"` DepVerboseResolve bool `json:"dependencyVerboseResolve" yaml:"dep_verboseresolve"` // PPA PpaDistributorID string `json:"ppaDistributorID" yaml:"ppa_distributor_id"` PpaCodename string `json:"ppaCodename" yaml:"ppa_codename"` // Server ServeInAPIMode bool `json:"serveInAPIMode" yaml:"serve_in_api_mode"` EnableMetricsEndpoint bool `json:"enableMetricsEndpoint" yaml:"enable_metrics_endpoint"` EnableSwaggerEndpoint bool `json:"enableSwaggerEndpoint" yaml:"enable_swagger_endpoint"` AsyncAPI bool `json:"AsyncAPI" yaml:"async_api"` // OBSOLETE // Database DatabaseBackend DBConfig `json:"databaseBackend" yaml:"database_backend"` // Mirroring Downloader string `json:"downloader" yaml:"downloader"` DownloadConcurrency int `json:"downloadConcurrency" yaml:"download_concurrency"` DownloadLimit int64 `json:"downloadSpeedLimit" yaml:"download_limit"` DownloadRetries int `json:"downloadRetries" yaml:"download_retries"` DownloadSourcePackages bool `json:"downloadSourcePackages" yaml:"download_sourcepackages"` // Signing GpgProvider string `json:"gpgProvider" yaml:"gpg_provider"` GpgDisableSign bool `json:"gpgDisableSign" yaml:"gpg_disable_sign"` GpgDisableVerify bool `json:"gpgDisableVerify" yaml:"gpg_disable_verify"` // Publishing SkipContentsPublishing bool `json:"skipContentsPublishing" yaml:"skip_contents_publishing"` SkipBz2Publishing bool `json:"skipBz2Publishing" yaml:"skip_bz2_publishing"` // Storage FileSystemPublishRoots map[string]FileSystemPublishRoot `json:"FileSystemPublishEndpoints" yaml:"filesystem_publish_endpoints"` S3PublishRoots map[string]S3PublishRoot `json:"S3PublishEndpoints" yaml:"s3_publish_endpoints"` SwiftPublishRoots map[string]SwiftPublishRoot `json:"SwiftPublishEndpoints" yaml:"swift_publish_endpoints"` AzurePublishRoots map[string]AzureEndpoint `json:"AzurePublishEndpoints" yaml:"azure_publish_endpoints"` PackagePoolStorage PackagePoolStorage `json:"packagePoolStorage" yaml:"packagepool_storage"` }
ConfigStructure is structure of main configuration
func (*ConfigStructure) GetRootDir ¶ added in v1.6.0
func (conf *ConfigStructure) GetRootDir() string
GetRootDir returns the RootDir with expanded ~ as home directory
type DBConfig ¶ added in v1.6.0
type DBConfig struct { Type string `json:"type" yaml:"type"` DbPath string `json:"dbPath" yaml:"db_path"` URL string `json:"url" yaml:"url"` }
DBConfig
type FileSystemPublishRoot ¶ added in v1.1.0
type FileSystemPublishRoot struct { RootDir string `json:"rootDir" yaml:"root_dir"` LinkMethod string `json:"linkMethod" yaml:"link_method"` VerifyMethod string `json:"verifyMethod" yaml:"verify_method"` }
FileSystemPublishRoot describes single filesystem publishing entry point
type LocalPoolStorage ¶ added in v1.6.0
type LocalPoolStorage struct {
Path string `json:"path,omitempty" yaml:"path,omitempty"`
}
type PackagePoolStorage ¶ added in v1.6.0
type PackagePoolStorage struct { Local *LocalPoolStorage Azure *AzureEndpoint }
func (*PackagePoolStorage) MarshalJSON ¶ added in v1.6.0
func (pool *PackagePoolStorage) MarshalJSON() ([]byte, error)
func (PackagePoolStorage) MarshalYAML ¶ added in v1.6.0
func (pool PackagePoolStorage) MarshalYAML() (interface{}, error)
func (*PackagePoolStorage) UnmarshalJSON ¶ added in v1.6.0
func (pool *PackagePoolStorage) UnmarshalJSON(data []byte) error
func (*PackagePoolStorage) UnmarshalYAML ¶ added in v1.6.0
func (pool *PackagePoolStorage) UnmarshalYAML(unmarshal func(interface{}) error) error
type S3PublishRoot ¶ added in v0.7.1
type S3PublishRoot struct { Region string `json:"region" yaml:"region"` Bucket string `json:"bucket" yaml:"bucket"` Prefix string `json:"prefix" yaml:"prefix"` ACL string `json:"acl" yaml:"acl"` AccessKeyID string `json:"awsAccessKeyID" yaml:"access_key_id"` SecretAccessKey string `json:"awsSecretAccessKey" yaml:"secret_access_key"` SessionToken string `json:"awsSessionToken" yaml:"session_token"` Endpoint string `json:"endpoint" yaml:"endpoint"` StorageClass string `json:"storageClass" yaml:"storage_class"` EncryptionMethod string `json:"encryptionMethod" yaml:"encryption_method"` PlusWorkaround bool `json:"plusWorkaround" yaml:"plus_workaround"` DisableMultiDel bool `json:"disableMultiDel" yaml:"disable_multidel"` ForceSigV2 bool `json:"forceSigV2" yaml:"force_sigv2"` ForceVirtualHostedStyle bool `json:"forceVirtualHostedStyle" yaml:"force_virtualhosted_style"` Debug bool `json:"debug" yaml:"debug"` }
S3PublishRoot describes single S3 publishing entry point
type SwiftPublishRoot ¶ added in v0.9.1
type SwiftPublishRoot struct { Container string `json:"container" yaml:"container"` Prefix string `json:"prefix" yaml:"prefix"` UserName string `json:"osname" yaml:"username"` Password string `json:"password" yaml:"password"` Tenant string `json:"tenant" yaml:"tenant"` TenantID string `json:"tenantid" yaml:"tenant_id"` Domain string `json:"domain" yaml:"domain"` DomainID string `json:"domainid" yaml:"domain_id"` TenantDomain string `json:"tenantdomain" yaml:"tenant_domain"` TenantDomainID string `json:"tenantdomainid" yaml:"tenant_domain_id"` AuthURL string `json:"authurl" yaml:"auth_url"` }
SwiftPublishRoot describes single OpenStack Swift publishing entry point