zpm

package
v0.0.0-...-5f02759 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MPL-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PKICertCA           = "ca"
	PKICertIntermediate = "intermediate"
	PKICertUser         = "user"
	PKICertCRL          = "crl"
)
View Source
const (
	SecurityModeNone = "none"
)
View Source
const (
	SecurityModeOffline = "offline"
)

Variables

This section is empty.

Functions

func FilterPackagesByArch

func FilterPackagesByArch(osarch *zps.OsArch, zpkgs map[string]*zps.Pkg) ([]string, []*zps.Pkg)

func MergeTemplateConfig

func MergeTemplateConfig(pkgTpls []*action.Template, cfgTpls []*config.TplConfig) []*action.Template

func PublisherFromUri

func PublisherFromUri(uri *url.URL) string

func SafeURI

func SafeURI(uri *url.URL) string

func ValidateFileSignature

func ValidateFileSignature(security Security, contentPath string, signaturePath string) error

func ValidateZpkg

func ValidateZpkg(emitter *emission.Emitter, security Security, path string, quiet bool) error

TODO move to higher level zpkg util

Types

type ABSFetcher

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

func NewABSFetcher

func NewABSFetcher(uri *url.URL, cache *Cache, security Security) *ABSFetcher

func (*ABSFetcher) Fetch

func (a *ABSFetcher) Fetch(pkg *zps.Pkg) error

func (*ABSFetcher) Keys

func (a *ABSFetcher) Keys() ([][]string, error)

func (*ABSFetcher) Refresh

func (a *ABSFetcher) Refresh() error

type ABSPublisher

type ABSPublisher struct {
	*emission.Emitter
	// contains filtered or unexported fields
}

func NewABSPublisher

func NewABSPublisher(emitter *emission.Emitter, security Security, workPath string, uri *url.URL, name string, prune int, lockUri *url.URL) *ABSPublisher

func (*ABSPublisher) Channel

func (a *ABSPublisher) Channel(pkg string, channel string) error

func (*ABSPublisher) Init

func (a *ABSPublisher) Init() error

func (*ABSPublisher) Publish

func (a *ABSPublisher) Publish(pkgs ...string) error

func (*ABSPublisher) Update

func (a *ABSPublisher) Update() error

type Cache

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

func NewCache

func NewCache(path string) *Cache

func (*Cache) Clean

func (c *Cache) Clean() error

func (*Cache) Clear

func (c *Cache) Clear() error

func (*Cache) Exists

func (c *Cache) Exists(name string) bool

func (*Cache) GetConfig

func (c *Cache) GetConfig(uri string) string

func (*Cache) GetConfigSig

func (c *Cache) GetConfigSig(uri string) string

func (*Cache) GetFile

func (c *Cache) GetFile(name string) string

func (*Cache) GetMeta

func (c *Cache) GetMeta(osarch string, uri string) string

func (*Cache) GetMetaSig

func (c *Cache) GetMetaSig(osarch string, uri string) string

func (*Cache) HasMeta

func (c *Cache) HasMeta(uri string) bool

type CertEntry

type CertEntry struct {
	Fingerprint string `storm:"id"`
	Subject     string `storm:"index"`
	Publisher   string `storm:"index"`
	Type        string `storm:"index"`
	Cert        []byte
}

func NewCertEntry

func NewCertEntry(fingerprint string, publisher string, typ string, cert []byte) *CertEntry

type Config

type Config struct {
	Path string
}

func NewConfig

func NewConfig(path string) *Config

func (*Config) All

func (c *Config) All() (map[string]string, error)

func (*Config) Get

func (c *Config) Get(key string) (string, error)

func (*Config) Set

func (m *Config) Set(key string, value string) error

type ConfigEntry

type ConfigEntry struct {
	Key   string `storm:"id"`
	Value string
}

type DynamoLocker

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

func NewDynamoLocker

func NewDynamoLocker(uri *url.URL) *DynamoLocker

func (*DynamoLocker) Lock

func (d *DynamoLocker) Lock() error

func (*DynamoLocker) LockWithEtag

func (d *DynamoLocker) LockWithEtag() (string, error)

func (*DynamoLocker) Unlock

func (d *DynamoLocker) Unlock() error

Unlock is used when we need to unlock repo but metadata wasn't changed

func (*DynamoLocker) UnlockWithEtag

func (d *DynamoLocker) UnlockWithEtag(eTag *string) error

type Fetcher

type Fetcher interface {
	Refresh() error
	Fetch(pkg *zps.Pkg) error
	Keys() ([][]string, error)
}

func NewFetcher

func NewFetcher(uri *url.URL, cache *Cache, security Security, cloudProvider string) Fetcher

type FileFetcher

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

func NewFileFetcher

func NewFileFetcher(uri *url.URL, cache *Cache, security Security) *FileFetcher

func (*FileFetcher) Fetch

func (f *FileFetcher) Fetch(pkg *zps.Pkg) error

func (*FileFetcher) Keys

func (f *FileFetcher) Keys() ([][]string, error)

func (*FileFetcher) Refresh

func (f *FileFetcher) Refresh() error

type FileLocker

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

func NewFileLocker

func NewFileLocker(uri *url.URL) *FileLocker

func (*FileLocker) Lock

func (f *FileLocker) Lock() error

func (*FileLocker) LockWithEtag

func (f *FileLocker) LockWithEtag() (string, error)

func (*FileLocker) Unlock

func (f *FileLocker) Unlock() error

func (*FileLocker) UnlockWithEtag

func (f *FileLocker) UnlockWithEtag(eTag *string) error

type FilePublisher

type FilePublisher struct {
	*emission.Emitter
	// contains filtered or unexported fields
}

func NewFilePublisher

func NewFilePublisher(emitter *emission.Emitter, security Security, uri *url.URL, name string, prune int, lockUri *url.URL) *FilePublisher

func (*FilePublisher) Channel

func (f *FilePublisher) Channel(pkg string, channel string) error

func (*FilePublisher) Init

func (f *FilePublisher) Init() error

func (*FilePublisher) Publish

func (f *FilePublisher) Publish(pkgs ...string) error

func (*FilePublisher) Update

func (f *FilePublisher) Update() error

type FrozenEntry

type FrozenEntry struct {
	PkgId string `storm:"id"`
}

type FsEntry

type FsEntry struct {
	Key  string `storm:"id"`
	Path string `storm:"index"`
	Pkg  string `storm:"index"`
	Type string `storm:"index"`
}

func NewFsEntry

func NewFsEntry(path string, pkg string, typ string) *FsEntry

type GCSFetcher

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

func NewGCSFetcher

func NewGCSFetcher(uri *url.URL, cache *Cache, security Security) *GCSFetcher

func (*GCSFetcher) Fetch

func (g *GCSFetcher) Fetch(pkg *zps.Pkg) error

func (*GCSFetcher) Keys

func (g *GCSFetcher) Keys() ([][]string, error)

func (*GCSFetcher) Refresh

func (g *GCSFetcher) Refresh() error

type GCSPublisher

type GCSPublisher struct {
	*emission.Emitter
	// contains filtered or unexported fields
}

func NewGCSPublisher

func NewGCSPublisher(emitter *emission.Emitter, security Security, workPath string, uri *url.URL, name string, prune int, lockUri *url.URL) *GCSPublisher

func (*GCSPublisher) Channel

func (g *GCSPublisher) Channel(pkg string, channel string) error

func (*GCSPublisher) Init

func (g *GCSPublisher) Init() error

func (*GCSPublisher) Publish

func (g *GCSPublisher) Publish(pkgs ...string) error

func (*GCSPublisher) Update

func (g *GCSPublisher) Update() error

type HttpsFetcher

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

func NewHttpsFetcher

func NewHttpsFetcher(uri *url.URL, cache *Cache, security Security) *HttpsFetcher

func (*HttpsFetcher) Fetch

func (h *HttpsFetcher) Fetch(pkg *zps.Pkg) error

func (*HttpsFetcher) Keys

func (h *HttpsFetcher) Keys() ([][]string, error)

func (*HttpsFetcher) Refresh

func (h *HttpsFetcher) Refresh() error

type KeyPairEntry

type KeyPairEntry struct {
	Fingerprint string `storm:"id"`
	Subject     string `storm:"index"`
	Publisher   string `storm:"index"`
	Cert        []byte
	Key         []byte
}

func (*KeyPairEntry) RSAKey

func (k *KeyPairEntry) RSAKey() (*rsa.PrivateKey, error)

type LocalFetcher

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

func NewLocalFetcher

func NewLocalFetcher(uri *url.URL, cache *Cache, security Security) *LocalFetcher

func (*LocalFetcher) Fetch

func (f *LocalFetcher) Fetch(pkg *zps.Pkg) error

func (*LocalFetcher) Keys

func (f *LocalFetcher) Keys() ([][]string, error)

func (*LocalFetcher) Refresh

func (f *LocalFetcher) Refresh() error

type Locker

type Locker interface {
	LockWithEtag() (string, error)
	UnlockWithEtag(eTag *string) error
	Lock() error
	Unlock() error
}

func NewLocker

func NewLocker(uri *url.URL) Locker

type Manager

type Manager struct {
	*emission.Emitter
	// contains filtered or unexported fields
}

func NewManager

func NewManager(image string) (*Manager, error)

func (*Manager) CacheClean

func (m *Manager) CacheClean() error

func (*Manager) CacheClear

func (m *Manager) CacheClear() error

func (*Manager) Channel

func (m *Manager) Channel(repo string, pkg string, channel string) error

func (*Manager) Configure

func (m *Manager) Configure(packages []string, profile string) error

func (*Manager) Contents

func (m *Manager) Contents(pkgName string) ([]string, error)

func (*Manager) EmptyImage

func (m *Manager) EmptyImage(imagePath string) error

func (*Manager) Fetch

func (m *Manager) Fetch(args []string) error

func (*Manager) Freeze

func (m *Manager) Freeze(args []string) error

func (*Manager) ImageCurrent

func (m *Manager) ImageCurrent(image string) error

func (*Manager) ImageDelete

func (m *Manager) ImageDelete(image string) error

func (*Manager) ImageInit

func (m *Manager) ImageInit(imageFilePath string, name string, imageOs string, arch string, imagePath string, profile string, configure bool, force bool, helper bool) error

TODO this is trash, refactor it after Imagefile support is added

func (*Manager) ImageList

func (m *Manager) ImageList() error

func (*Manager) Info

func (m *Manager) Info(pkgName string) ([]string, error)

func (*Manager) Install

func (m *Manager) Install(args []string, request *zps.Request) error

func (*Manager) IsEmptyImage

func (m *Manager) IsEmptyImage(imagePath string) (bool, error)

func (*Manager) IsImage

func (m *Manager) IsImage(imagePath string) bool

func (*Manager) List

func (m *Manager) List() ([]string, error)

func (*Manager) PkiKeyPairImport

func (m *Manager) PkiKeyPairImport(certPath string, keyPath string) error

func (*Manager) PkiKeyPairList

func (m *Manager) PkiKeyPairList() ([]string, error)

func (*Manager) PkiKeyPairRemove

func (m *Manager) PkiKeyPairRemove(fingerprint string) error

func (*Manager) PkiTrustFetch

func (m *Manager) PkiTrustFetch(uriString string) error

func (*Manager) PkiTrustImport

func (m *Manager) PkiTrustImport(certPath string, typ string) error

func (*Manager) PkiTrustList

func (m *Manager) PkiTrustList() ([]string, error)

func (*Manager) PkiTrustRemove

func (m *Manager) PkiTrustRemove(fingerprint string) error

func (*Manager) Plan

func (m *Manager) Plan(action string, args []string) (*zps.Solution, error)

func (*Manager) Publish

func (m *Manager) Publish(repo string, pkgs ...string) error

func (*Manager) Refresh

func (m *Manager) Refresh() error

func (*Manager) Remove

func (m *Manager) Remove(args []string) error

func (*Manager) RepoContents

func (m *Manager) RepoContents(name string) ([]string, error)

func (*Manager) RepoInit

func (m *Manager) RepoInit(name string) error

func (*Manager) RepoList

func (m *Manager) RepoList() ([]string, error)

func (*Manager) RepoUnlock

func (m *Manager) RepoUnlock(name string, removeEtag bool) error

func (*Manager) RepoUpdate

func (m *Manager) RepoUpdate(name string) error

func (*Manager) Status

func (m *Manager) Status(query string) (string, []string, error)

func (*Manager) Thaw

func (m *Manager) Thaw(args []string) error

func (*Manager) Tpl

func (m *Manager) Tpl(tplPath string, profile string) error

func (*Manager) TransActionList

func (m *Manager) TransActionList() ([]string, error)

func (*Manager) Update

func (m *Manager) Update(reqs []string) error

func (*Manager) ZpkgBuild

func (m *Manager) ZpkgBuild(zpfPath string, targetPath string, workPath string, outputPath string, restrict bool, secure bool) error

func (*Manager) ZpkgContents

func (m *Manager) ZpkgContents(path string) ([]string, error)

TODO consider merging with Contents command via file path sniffing

func (*Manager) ZpkgExtract

func (m *Manager) ZpkgExtract(filepath string, target string) error

func (*Manager) ZpkgInfo

func (m *Manager) ZpkgInfo(path string) (string, error)

TODO consider merging with Info command utilizing file path sniffing

func (*Manager) ZpkgManifest

func (m *Manager) ZpkgManifest(path string) (string, error)

TODO consider reworking into Manifest command utilizing file path sniffing

func (*Manager) ZpkgSign

func (m *Manager) ZpkgSign(path string, workPath string) error

func (*Manager) ZpkgValidate

func (m *Manager) ZpkgValidate(path string) error

TODO also verify file digests

type Metadata

type Metadata struct {
	Path     string
	Packages *MetadataPackages
	Channels *MetadataChannels
	Updates  *MetadataUpdates
}

func NewMetadata

func NewMetadata(path string) *Metadata

func (*Metadata) All

func (m *Metadata) All() ([]*zps.Pkg, error)

func (*Metadata) Del

func (m *Metadata) Del(id string) error

func (*Metadata) Empty

func (m *Metadata) Empty() error

func (*Metadata) Exists

func (m *Metadata) Exists() bool

func (*Metadata) Get

func (m *Metadata) Get(name string) ([]*zps.Pkg, error)

func (*Metadata) Put

func (m *Metadata) Put(pkg *zps.Pkg) error

type MetadataChannels

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

func (*MetadataChannels) Add

func (m *MetadataChannels) Add(id string, channel string) error

func (*MetadataChannels) List

func (m *MetadataChannels) List() ([]string, error)

func (*MetadataChannels) Remove

func (m *MetadataChannels) Remove(id string, channel string) error

type MetadataPackages

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

type MetadataUpdates

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

type NoneLocker

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

func NewNoneLocker

func NewNoneLocker(uri *url.URL) *NoneLocker

func (*NoneLocker) Lock

func (n *NoneLocker) Lock() error

func (*NoneLocker) LockWithEtag

func (n *NoneLocker) LockWithEtag() (string, error)

func (*NoneLocker) Unlock

func (n *NoneLocker) Unlock() error

func (*NoneLocker) UnlockWithEtag

func (n *NoneLocker) UnlockWithEtag(etag *string) error

type PkgEntry

type PkgEntry struct {
	Name     string `storm:"id"`
	Manifest []byte
}

type Pki

type Pki struct {
	Path         string
	Certificates *PkiCertificates
	KeyPairs     *PkiKeyPairs
}

func NewPki

func NewPki(path string) *Pki

type PkiCertificates

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

func (*PkiCertificates) All

func (p *PkiCertificates) All() ([]*CertEntry, error)

func (*PkiCertificates) Del

func (p *PkiCertificates) Del(fingerprint string) error

func (*PkiCertificates) Get

func (p *PkiCertificates) Get(fingerprint string) (*CertEntry, error)

func (*PkiCertificates) GetByPublisher

func (p *PkiCertificates) GetByPublisher(publisher string) ([]*CertEntry, error)

func (*PkiCertificates) GetBySubject

func (p *PkiCertificates) GetBySubject(subject string) ([]*CertEntry, error)

func (*PkiCertificates) GetByType

func (p *PkiCertificates) GetByType(typ string) ([]*CertEntry, error)

func (*PkiCertificates) Put

func (p *PkiCertificates) Put(fingerprint string, subject string, publisher string, typ string, cert []byte) error

type PkiKeyPairs

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

func (*PkiKeyPairs) All

func (p *PkiKeyPairs) All() ([]*KeyPairEntry, error)

func (*PkiKeyPairs) Del

func (p *PkiKeyPairs) Del(fingerprint string) error

func (*PkiKeyPairs) Get

func (p *PkiKeyPairs) Get(fingerprint string) (*KeyPairEntry, error)

func (*PkiKeyPairs) GetByPublisher

func (p *PkiKeyPairs) GetByPublisher(publisher string) ([]*KeyPairEntry, error)

func (*PkiKeyPairs) GetBySubject

func (p *PkiKeyPairs) GetBySubject(subject string) ([]*KeyPairEntry, error)

func (*PkiKeyPairs) Put

func (p *PkiKeyPairs) Put(fingerprint string, subject string, publisher string, cert []byte, key []byte) error

type Publisher

type Publisher interface {
	Init() error
	Update() error
	Channel(pkg string, channel string) error
	Publish(...string) error
}

func NewPublisher

func NewPublisher(emitter *emission.Emitter, security Security, workPath string, uri *url.URL, name string, prune int, lockUri *url.URL) Publisher

type S3Fetcher

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

func NewS3Fetcher

func NewS3Fetcher(uri *url.URL, cache *Cache, security Security) *S3Fetcher

func (*S3Fetcher) Fetch

func (s *S3Fetcher) Fetch(pkg *zps.Pkg) error

func (*S3Fetcher) Keys

func (s *S3Fetcher) Keys() ([][]string, error)

func (*S3Fetcher) Refresh

func (s *S3Fetcher) Refresh() error

type S3Publisher

type S3Publisher struct {
	*emission.Emitter
	// contains filtered or unexported fields
}

func NewS3Publisher

func NewS3Publisher(emitter *emission.Emitter, security Security, workPath string, uri *url.URL, name string, prune int, lockUri *url.URL) *S3Publisher

func (*S3Publisher) Channel

func (s *S3Publisher) Channel(pkg string, channel string) error

func (*S3Publisher) Init

func (s *S3Publisher) Init() error

func (*S3Publisher) Publish

func (s *S3Publisher) Publish(pkgs ...string) error

func (*S3Publisher) Update

func (s *S3Publisher) Update() error

type Security

type Security interface {
	Mode() string
	Verify(content *[]byte, signatures []*action.Signature) (*action.Signature, error)
	KeyPair(publisher string) (*KeyPairEntry, error)
	Trust(content *[]byte, typ string) (string, string, error)
}

func NewSecurity

func NewSecurity(mode string, pki *Pki) (Security, error)

type SecurityNone

type SecurityNone struct{}

func (*SecurityNone) KeyPair

func (s *SecurityNone) KeyPair(publisher string) (*KeyPairEntry, error)

func (*SecurityNone) Mode

func (s *SecurityNone) Mode() string

func (*SecurityNone) Trust

func (s *SecurityNone) Trust(content *[]byte, typ string) (string, string, error)

func (*SecurityNone) Verify

func (s *SecurityNone) Verify(content *[]byte, signatures []*action.Signature) (*action.Signature, error)

TODO warn on the presence of invalid signatures

type SecurityOffline

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

func (*SecurityOffline) KeyPair

func (s *SecurityOffline) KeyPair(publisher string) (*KeyPairEntry, error)

func (*SecurityOffline) Mode

func (s *SecurityOffline) Mode() string

func (*SecurityOffline) Trust

func (s *SecurityOffline) Trust(content *[]byte, typ string) (string, string, error)

func (*SecurityOffline) Verify

func (s *SecurityOffline) Verify(content *[]byte, signatures []*action.Signature) (*action.Signature, error)

TODO warn on the presence of invalid signatures

type State

type State struct {
	Path         string
	Frozen       *StateFrozen
	Packages     *StatePackages
	Objects      *StateObjects
	Templates    *StateTemplates
	Transactions *StateTransactions
}

func NewState

func NewState(path string) *State

type StateFrozen

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

func (*StateFrozen) All

func (s *StateFrozen) All() ([]*FrozenEntry, error)

func (*StateFrozen) Del

func (s *StateFrozen) Del(pkgId string) error

func (*StateFrozen) Put

func (s *StateFrozen) Put(pkgId string) error

type StateObjects

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

func (*StateObjects) All

func (s *StateObjects) All() ([]*FsEntry, error)

func (*StateObjects) Del

func (s *StateObjects) Del(pkg string) error

func (*StateObjects) Get

func (s *StateObjects) Get(path string) ([]*FsEntry, error)

func (*StateObjects) Put

func (s *StateObjects) Put(path string, pkg string, typ string) error

type StatePackages

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

func (*StatePackages) All

func (s *StatePackages) All() ([]*action.Manifest, error)

func (*StatePackages) Del

func (s *StatePackages) Del(name string) error

func (*StatePackages) Get

func (s *StatePackages) Get(name string) (*action.Manifest, error)

func (*StatePackages) Put

func (s *StatePackages) Put(name string, pkg *action.Manifest) error

type StateTemplates

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

func (*StateTemplates) All

func (s *StateTemplates) All() ([]*TemplateEntry, error)

func (*StateTemplates) Del

func (s *StateTemplates) Del(pkg string) error

func (*StateTemplates) Get

func (s *StateTemplates) Get(pkg string) ([]*action.Template, error)

func (*StateTemplates) Put

func (s *StateTemplates) Put(pkg string, tpl *action.Template) error

type StateTransactions

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

func (*StateTransactions) All

func (s *StateTransactions) All() ([]*TransactionEntry, error)

func (*StateTransactions) Get

func (*StateTransactions) Put

func (s *StateTransactions) Put(id string, pkgId string, operation string, date *time.Time) error

type TemplateEntry

type TemplateEntry struct {
	Id   string `storm:"id"`
	Pkg  string `storm:"index"`
	Name string

	Source string
	Output string

	Owner string
	Group string
	Mode  string
}

type Transaction

type Transaction struct {
	*emission.Emitter
	// contains filtered or unexported fields
}

func NewTransaction

func NewTransaction(emitter *emission.Emitter, targetPath string, cache *Cache, state *State) *Transaction

func (*Transaction) Realize

func (t *Transaction) Realize(solution *zps.Solution) error

type TransactionEntry

type TransactionEntry struct {
	Key       string `storm:"id"`
	Id        string `storm:"index"`
	PkgId     string
	Operation string
	Date      *time.Time `storm:"index"`
}

func NewTransactionEntry

func NewTransactionEntry(id string, pkgId string, operation string, date *time.Time) *TransactionEntry

Jump to

Keyboard shortcuts

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