Repo Layout¶
For Infrastructure as Code (Iac) practices, it is useful to store your content packs into a change control system, e.g. git.
The following documentation will use git
as our example repository.
A common useful direcotry structure is as follows.
Example
In the above example, repo-test
is our git repository. A common layout
includes a .gitignore
file, a README.md
, and a set of tools files.
.gitignore¶
The .gitignore
ignores toplevel yaml and json files, version definition files, and
a catalog holding file (rebar-catalog).
Tools Files and Scripts¶
In the tools directory, there are a couple of build scripts and a contents list file, packs
.
The build scripts are for bash and powershell. They assume that git
is present and Semver
based version tags.
These scripts will use drpcli to get the version from the current git branch and bundle
each content pack listed in the packs
file setting the version to the value from drpcli.
tools/build_content.sh File¶
#!/usr/bin/env bash
version=$(drpcli generate git version get)
for cpname in `cat tools/packs` ; do
cd ${cpname}
rm -f ._Version.meta
drpcli contents bundle ../${cpname}.json Version=$version
drpcli contents bundle ../${cpname}.yaml Version=$version --format=yaml
cd ..
done
tools/build_content.ps1 File¶
# Get the version using drpcli
$version = drpcli generate git version get
# Read the contents of tools/packs
$cpnames = Get-Content -Path "tools/packs"
foreach ($cpname in $cpnames) {
# Change directory to the current cpname
Set-Location -Path $cpname
# Remove the ._Version.meta file if it exists
Remove-Item -Path "._Version.meta" -Force -ErrorAction SilentlyContinue
# Bundle the contents into JSON and YAML formats
drpcli contents bundle "../$cpname.json" Version=$version
drpcli contents bundle "../$cpname.yaml" Version=$version --format=yaml
# Return to the previous directory
Set-Location -Path ".."
}
tools/packs File¶
The tools/packs
file is a flat text file with one line for each content pack directory within the repo.
The entry is a directory at the top-level of the repo.
Versioning¶
Within the repo, branches and tags can be used to track versions. The drpcli generate git version get
command
will attempt to find the most recent SEMVER tag, e.g. v4.13.3 and generate a version from it.
If the tag is on the current commit, the value is used directly.
Example
If the current commit is not tag, the number of commits from that most recent tag is generated and
the git hash is with g
proceeding it is created.
Example
These version get automatically injected into the content packs if the tools/build scripts are used.
Additional, CI/CD automation can be used to run the tools and publish the content packs into artifact repositories. For example, RackN uses gitlab ci/cd to automatically build and version content packs and publish them into AWS s3 buckets after generating our public catalog files.