publisher

package
v0.0.0-...-6aa8790 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUninitializedRepositoryKeys = errors.New("uninitialized repository keys")
	ErrUninitializedPGPSigningKey  = errors.New("uninitialized pgp signing key")
)

Functions

func NewErrIncorrectTargetPath

func NewErrIncorrectTargetPath(path string) error

func SplitFilepath

func SplitFilepath(path string) (result []string)

TODO: move this to the separate project in github.com/werf

Types

type Filesystem

type Filesystem interface {
	IsFileExist(ctx context.Context, path string) (bool, error)
	ReadFile(ctx context.Context, path string, writer io.WriterAt) error
	ReadFileStream(ctx context.Context, path string, writer io.Writer) error
	ReadFileBytes(ctx context.Context, path string) ([]byte, error)
	WriteFileBytes(ctx context.Context, path string, data []byte) error
	WriteFileStream(ctx context.Context, path string, reader io.Reader) error
}

type InMemoryFile

type InMemoryFile struct {
	Name string
	Data []byte
}

type Interface

type Interface interface {
	GetRepository(ctx context.Context, storage logical.Storage, options RepositoryOptions) (RepositoryInterface, error)
	RotateRepositoryKeys(ctx context.Context, storage logical.Storage, repository RepositoryInterface, systemClock util.Clock) error
	UpdateTimestamps(ctx context.Context, storage logical.Storage, repository RepositoryInterface, systemClock util.Clock) error
	StageReleaseTarget(ctx context.Context, repository RepositoryInterface, releaseName, path string, data io.Reader) error
	StageChannelsConfig(ctx context.Context, repository RepositoryInterface, trdlChannelsConfig *config.TrdlChannels) error
	StageInMemoryFiles(ctx context.Context, repository RepositoryInterface, files []*InMemoryFile) error
	GetExistingReleases(ctx context.Context, repository RepositoryInterface) ([]string, error)
}

type NonAtomicTufStore

type NonAtomicTufStore struct {
	Filesystem Filesystem
	PrivKeys   TufRepoPrivKeys
	// contains filtered or unexported fields
}

func NewNonAtomicTufStore

func NewNonAtomicTufStore(privKeys TufRepoPrivKeys, filesystem Filesystem, logger hclog.Logger) *NonAtomicTufStore

func (*NonAtomicTufStore) Clean

func (m *NonAtomicTufStore) Clean() error

func (*NonAtomicTufStore) Commit

func (store *NonAtomicTufStore) Commit(consistentSnapshot bool, versions map[string]int64, _ map[string]data.Hashes) error

func (*NonAtomicTufStore) FileIsStaged

func (store *NonAtomicTufStore) FileIsStaged(filename string) bool

func (*NonAtomicTufStore) GetMeta

func (store *NonAtomicTufStore) GetMeta() (map[string]json.RawMessage, error)

func (*NonAtomicTufStore) GetSigners

func (store *NonAtomicTufStore) GetSigners(role string) ([]keys.Signer, error)

func (*NonAtomicTufStore) SaveSigner

func (store *NonAtomicTufStore) SaveSigner(role string, signer keys.Signer) error

func (*NonAtomicTufStore) SetMeta

func (store *NonAtomicTufStore) SetMeta(name string, meta json.RawMessage) error

func (*NonAtomicTufStore) SignersForKeyIDs

func (store *NonAtomicTufStore) SignersForKeyIDs(keyIDs []string) []keys.Signer

func (*NonAtomicTufStore) StageTargetFile

func (store *NonAtomicTufStore) StageTargetFile(ctx context.Context, targetPath string, data io.Reader) error

func (*NonAtomicTufStore) WalkStagedTargets

func (store *NonAtomicTufStore) WalkStagedTargets(targetPathList []string, targetsFn tuf.TargetsWalkFunc) error

type Publisher

type Publisher struct {
	PGPSigningKey *pgp.RSASigningKey
	// contains filtered or unexported fields
}

func NewPublisher

func NewPublisher(logger hclog.Logger) *Publisher

func (*Publisher) GetExistingReleases

func (publisher *Publisher) GetExistingReleases(ctx context.Context, repository RepositoryInterface) ([]string, error)

func (*Publisher) GetRepository

func (publisher *Publisher) GetRepository(ctx context.Context, storage logical.Storage, options RepositoryOptions) (RepositoryInterface, error)

func (*Publisher) Paths

func (publisher *Publisher) Paths() []*framework.Path

func (*Publisher) PeriodicFunc

func (m *Publisher) PeriodicFunc(_ context.Context, _ *logical.Request) error

func (*Publisher) RotateRepositoryKeys

func (publisher *Publisher) RotateRepositoryKeys(ctx context.Context, storage logical.Storage, repository RepositoryInterface, systemClock util.Clock) error

func (*Publisher) StageChannelsConfig

func (publisher *Publisher) StageChannelsConfig(ctx context.Context, repository RepositoryInterface, trdlChannelsConfig *config.TrdlChannels) error

func (*Publisher) StageInMemoryFiles

func (publisher *Publisher) StageInMemoryFiles(ctx context.Context, repository RepositoryInterface, files []*InMemoryFile) error

func (*Publisher) StageReleaseTarget

func (publisher *Publisher) StageReleaseTarget(ctx context.Context, repository RepositoryInterface, releaseName, releaseFilePath string, data io.Reader) error

func (*Publisher) UpdateTimestamps

func (publisher *Publisher) UpdateTimestamps(ctx context.Context, storage logical.Storage, repository RepositoryInterface, systemClock util.Clock) error

type RepositoryInterface

type RepositoryInterface interface {
	Init() error
	SetPrivKeys(privKeys TufRepoPrivKeys) error
	GetPrivKeys() TufRepoPrivKeys
	GenPrivKeys() error
	RotatePrivKeys(ctx context.Context) (bool, TufRepoPrivKeys, error)
	UpdateTimestamps(ctx context.Context, systemClock util.Clock) error
	StageTarget(ctx context.Context, pathInsideTargets string, data io.Reader) error
	CommitStaged(ctx context.Context) error
	GetTargets(ctx context.Context) ([]string, error)
}

type RepositoryOptions

type RepositoryOptions struct {
	S3Endpoint        string
	S3Region          string
	S3AccessKeyID     string
	S3SecretAccessKey string
	S3BucketName      string

	InitializeTUFKeys       bool
	InitializePGPSigningKey bool
}

type S3Filesystem

type S3Filesystem struct {
	AwsConfig  *aws.Config
	BucketName string
	// contains filtered or unexported fields
}

func NewS3Filesystem

func NewS3Filesystem(awsConfig *aws.Config, bucketName string, logger hclog.Logger) *S3Filesystem

func (*S3Filesystem) IsFileExist

func (fs *S3Filesystem) IsFileExist(ctx context.Context, path string) (bool, error)

func (*S3Filesystem) ReadFile

func (fs *S3Filesystem) ReadFile(ctx context.Context, path string, writerAt io.WriterAt) error

func (*S3Filesystem) ReadFileBytes

func (fs *S3Filesystem) ReadFileBytes(ctx context.Context, path string) ([]byte, error)

func (*S3Filesystem) ReadFileStream

func (fs *S3Filesystem) ReadFileStream(ctx context.Context, path string, writer io.Writer) error

func (*S3Filesystem) WriteFileBytes

func (fs *S3Filesystem) WriteFileBytes(ctx context.Context, path string, data []byte) error

func (*S3Filesystem) WriteFileStream

func (fs *S3Filesystem) WriteFileStream(ctx context.Context, path string, data io.Reader) error

type S3Options

type S3Options struct {
	AwsConfig  *aws.Config
	BucketName string
}

type S3Repository

type S3Repository struct {
	S3Filesystem *S3Filesystem
	TufStore     *NonAtomicTufStore
	TufRepo      *tuf.Repo
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(s3Filesystem *S3Filesystem, tufStore *NonAtomicTufStore, tufRepo *tuf.Repo, logger hclog.Logger) *S3Repository

func NewRepositoryWithOptions

func NewRepositoryWithOptions(s3Options S3Options, tufRepoOptions TufRepoOptions, logger hclog.Logger) (*S3Repository, error)

func (*S3Repository) CommitStaged

func (repository *S3Repository) CommitStaged(_ context.Context) error

func (*S3Repository) GenPrivKeys

func (repository *S3Repository) GenPrivKeys() error

func (*S3Repository) GetPrivKeys

func (repository *S3Repository) GetPrivKeys() TufRepoPrivKeys

func (*S3Repository) GetTargets

func (repository *S3Repository) GetTargets(ctx context.Context) ([]string, error)

func (*S3Repository) Init

func (repository *S3Repository) Init() error

func (*S3Repository) RotatePrivKeys

func (repository *S3Repository) RotatePrivKeys(ctx context.Context) (bool, TufRepoPrivKeys, error)

func (*S3Repository) SetPrivKeys

func (repository *S3Repository) SetPrivKeys(privKeys TufRepoPrivKeys) error

func (*S3Repository) StageTarget

func (repository *S3Repository) StageTarget(ctx context.Context, pathInsideTargets string, data io.Reader) error

func (*S3Repository) UpdateTimestamps

func (repository *S3Repository) UpdateTimestamps(_ context.Context, systemClock util.Clock) error

type TufRepoOptions

type TufRepoOptions struct {
	PrivKeys TufRepoPrivKeys
}

type TufRepoPrivKeys

type TufRepoPrivKeys struct {
	Root      *data.PrivateKey `json:"root"`
	Snapshot  *data.PrivateKey `json:"snapshot"`
	Targets   *data.PrivateKey `json:"targets"`
	Timestamp *data.PrivateKey `json:"timestamp"`
}

func (TufRepoPrivKeys) GetSigner

func (privKeys TufRepoPrivKeys) GetSigner(role string) (keys.Signer, error)

func (*TufRepoPrivKeys) SetKeyFromSigner

func (keys *TufRepoPrivKeys) SetKeyFromSigner(role string, signer keys.Signer) error

func (TufRepoPrivKeys) SetupStoreSigners

func (privKeys TufRepoPrivKeys) SetupStoreSigners(store tuf.LocalStore) error

func (TufRepoPrivKeys) SetupTufRepoSigners

func (privKeys TufRepoPrivKeys) SetupTufRepoSigners(tufRepo *tuf.Repo) error

type TufRepoRotator

type TufRepoRotator struct {
	TufRepo TufRepoRotatorAccessor
}

func NewTufRepoRotator

func NewTufRepoRotator(tufRepo TufRepoRotatorAccessor) *TufRepoRotator

func (*TufRepoRotator) Commit

func (rotator *TufRepoRotator) Commit() error

func (*TufRepoRotator) GetRootRotateAt

func (rotator *TufRepoRotator) GetRootRotateAt() (time.Time, error)

Root expires every year, rotate every 3 month

func (*TufRepoRotator) GetSnapshotRotateAt

func (rotator *TufRepoRotator) GetSnapshotRotateAt() (time.Time, error)

Snapshot expires every 7 days, rotate every 2nd day

func (*TufRepoRotator) GetTargetsRotateAt

func (rotator *TufRepoRotator) GetTargetsRotateAt() (time.Time, error)

Targets expires every 3 month, rotate every 3 weeks

func (*TufRepoRotator) GetTimestampRotateAt

func (rotator *TufRepoRotator) GetTimestampRotateAt() (time.Time, error)

Timestamp expires every day, rotate every 4th hour

func (*TufRepoRotator) Rotate

func (rotator *TufRepoRotator) Rotate(logger hclog.Logger, now time.Time) error

func (*TufRepoRotator) RotateRoot

func (rotator *TufRepoRotator) RotateRoot(now time.Time) error

func (*TufRepoRotator) RotateSnapshot

func (rotator *TufRepoRotator) RotateSnapshot(now time.Time) error

func (*TufRepoRotator) RotateTargets

func (rotator *TufRepoRotator) RotateTargets(now time.Time) error

func (*TufRepoRotator) RotateTimestamp

func (rotator *TufRepoRotator) RotateTimestamp(now time.Time) error

type TufRepoRotatorAccessor

type TufRepoRotatorAccessor interface {
	RootExpires() (time.Time, error)
	TargetsExpires() (time.Time, error)
	SnapshotExpires() (time.Time, error)
	TimestampExpires() (time.Time, error)

	IncrementRootVersionWithExpires(expires time.Time) error
	IncrementTargetsVersionWithExpires(expires time.Time) error
	IncrementSnapshotVersionWithExpires(expires time.Time) error
	IncrementTimestampVersionWithExpires(expires time.Time) error

	Commit() error
}

Jump to

Keyboard shortcuts

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