-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add git branch support, non-linear tag support and simplify git repo …
…logic (#1404) This refactors our git logic to be more in line with the goals of #1405 Fixes #1405 - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) - [ ] Test, docs, adr added or updated as needed - [ ] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow) followed --------- Co-authored-by: Wayne Starr <[email protected]> Co-authored-by: Wayne Starr <[email protected]>
- Loading branch information
1 parent
a226dae
commit 41aa660
Showing
21 changed files
with
302 additions
and
550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,34 @@ | ||
# Git Data | ||
|
||
This example shows how to package `git` repositories to be bundled and pushed across the air gap. This package does not deploy anything itself but pushes assets to the specified `git` service to be consumed as desired. Within Zarf, there are two main ways to include `git` repositories as described below. | ||
This example shows how to package `git` repositories within a Zarf package. This package does not deploy anything itself but pushes assets to the specified `git` service to be consumed as desired. Within Zarf, there are a few ways to include `git` repositories (as described below). | ||
|
||
:::info | ||
|
||
To view the example source code, select the `Edit this page` link below the article and select the parent folder. | ||
|
||
::: | ||
|
||
## Tag-Provided Git Repository Clone | ||
## Tag-Based Git Repository Clone | ||
|
||
Tag-provided `git` repository cloning is the recommended way of cloning a `git` repository for air-gapped deployments because it wraps meaning around a specific point in git history that can easily be traced back to the online world. Tag-provided clones are defined using the `scheme://host/repo@tag` format as seen in the example of the `defenseunicorns/zarf` repository (`https://github.com/defenseunicorns/[email protected]`). | ||
Tag-based `git` repository cloning is the **recommended** way of cloning a `git` repository for air-gapped deployments because it wraps meaning around a specific point in git history that can easily be traced back to the online world. Tag-based clones are defined using the `scheme://host/repo@tag` format as seen in the example of the `defenseunicorns/zarf` repository (`https://github.com/defenseunicorns/[email protected]`). | ||
|
||
A tag-provided clone only mirrors the tag defined in the Zarf definition. The tag will be applied on the `git` mirror to the default trunk branch of the repo (i.e. `master`, `main`, or the default when the repo is cloned). | ||
A tag-based clone only mirrors the tag defined in the Zarf definition. The tag will be applied on the `git` mirror to a zarf-specific branch name based on the tag name (e.g. the tag `v0.1.0` will be pushed to the `zarf-ref-v0.1.0` branch). This ensures that this tag will be pushed and received properly by the airgap `git` server. | ||
|
||
:::note | ||
|
||
If you would like to use a protocol scheme other than http/https, you can do so with something like the following: `ssh://[email protected]/defenseunicorns/[email protected]`. Using this you can also clone from a local repo to help you manage larger git repositories: `file:///home/zarf/workspace/[email protected]`. | ||
|
||
::: | ||
|
||
## SHA-Provided Git Repository Clone | ||
## SHA-Based Git Repository Clone | ||
|
||
SHA-provided `git` repository cloning is another supported way of cloning repos in Zarf but is not recommended as it is less readable/understandable than tag cloning. Commit SHAs are defined using the same `scheme://host/repo@shasum` format as seen in the example of the `defenseunicorns/zarf` repository (`https://github.com/defenseunicorns/zarf.git@c74e2e9626da0400e0a41e78319b3054c53a5d4e`). | ||
In addition to tags, Zarf also supports cloning and pushing a specific SHA hash from a `git` repository, but this is **not recommended** as it is less readable/understandable than tag cloning. Commit SHAs are defined using the same `scheme://host/repo@shasum` format as seen in the example of the `defenseunicorns/zarf` repository (`https://github.com/defenseunicorns/zarf.git@c74e2e9626da0400e0a41e78319b3054c53a5d4e`). | ||
|
||
A SHA-provided clone only mirrors the SHA hash defined in the Zarf definition. The SHA will be applied on the `git` mirror to the default trunk branch of the repo (i.e. `master`, `main`, or the default when the repo is cloned) as Zarf does with tagging. | ||
A SHA-based clone only mirrors the SHA hash defined in the Zarf definition. The SHA will be applied on the `git` mirror to a zarf-specific branch name based on the SHA hash (e.g. the SHA `c74e2e9626da0400e0a41e78319b3054c53a5d4e` will be pushed to the `zarf-ref-c74e2e9626da0400e0a41e78319b3054c53a5d4e` branch). This ensures that this tag will be pushed and received properly by the airgap `git` server. | ||
|
||
:::note | ||
|
||
If you use a SHA hash or a tag that is on a separate branch this will be placed on the default trunk branch on the offline mirror (i.e. `master`, `main`, etc). This may result in conflicts upon updates if this SHA or tag is not in the update branch's history. | ||
## Git Reference-Based Git Repository Clone | ||
|
||
::: | ||
If you need even more control, Zarf also supports providing full `git` [refspecs](https://git-scm.com/book/en/v2/Git-Internals-The-Refspec), as seen in `https://repo1.dso.mil/big-bang/bigbang.git@refs/heads/release-1.53.x`. This allows you to pull specific tags or branches by using this standard. The branch name used by zarf on deploy will depend on the kind of ref specified, branches will use the upstream branch name, whereas other refs (namely tags) will use the `zarf-ref-*` branch name. | ||
|
||
## Git Repository Full Clone | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,26 +5,38 @@ metadata: | |
description: "Demo Zarf loading resources into a gitops service" | ||
|
||
components: | ||
- name: full-repo | ||
- name: flux-demo | ||
required: true | ||
images: | ||
- ghcr.io/stefanprodan/podinfo:6.0.0 | ||
repos: | ||
# Do a full Git Repo Mirror | ||
# Do a full Git Repo Mirror of a flux repo | ||
- https://github.com/stefanprodan/podinfo.git | ||
# Clone an azure repo that breaks in go-git and has to fall back to the host git | ||
- https://[email protected]/me0515/zarf-public-test/_git/zarf-public-test | ||
|
||
- name: full-repo | ||
required: true | ||
repos: | ||
# Do a full Git Repo Mirror | ||
- https://github.com/kelseyhightower/nocode.git | ||
|
||
- name: specific-tag | ||
required: true | ||
repos: | ||
# Do a tag-provided Git Repo mirror | ||
# Do a tag-provided Git Repo mirror | ||
- https://github.com/defenseunicorns/[email protected] | ||
# Use the git refspec pattern to get a tag | ||
- https://github.com/defenseunicorns/zarf.git@refs/tags/v0.16.0 | ||
|
||
- name: specific-branch | ||
required: true | ||
repos: | ||
# Do a branch-provided Git Repo mirror | ||
- "https://repo1.dso.mil/big-bang/bigbang.git@refs/heads/release-1.53.x" | ||
|
||
- name: specific-hash | ||
required: true | ||
repos: | ||
# Do a commit hash Git Repo mirror | ||
# Do a commit hash Git Repo mirror | ||
- https://github.com/defenseunicorns/zarf.git@c74e2e9626da0400e0a41e78319b3054c53a5d4e | ||
# Clone an azure repo (w/SHA) that breaks in go-git and has to fall back to the host git | ||
# Clone an azure repo (w/SHA) that breaks in go-git and has to fall back to the host git | ||
- https://[email protected]/me0515/zarf-public-test/_git/zarf-public-test@524980951ff16e19dc25232e9aea8fd693989ba6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.