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 SaveConfig(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 AzurePublishRoot
- type ChecksumInfo
- type ChecksumWriter
- type ConfigStructure
- type FileSystemPublishRoot
- type LogWriter
- type S3PublishRoot
- type SwiftPublishRoot
Constants ¶
This section is empty.
Variables ¶
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, SkipLegacyPool: false, PpaDistributorID: "ubuntu", PpaCodename: "", FileSystemPublishRoots: map[string]FileSystemPublishRoot{}, S3PublishRoots: map[string]S3PublishRoot{}, SwiftPublishRoots: map[string]SwiftPublishRoot{}, AzurePublishRoots: map[string]AzurePublishRoot{}, AsyncAPI: false, EnableMetricsEndpoint: false, LogLevel: "debug", LogFormat: "default", ServeInAPIMode: false, }
Config is configuration for aptly, shared by all modules
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.5.1
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 SaveConfig ¶
func SaveConfig(filename string, config *ConfigStructure) error
SaveConfig write configuration to json file
func SetupDefaultLogger ¶ added in v1.5.1
func SetupDefaultLogger(levelStr string)
func SetupJSONLogger ¶ added in v1.5.1
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 AzurePublishRoot ¶ added in v1.5.0
type AzurePublishRoot struct {
AccountName string `json:"accountName"`
AccountKey string `json:"accountKey"`
Container string `json:"container"`
Prefix string `json:"prefix"`
Endpoint string `json:"endpoint"`
}
AzurePublishRoot 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 given file
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 {
RootDir string `json:"rootDir"`
DownloadConcurrency int `json:"downloadConcurrency"`
DownloadLimit int64 `json:"downloadSpeedLimit"`
DownloadRetries int `json:"downloadRetries"`
Downloader string `json:"downloader"`
DatabaseOpenAttempts int `json:"databaseOpenAttempts"`
Architectures []string `json:"architectures"`
DepFollowSuggests bool `json:"dependencyFollowSuggests"`
DepFollowRecommends bool `json:"dependencyFollowRecommends"`
DepFollowAllVariants bool `json:"dependencyFollowAllVariants"`
DepFollowSource bool `json:"dependencyFollowSource"`
DepVerboseResolve bool `json:"dependencyVerboseResolve"`
GpgDisableSign bool `json:"gpgDisableSign"`
GpgDisableVerify bool `json:"gpgDisableVerify"`
GpgProvider string `json:"gpgProvider"`
DownloadSourcePackages bool `json:"downloadSourcePackages"`
SkipLegacyPool bool `json:"skipLegacyPool"`
PpaDistributorID string `json:"ppaDistributorID"`
PpaCodename string `json:"ppaCodename"`
SkipContentsPublishing bool `json:"skipContentsPublishing"`
SkipBz2Publishing bool `json:"skipBz2Publishing"`
FileSystemPublishRoots map[string]FileSystemPublishRoot `json:"FileSystemPublishEndpoints"`
S3PublishRoots map[string]S3PublishRoot `json:"S3PublishEndpoints"`
SwiftPublishRoots map[string]SwiftPublishRoot `json:"SwiftPublishEndpoints"`
AzurePublishRoots map[string]AzurePublishRoot `json:"AzurePublishEndpoints"`
AsyncAPI bool `json:"AsyncAPI"`
EnableMetricsEndpoint bool `json:"enableMetricsEndpoint"`
LogLevel string `json:"logLevel"`
LogFormat string `json:"logFormat"`
ServeInAPIMode bool `json:"serveInAPIMode"`
}
ConfigStructure is structure of main configuration
type FileSystemPublishRoot ¶ added in v1.1.0
type FileSystemPublishRoot struct {
RootDir string `json:"rootDir"`
LinkMethod string `json:"linkMethod"`
VerifyMethod string `json:"verifyMethod"`
}
FileSystemPublishRoot describes single filesystem publishing entry point
type S3PublishRoot ¶ added in v0.7.1
type S3PublishRoot struct {
Region string `json:"region"`
Bucket string `json:"bucket"`
Endpoint string `json:"endpoint"`
AccessKeyID string `json:"awsAccessKeyID"`
SecretAccessKey string `json:"awsSecretAccessKey"`
SessionToken string `json:"awsSessionToken"`
Prefix string `json:"prefix"`
ACL string `json:"acl"`
StorageClass string `json:"storageClass"`
EncryptionMethod string `json:"encryptionMethod"`
PlusWorkaround bool `json:"plusWorkaround"`
DisableMultiDel bool `json:"disableMultiDel"`
ForceSigV2 bool `json:"forceSigV2"`
ForceVirtualHostedStyle bool `json:"forceVirtualHostedStyle"`
Debug bool `json:"debug"`
}
S3PublishRoot describes single S3 publishing entry point
type SwiftPublishRoot ¶ added in v0.9.1
type SwiftPublishRoot struct {
UserName string `json:"osname"`
Password string `json:"password"`
AuthURL string `json:"authurl"`
Tenant string `json:"tenant"`
TenantID string `json:"tenantid"`
Domain string `json:"domain"`
DomainID string `json:"domainid"`
TenantDomain string `json:"tenantdomain"`
TenantDomainID string `json:"tenantdomainid"`
Prefix string `json:"prefix"`
Container string `json:"container"`
}
SwiftPublishRoot describes single OpenStack Swift publishing entry point