b9-2.1.0: A tool and library for building virtual machine images.

Safe HaskellNone
LanguageHaskell2010

B9.Repository

Description

B9 has a concept of SharedImaged. Shared images can be pulled and pushed to/from remote locations via rsync+ssh. B9 also maintains a local cache; the whole thing is supposed to be build-server-safe, that means no two builds shall interfere with each other. This is accomplished by refraining from automatic cache updates from/to remote repositories.

Synopsis

Documentation

type RepoCacheReader = Reader RepoCache Source #

Alias for a Reader Effect that reads a list of RemoteRepos.

Since: 0.5.65

getRepoCache :: Member RepoCacheReader e => Eff e RepoCache Source #

Ask for the RepoCache initialized by withRemoteRepos.

Since: 0.5.65

withSelectedRemoteRepo :: (Member B9ConfigReader e, Member ExcB9 e) => Eff (SelectedRemoteRepoReader ': e) a -> Eff e a Source #

Run a SelectedRemoteRepoReader with the SelectedRemoteRepo selected in the B9Config.

If the selected repo does not exist, and exception is thrown.

Since: 0.5.65

type SelectedRemoteRepoReader = Reader SelectedRemoteRepo Source #

Alias for a Reader Effect that reads the RemoteRepo selected by the B9Config value _repository. See withSelectedRemoteRepo.

Since: 0.5.65

data Repository Source #

Constructors

Cache 
Remote String 
Instances
Eq Repository Source # 
Instance details

Defined in B9.Repository

Ord Repository Source # 
Instance details

Defined in B9.Repository

Read Repository Source # 
Instance details

Defined in B9.Repository

Show Repository Source # 
Instance details

Defined in B9.Repository

Generic Repository Source # 
Instance details

Defined in B9.Repository

Associated Types

type Rep Repository :: Type -> Type #

Function Repository Source # 
Instance details

Defined in B9.Repository

Methods

function :: (Repository -> b) -> Repository :-> b #

Arbitrary Repository Source # 
Instance details

Defined in B9.Repository

CoArbitrary Repository Source # 
Instance details

Defined in B9.Repository

Methods

coarbitrary :: Repository -> Gen b -> Gen b #

type Rep Repository Source # 
Instance details

Defined in B9.Repository

type Rep Repository = D1 (MetaData "Repository" "B9.Repository" "b9-2.1.0-RZRDTT94jm9r60J5nt33" False) (C1 (MetaCons "Cache" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Remote" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)))

type RepoImagesMap = Map Repository (Set SharedImage) Source #

A Map that maps Repositorys to the SharedImages they hold.

Since: 1.1.0

newtype SelectedRemoteRepo Source #

Contains the Just the RemoteRepo selected by the B9Config value _repository, or Nothing of no RemoteRepo was selected in the B9Config.

Since: 0.5.65

remoteRepoCacheDir Source #

Arguments

:: RepoCache

The repository cache directory

-> String

Id of the repository

-> FilePath

The existing, absolute path to the cache directory

Return the cache directory for a remote repository relative to the root cache dir.

localRepoDir Source #

Arguments

:: RepoCache

The repository cache directory

-> FilePath

The existing, absolute path to the directory

Return the local repository directory.

lookupRemoteRepo :: Set RemoteRepo -> String -> Maybe RemoteRepo Source #

Select the first RemoteRepo with a given repoId.

filterRepoImagesMap :: (Repository -> Bool) -> (SharedImage -> Bool) -> RepoImagesMap -> RepoImagesMap Source #

Filter the SharedImages returned by getSharedImages using a Repository-, and a SharedImage predicate.

Since: 1.1.0

lookupCachedImages :: SharedImageName -> RepoImagesMap -> Set SharedImage Source #

Return the versions of a shared image named name from the local cache.

Since: 1.1.0

allSharedImagesWithRepo :: RepoImagesMap -> Set (SharedImage, Repository) Source #

Fetch all SharedImages like allSharedImages but attach the Repository that the image belongs to.

Usage example: In combination with filterRepoImagesMap to find the latest version of a certain image in all known repositories.

Since: 1.1.0

maxSharedImageOfAllRepos :: RepoImagesMap -> Maybe (SharedImage, Repository) Source #

Return the maximum with regard to the Ord instance of SharedImage from an RepoImagesMap

Since: 1.1.0

allSharedImagesInRepo :: Repository -> RepoImagesMap -> Set SharedImage Source #

Return the SharedImages, that are contained in a Repository.

Since: 1.1.0

allRepositories :: RepoImagesMap -> Set Repository Source #

Return a Set of Repository names from a RepoImagesMap

Since: 1.1.0

keepNLatestSharedImages :: Int -> Set SharedImage -> Set SharedImage Source #

Take a subset that contains the n latest versions of SharedImages with the same name.

For example, if the input contains:

@@ fromList [ SharedImage "foo" "2020-07-07 13:34:31" , SharedImage "foo" "2020-07-07 13:34:32" , SharedImage "foo" "2020-07-07 13:34:33" , SharedImage "bar" "2020-07-07 13:34:34" , SharedImage "bar" "2020-07-07 13:34:35" , SharedImage "bar" "2020-07-07 13:34:36" ] @@

The output of keepNLatestSharedImages 2 will be:

@@ fromList [ SharedImage "foo" "2020-07-07 13:34:32" , SharedImage "foo" "2020-07-07 13:34:33" , SharedImage "bar" "2020-07-07 13:34:35" , SharedImage "bar" "2020-07-07 13:34:36" ] @@

Since: 1.1.0

dropAllButNLatestSharedImages :: Int -> Set SharedImage -> Set SharedImage Source #

Take a subset that contains obsolete images.

Do the opposite of keepNLatestSharedImages, and return all **but** the n latest versions of SharedImages with the same name.

For example, if the input contains:

@@ fromList [ SharedImage "foo" "2020-07-07 13:34:31" , SharedImage "foo" "2020-07-07 13:34:32" , SharedImage "foo" "2020-07-07 13:34:33" , SharedImage "bar" "2020-07-07 13:34:34" , SharedImage "bar" "2020-07-07 13:34:35" , SharedImage "bar" "2020-07-07 13:34:36" ] @@

The output of keepNLatestSharedImages 2 will be:

@@ fromList [ SharedImage "foo" "2020-07-07 13:34:31" , SharedImage "bar" "2020-07-07 13:34:34" ] @@

Since: 1.1.0