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 HumanBytes(i int64) (result string)
- func LoadConfig(filename string, config *ConfigStructure) error
- func SaveConfig(filename string, config *ConfigStructure) error
- 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 ChecksumInfo
- type ChecksumWriter
- type ConfigStructure
- type GpgKey
- type GpgKeyInfo
- type GpgSigner
- func (g *GpgSigner) ClearSign(source string, destination string) error
- func (g *GpgSigner) DetachedSign(source string, destination string) error
- func (g *GpgSigner) Init() error
- func (g *GpgSigner) SetBatch(batch bool)
- func (g *GpgSigner) SetKey(keyRef string)
- func (g *GpgSigner) SetKeyRing(keyring, secretKeyring string)
- func (g *GpgSigner) SetPassphrase(passphrase, passphraseFile string)
- type GpgVerifier
- func (g *GpgVerifier) AddKeyring(keyring string)
- func (g *GpgVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error)
- func (g *GpgVerifier) InitKeyring() error
- func (g *GpgVerifier) IsClearSigned(clearsigned io.Reader) (bool, error)
- func (g *GpgVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*GpgKeyInfo, error)
- func (g *GpgVerifier) VerifyDetachedSignature(signature, cleartext io.Reader) error
- type S3PublishRoot
- type Signer
- type SwiftPublishRoot
- type Verifier
Constants ¶
This section is empty.
Variables ¶
var Config = ConfigStructure{ RootDir: filepath.Join(os.Getenv("HOME"), ".aptly"), DownloadConcurrency: 4, DownloadLimit: 0, Architectures: []string{}, DepFollowSuggests: false, DepFollowRecommends: false, DepFollowAllVariants: false, DepFollowSource: false, GpgDisableSign: false, GpgDisableVerify: false, DownloadSourcePackages: false, PpaDistributorID: "ubuntu", PpaCodename: "", S3PublishRoots: map[string]S3PublishRoot{}, SwiftPublishRoots: map[string]SwiftPublishRoot{}, }
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 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 SaveConfig ¶
func SaveConfig(filename string, config *ConfigStructure) error
SaveConfig write configuration to json file
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 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
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"` Architectures []string `json:"architectures"` DepFollowSuggests bool `json:"dependencyFollowSuggests"` DepFollowRecommends bool `json:"dependencyFollowRecommends"` DepFollowAllVariants bool `json:"dependencyFollowAllVariants"` DepFollowSource bool `json:"dependencyFollowSource"` GpgDisableSign bool `json:"gpgDisableSign"` GpgDisableVerify bool `json:"gpgDisableVerify"` DownloadSourcePackages bool `json:"downloadSourcePackages"` PpaDistributorID string `json:"ppaDistributorID"` PpaCodename string `json:"ppaCodename"` SkipContentsPublishing bool `json:"skipContentsPublishing"` S3PublishRoots map[string]S3PublishRoot `json:"S3PublishEndpoints"` SwiftPublishRoots map[string]SwiftPublishRoot `json:"SwiftPublishEndpoints"` }
ConfigStructure is structure of main configuration
type GpgKeyInfo ¶ added in v0.9.6
GpgKeyInfo is response from signature verification
type GpgSigner ¶
type GpgSigner struct {
// contains filtered or unexported fields
}
GpgSigner is implementation of Signer interface using gpg
func (*GpgSigner) DetachedSign ¶
DetachedSign signs file with detached signature in ASCII format
func (*GpgSigner) SetKeyRing ¶
SetKeyRing allows to set custom keyring and secretkeyring
func (*GpgSigner) SetPassphrase ¶ added in v0.9.1
SetPassphrase sets passhprase params
type GpgVerifier ¶
type GpgVerifier struct {
// contains filtered or unexported fields
}
GpgVerifier is implementation of Verifier interface using gpgv
func (*GpgVerifier) AddKeyring ¶
func (g *GpgVerifier) AddKeyring(keyring string)
AddKeyring adds custom keyring to GPG parameters
func (*GpgVerifier) ExtractClearsigned ¶
ExtractClearsigned extracts cleartext from clearsigned file WITHOUT signature verification
func (*GpgVerifier) InitKeyring ¶
func (g *GpgVerifier) InitKeyring() error
InitKeyring verifies that gpg is installed and some keys are trusted
func (*GpgVerifier) IsClearSigned ¶ added in v0.9.6
func (g *GpgVerifier) IsClearSigned(clearsigned io.Reader) (bool, error)
IsClearSigned returns true if file contains signature
func (*GpgVerifier) VerifyClearsigned ¶
func (g *GpgVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*GpgKeyInfo, error)
VerifyClearsigned verifies clearsigned file using gpgv
func (*GpgVerifier) VerifyDetachedSignature ¶
func (g *GpgVerifier) VerifyDetachedSignature(signature, cleartext io.Reader) error
VerifyDetachedSignature verifies combination of signature and cleartext using gpgv
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"` Debug bool `json:"debug"` }
S3PublishRoot describes single S3 publishing entry point
type Signer ¶
type Signer interface { Init() error SetKey(keyRef string) SetKeyRing(keyring, secretKeyring string) SetPassphrase(passphrase, passphraseFile string) SetBatch(batch bool) DetachedSign(source string, destination string) error ClearSign(source string, destination string) error }
Signer interface describes facility implementing signing of files
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
type Verifier ¶
type Verifier interface { InitKeyring() error AddKeyring(keyring string) VerifyDetachedSignature(signature, cleartext io.Reader) error IsClearSigned(clearsigned io.Reader) (bool, error) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*GpgKeyInfo, error) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error) }
Verifier interface describes signature verification factility