Help us shape the future of Go! Take the 2026 Go Developer Survey

utils

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2014 License: MIT Imports: 16 Imported by: 100

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,
	GpgDisableSign:         false,
	GpgDisableVerify:       false,
	DownloadSourcePackages: false,
	PpaDistributorID:       "ubuntu",
	PpaCodename:            "",
	S3PublishRoots:         map[string]S3PublishRoot{},
}

Config is configuration for aptly, shared by all modules

Functions

func CompressFile

func CompressFile(source *os.File) 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 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 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
}

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

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"`
	GpgDisableSign         bool                     `json:"gpgDisableSign"`
	GpgDisableVerify       bool                     `json:"gpgDisableVerify"`
	DownloadSourcePackages bool                     `json:"downloadSourcePackages"`
	PpaDistributorID       string                   `json:"ppaDistributorID"`
	PpaCodename            string                   `json:"ppaCodename"`
	S3PublishRoots         map[string]S3PublishRoot `json:"S3PublishEndpoints"`
}

ConfigStructure is structure of main configuration

type GpgSigner

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

GpgSigner is implementation of Signer interface using gpg

func (*GpgSigner) ClearSign

func (g *GpgSigner) ClearSign(source string, destination string) error

ClearSign clear-signs the file

func (*GpgSigner) DetachedSign

func (g *GpgSigner) DetachedSign(source string, destination string) error

DetachedSign signs file with detached signature in ASCII format

func (*GpgSigner) Init

func (g *GpgSigner) Init() error

Init verifies availability of gpg & presence of keys

func (*GpgSigner) SetKey

func (g *GpgSigner) SetKey(keyRef string)

SetKey sets key ID to use when signing files

func (*GpgSigner) SetKeyRing

func (g *GpgSigner) SetKeyRing(keyring, secretKeyring string)

SetKeyRing allows to set custom keyring and secretkeyring

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

func (g *GpgVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error)

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

func (g *GpgVerifier) VerifyClearsigned(clearsigned io.Reader) 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"`
	AccessKeyID     string `json:"awsAccessKeyID"`
	SecretAccessKey string `json:"awsSecretAccessKey"`
	Prefix          string `json:"prefix"`
	ACL             string `json:"acl"`
}

S3PublishRoot describes single S3 publishing entry point

type Signer

type Signer interface {
	Init() error
	SetKey(keyRef string)
	SetKeyRing(keyring, secretKeyring string)
	DetachedSign(source string, destination string) error
	ClearSign(source string, destination string) error
}

Signer interface describes facility implementing signing of files

type Verifier

type Verifier interface {
	InitKeyring() error
	AddKeyring(keyring string)
	VerifyDetachedSignature(signature, cleartext io.Reader) error
	VerifyClearsigned(clearsigned io.Reader) error
	ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error)
}

Verifier interface describes signature verification factility

Jump to

Keyboard shortcuts

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