composedb

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComposeHistory

type ComposeHistory struct {
	DB Database
}

ComposeHistory used to interact with the previous compose files.

func (ComposeHistory) ListVersions

func (s ComposeHistory) ListVersions() ([]Version, error)

ListVersions lists the latest stored versions of the compose history files.

func (ComposeHistory) RestoreLatestVersion

func (s ComposeHistory) RestoreLatestVersion() ([]byte, error)

RestoreLatestVersion returns the latest version of the saved compose history.

func (ComposeHistory) RestoreVersion

func (s ComposeHistory) RestoreVersion(version string) ([]byte, error)

RestoreVersion returns the requested version of the saved compose history.

func (ComposeHistory) SaveCurrentVersion

func (s ComposeHistory) SaveCurrentVersion(bytes []byte) (string, error)

SaveCurrentVersion stores the provided compose history into the compose history records.

type Database

type Database interface {
	Read(versionID string) ([]byte, error)
	Write(versionID string, data []byte) error
	Delete(versionID string) error
	GetObjectVersions() ([]Version, error)
}

Database is the interface for a backing database used to store docker-compose yaml file history.

type FileDatabase

type FileDatabase struct{}

FileDatabase implements is an abstraction of os.WriterFile.

func (FileDatabase) Delete

func (db FileDatabase) Delete(filename string) error

Delete implements the Delete interface for a flat filesystem database.

func (FileDatabase) GetObjectVersions

func (db FileDatabase) GetObjectVersions() ([]Version, error)

GetObjectVersions returns the name and modified time of all objects stored in the DB.

func (FileDatabase) Read

func (db FileDatabase) Read(filename string) ([]byte, error)

Read implements the Reader interface for a flat filesystem database.

func (FileDatabase) Write

func (db FileDatabase) Write(filename string, data []byte) error

Write implements the Writer interface for a flat filesystem database.

type Version

type Version struct {
	// todo use VersionID instead of string
	ID          string
	LastUpdated time.Time
}

Version is made up of the ID and the last time the record was updated.

type VersionStore

type VersionStore interface {
	// todo use VersionID instead of string
	SaveCurrentVersion(bytes []byte) (string, error)
	RestoreLatestVersion() ([]byte, error)
	// todo use VersionID instead of string
	RestoreVersion(string) ([]byte, error)
	ListVersions() ([]Version, error)
}

VersionStore is the interface for operations performed on the docker-compose yaml file history.

Jump to

Keyboard shortcuts

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