hocker-1.0.5: Interact with the docker registry and generate nix build instructions

Copyright(C) 2016 Awake Networks
LicenseApache-2.0
MaintainerAwake Networks <opensource@awakenetworks.com>
Stabilitystable
Safe HaskellNone
LanguageHaskell2010

Hocker.Lib

Description

 

Synopsis

Documentation

die :: MonadIO io => Text -> io a #

Throw a userError, exiting the program with the supplied message.

exitProgFail :: String -> IO a #

Print an error message to stderr and return a non-zero exit code, the message is prefixed with the name of the program.

writeOrPrint :: Maybe FilePath -> ByteString -> IO () #

Print the bytestring to stdout if the first argument is Nothing, otherwise write the bytestring to the provided filesystem path and print the path to stdout.

mkOutImage #

Arguments

:: ImageName

Docker image name

-> FilePath

Base path to write to

-> FilePath 

Combine an image name and a base path producing an output path.

mkOutConfig #

Arguments

:: ImageName

Docker image name

-> ImageTag

Docker image tag

-> FilePath

Base path to write to

-> FilePath 

Combine an image name, an image tag, and a base path producing an output path with a -config.json suffix.

mkOutManifest #

Arguments

:: ImageName

Docker image name

-> ImageTag

Docker image tag

-> FilePath

Base path to write to

-> FilePath 

Combine an image name, an image tag, and a base path producing an output path with a -manifest.json suffix.

joinURIPath #

Arguments

:: [String]

Extra path segments to add

-> RegistryURI

Base URI to add path segments to

-> RegistryURI 

Join a list of strings and the path part of a RegistryURI to produce a new RegistryURI with a path root of /v2.

opts :: Maybe Auth -> Options #

Given a Auth produce a Options.

sha256 :: ByteString -> Digest SHA256 #

Hash a Char8 using the SHA256 algorithm.

stripHashId :: Text -> Text #

Strip the sha256: identifier prefix from a hash digest.

encodeCanonical :: ToJSON a => a -> ByteString #

Encode, following Docker's canonical JSON rules, any ToJSON data type.

The canonicalization rules enable consistent hashing of encoded JSON, a process relied upon heavily by docker for content addressability and unique identification of resources within a docker registry. Notably, an image's config JSON file and layers.

NB: Docker's canonical JSON spec intentionally *does not* follow the OLPC's Canonical JSON format even though it was inspired by it.

requirePath :: MonadError HockerException m => Maybe FilePath -> m FilePath #

Throw an error if the first argument is Nothing, otherwise return the FilePath unwrapped.

getConfigDigest :: MonadError HockerException m => ByteString -> m (Digest SHA256) #

Pluck out the digest value for the config JSON given a docker registry image manifest. Attempting to parse and return the digest value as a SHA256, otherwise throw an error.

splitRepository :: ImageName -> (RepoNamePart, ImageNamePart) #

Split a docker image's name on the forward slash separator so we get the distinct repo name and image name.

renderNixExpr :: NExpr -> SimpleDoc #

Given a nix expression AST, produce a pretty printer document.

pprintNixExpr :: NExpr -> IO () #

Print a nix expression AST using the renderNixExpr pretty printing renderer.

findExec :: (MonadIO m, MonadError HockerException m) => String -> m FilePath #

Given an executable's name, try to find it in the PATH.