The Controller supports Git managed deployments. The Controller Git integration consists of a couple of concepts:
GitRepo
- The git repository with login information and location.GitConfig
- The VCLGroup specific Git configuration.A GitRepo
can be used by multiple VCLGroups while the GitConfig
is part of the VCLGroup itself.
Commits can be automatically deployed for a branch by configuring the VCLGroup to TrackLatest
changes. See VCLGroup.
The GitRepo
is Git repository information that is required to be able to access the git
repository.
URL
- The URL to the repository. Usually https
but can also be file://
if it is a locally
mounted repository.Token
- Access token for the repository.Username
- The username for the repository.Since the GitRepo
can be used by multiple VCLGroups any change to this affects all VCLGroups that
uses this GitRepo. This makes it simple to update token
at one place.
Each VCLGroup has it’s own GitConfig
which specifies how a GitRepo
should be used by the
VCLGroup.
GitRepoID
- The GitRepo
to use.Dir
- Which directory in the Git repository to use for deployments.Branch
- Which branch to useMainVCL
- Which file that is the Main VCL in the given directory.Exclude
- The Controller deploys all files except those matching the Exclude patterns. Regular
expressions can be used for pattern matching.The Dir
is useful if the Git repository contains multiple setups and the particular VCLGroup
should only deploy a set of files in the given directory.
The Controller will deploy all files not part of the Exclude
pattern. The specified MainVCL
will
be used as the main entry point for the VCLGroup, while all other files will be placed in the
Includes
section of the VCLGroup. Therefore, it is important to use the Exclude
to avoid
deploying files that is part of the Git repo but shouldn’t be deployed.
Files/directories starting with .
(dotfiles) will automatically be excluded.
First, a Git repository is created. The Controller then verifies connectivity to the repository, if it cannot be reached, the request will fail. Once the repository is successfully created, the VCLGroup can be configured with the repository settings and deployment instructions for using the Git repository. Each successful deployment from git will automatically create files in the Controller with files and versions for each file.
It is not possible to mix git files and Controller native files in the same VCLGroup deployment. To convert a previously git managed VCLGroup to use Controller native files, undeploy the VCLGroup and unassign the git-repository from the VCLGroup.
# Create a Git repo
vcli gitrepo add test \
--git-url https://github.com/varnish/vcls.git \
--git-token github_token_id \
--git-username oauth2
# Create a VCLGroup to deploy with the repository.
# git-repo: The ID of the previously created Git repo.
# git-branch: The git branch to use for deploying files
# git-main: Which file from the git repo that is the main VCL
# NOTE: All other files in the repo will be included as --includes
# if --exclude is not used.
vcli vg add test \
--tags id=1 \
--domains 1 \
--git-repo 1 \
--git-branch main \
--git-main main.vcl
# Exclude files with a comma separated list (go regexp is supported)
vcli vg add test \
--tags id=1 \
--domains 1 \
--git-repo 1 \
--git-branch main \
--git-main main.vcl \
--exclude "README.md,test.vcl"
# Only deploy a specific directory of the git repo (myvcls in this case).
# The main.vcl is expected to be found in the directory 'myvcls' in this case.
vcli vg add test \
--tags id=1 \
--domains 1 \
--git-repo 1 \
--git-branch main \
--git-main main.vcl \
--git-dir myvcls
# Deploy VCLGroup with ID 1, using the git repo (latest commit on given branch)
vcli vg deploy 1
# Test compile a specific commit SHA
vcli vg compile 1 --git-commit 563ed97c35e83d4e57a3bd4dafcaf715d08b38e2d
# Deploy a specific commit
vcli vg deploy 1 --git-commit 563ed97c35e83d4e57a3bd4dafcaf715d08b38e2d