hocker-1.0.3: 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 Source #

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

exitProgFail :: String -> IO a Source #

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 () Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

Given a Auth produce a Options.

sha256 :: ByteString -> Digest SHA256 Source #

Hash a Char8 using the SHA256 algorithm.

stripHashId :: Text -> Text Source #

Strip the sha256: identifier prefix from a hash digest.

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

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 Source #

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

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

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) Source #

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

renderNixExpr :: NExpr -> SimpleDoc Source #

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

pprintNixExpr :: NExpr -> IO () Source #

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

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

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