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

Safe HaskellNone
LanguageHaskell2010

B9.ArtifactGenerator

Description

Top-Level data types for B9 build artifacts.

Synopsis

Documentation

data ArtifactGenerator Source

Artifacts represent the things B9 can build. A generator specifies howto generate parameterized, multiple artifacts. The general structure is:

   Let [ ... bindings ... ]
       [ Sources
           [ ... list all input files ... ]
           [ Artifact ...
           , Artifact ...
           , Let [ ... ] [ ... ]
           ]
       ]

The reasons why Sources takes a list of ArtifactGenerators is that 1. this makes the value easier to read/write for humans 2. the sources are static files used in all children (e.g. company logo image) 3. the sources are parameterized by variables that bound to different values for each artifact, e.g. a template network config file which contains the host IP address.

To bind such variables use Let, Each, LetX or EachT.

String subtitution of these variables is done by B9.Content.StringTemplate. These variables can be used as value in nested Lets, in most file names/paths and in source files added with SourceFile

Constructors

Sources [ArtifactSource] [ArtifactGenerator]

Add sources available to ArtifactAssemblys in nested artifact generators.

Let [(String, String)] [ArtifactGenerator]

Bind variables, variables are avaible in nested generators.

LetX [(String, [String])] [ArtifactGenerator]

A Let where each variable is assigned to each value; the nested generator is executed for each permutation.

    LetX [("x", ["1","2","3"]), ("y", ["a","b"])] [..]

Is equal to:

    Let [] [
      Let [("x", "1"), ("y", "a")] [..]
      Let [("x", "1"), ("y", "b")] [..]
      Let [("x", "2"), ("y", "a")] [..]
      Let [("x", "2"), ("y", "b")] [..]
      Let [("x", "3"), ("y", "a")] [..]
      Let [("x", "3"), ("y", "b")] [..]
    ]
Each [(String, [String])] [ArtifactGenerator]

Bind each variable to their first value, then each variable to the second value, etc ... and execute the nested generator in every step. LetX represents a product of all variables, whereas Each represents a sum of variable bindings - Each is more like a zip whereas LetX is more like a list comprehension.

EachT [String] [[String]] [ArtifactGenerator]

The transposed verison of Each: Bind the variables in the first list to each a set of values from the second argument; execute the nested generators for each binding

Artifact InstanceId ArtifactAssembly

Generate an artifact defined by an ArtifactAssembly; the assembly can access the files created from the Sources and variables bound by Letish elements. An artifact has an instance id, that is a unique, human readable string describing the artifact to assemble.

EmptyArtifact 

data ArtifactSource Source

Describe how input files for artifacts to build are obtained. The general structure of each constructor is FromXXX destination source

Constructors

FromFile FilePath SourceFile

Copy a SourceFile potentially replacing variabled defined in Let-like parent elements.

FromContent FilePath Content

Create a file from some Content

SetPermissions Int Int Int [ArtifactSource]

Set the unix file permissions to all files generated by the nested list of ArtifactSources.

FromDirectory FilePath [ArtifactSource]

Assume a local directory as starting point for all relative source files in the nested ArtifactSources.

IntoDirectory FilePath [ArtifactSource]

Specify an output directory for all the files generated by the nested ArtifactSources

Concatenation FilePath [ArtifactSource]

Deprecated Concatenate the files generated by the nested ArtifactSources. The nested, generated files are not written when they are concatenated.

newtype InstanceId Source

Identify an artifact. Deprecated TODO: B9 does not check if all instances IDs are unique.

Constructors

IID String 

data ArtifactAssembly Source

Define an output of a build. Assemblies are nested into ArtifactGenerators. They contain all the files defined by the Sources they are nested into.

Constructors

CloudInit [CloudInitType] FilePath

Generate a cloud-init compatible directory, ISO- or VFAT image, as specified by the list of CloudInitTypes. Every item will use the second argument to create an appropriate file name, e.g. for the CI_ISO type the output is second_param.iso.

VmImages [ImageTarget] VmScript

a set of VM-images that were created by executing a build script on them.

data AssembledArtifact Source

A type representing the targets assembled by assemble from an ArtifactAssembly. There is a list of ArtifactTargets because e.g. a single CloudInit can produce upto three output files, a directory, an ISO image and a VFAT image.

instanceIdKey :: String Source

The variable containing the instance id. Deprecated

buildIdKey :: String Source

The variable containing the buildId that identifies each execution of B9. For more info about variable substitution in source files see StringTemplate

buildDateKey :: String Source

The variable containing the date and time a build was started. For more info about variable substitution in source files see StringTemplate