utils

package
Version: v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2018 License: MIT Imports: 14 Imported by: 239

Documentation

Overview

Package utils collects various services: simple operations, compression, etc.

Index

Constants

This section is empty.

Variables

View Source
var Config = ConfigStructure{
	RootDir:                filepath.Join(os.Getenv("HOME"), ".aptly"),
	DownloadConcurrency:    4,
	DownloadLimit:          0,
	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{},
}

Config is configuration for aptly, shared by all modules

Functions

func CompressFile

func CompressFile(source *os.File, onlyGzip bool) error

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 CopyFile added in v0.9.6

func CopyFile(src, dst string) error

CopyFile copeis file from src to dst, not preserving attributes

func DirIsAccessible added in v1.0.0

func DirIsAccessible(filename string) error

DirIsAccessible verifies that directory exists and is accessible

func HumanBytes added in v0.5.1

func HumanBytes(i int64) (result string)

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

func MD5ChecksumForFile(path string) (string, error)

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 StrMapSortedKeys

func StrMapSortedKeys(m map[string]string) []string

StrMapSortedKeys returns keys of map[string]string sorted

func StrMapsEqual

func StrMapsEqual(m1, m2 map[string]string) bool

StrMapsEqual compares two map[string]string

func StrSliceDeduplicate

func StrSliceDeduplicate(s []string) []string

StrSliceDeduplicate removes dups in slice

func StrSliceHasItem

func StrSliceHasItem(s []string, item string) bool

StrSliceHasItem checks item for presence in slice

func StrSlicesEqual

func StrSlicesEqual(s1, s2 []string) bool

StrSlicesEqual compares two slices for equality

func StrSlicesSubstract

func StrSlicesSubstract(l, r []string) []string

StrSlicesSubstract finds all the strings which are in l but not in r, both slices shoult be sorted

func StringsIsSubset

func StringsIsSubset(subset, full []string, errorFmt string) error

StringsIsSubset checks that subset is strict subset of full, and returns error formatted with errorFmt otherwise

Types

type ChecksumInfo

type ChecksumInfo struct {
	Size   int64
	MD5    string
	SHA1   string
	SHA256 string
	SHA512 string
}

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

func (*ChecksumWriter) Write

func (c *ChecksumWriter) Write(p []byte) (n int, err error)

Write implememnts pass-through writing with checksum calculation on the fly

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"`
	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"`
	FileSystemPublishRoots map[string]FileSystemPublishRoot `json:"FileSystemPublishEndpoints"`
	S3PublishRoots         map[string]S3PublishRoot         `json:"S3PublishEndpoints"`
	SwiftPublishRoots      map[string]SwiftPublishRoot      `json:"SwiftPublishEndpoints"`
}

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

Jump to

Keyboard shortcuts

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