Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1766 - Git Tag and Chart Version assumed to match #1892

Merged
merged 18 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/internal/packager/git/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (g *Git) Pull(gitURL, targetFolder string, shallow bool) error {
g.Spinner.Updatef("Processing git repo %s", gitURL)

// Split the remote url and the zarf reference
gitURLNoRef, refPlain, err := transform.GitTransformURLSplitRef(gitURL)
gitURLNoRef, refPlain, err := transform.GitURLSplitRef(gitURL)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion src/internal/packager/helm/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
// PackageChart creates a chart archive from a path to a chart on the host os and builds chart dependencies
func (h *Helm) PackageChart(destination string) error {
cmwylie19 marked this conversation as resolved.
Show resolved Hide resolved
if len(h.Chart.URL) > 0 {
url, refPlain, err := transform.GitTransformURLSplitRef(h.Chart.URL)
url, refPlain, err := transform.GitURLSplitRef(h.Chart.URL)
// check if the chart is a git url with a ref (if an error is returned url will be empty)
isGitURL := strings.HasSuffix(url, ".git")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/packager/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ func (p *Packager) removeCopiesFromDifferentialPackage() error {
// Generate a list of all unique repos for this component
for _, repoURL := range component.Repos {
// Split the remote url and the zarf reference
_, refPlain, err := transform.GitTransformURLSplitRef(repoURL)
_, refPlain, err := transform.GitURLSplitRef(repoURL)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/transform/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func MutateGitURLsInText(logger Log, targetBaseURL string, text string, pushUser
return output
}

// GitTransformURLSplitRef takes a git url and returns a separated source url and zarf reference.
func GitTransformURLSplitRef(sourceURL string) (string, string, error) {
// GitURLSplitRef takes a git url and returns a separated source url and zarf reference.
func GitURLSplitRef(sourceURL string) (string, string, error) {
cmwylie19 marked this conversation as resolved.
Show resolved Hide resolved
get, err := helpers.MatchRegex(gitURLRegex, sourceURL)

if err != nil {
Expand Down
11 changes: 8 additions & 3 deletions src/pkg/transform/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var gitURLs = []string{
"https://github.com/defenseunicorns/zarf.helm.git",
"https://github.com/defenseunicorns/zarf.git@refs/tags/v0.16.0",
"https://github.com/DoD-Platform-One/big-bang.git@refs/heads/release-1.54.x",
"https://github.com/prometheus-community/[email protected]",

// Smart Git Protocol URLs for proxying (https://www.git-scm.com/docs/http-protocol)
"https://github.com/defenseunicorns/zarf.helm.git/info/refs",
Expand Down Expand Up @@ -70,7 +71,7 @@ func TestMutateGitURLsInText(t *testing.T) {
require.Equal(t, expectedText, resultingText)
}

func TestGitTransformURLSplitRef(t *testing.T) {
func TestGitURLSplitRef(t *testing.T) {
var expectedResult = [][]string{
// Normal git repos and references for pushing/pulling
{"https://repo1.dso.mil/platform-one/big-bang/apps/security-tools/twistlock.git", ""},
Expand All @@ -87,6 +88,7 @@ func TestGitTransformURLSplitRef(t *testing.T) {
{"https://github.com/defenseunicorns/zarf.helm.git", ""},
{"https://github.com/defenseunicorns/zarf.git", "refs/tags/v0.16.0"},
{"https://github.com/DoD-Platform-One/big-bang.git", "refs/heads/release-1.54.x"},
{"https://github.com/prometheus-community/helm-charts.git", "kube-prometheus-stack-47.3.0"},
Racer159 marked this conversation as resolved.
Show resolved Hide resolved

// Smart Git Protocol URLs for proxying (https://www.git-scm.com/docs/http-protocol)
{"https://github.com/defenseunicorns/zarf.helm.git", ""},
Expand All @@ -97,14 +99,14 @@ func TestGitTransformURLSplitRef(t *testing.T) {
}

for idx, url := range gitURLs {
gitURLNoRef, refPlain, err := GitTransformURLSplitRef(url)
gitURLNoRef, refPlain, err := GitURLSplitRef(url)
require.NoError(t, err)
require.Equal(t, expectedResult[idx][0], gitURLNoRef)
require.Equal(t, expectedResult[idx][1], refPlain)
}

for _, url := range badGitURLs {
_, _, err := GitTransformURLSplitRef(url)
_, _, err := GitURLSplitRef(url)
require.Error(t, err)
}
}
Expand All @@ -126,6 +128,7 @@ func TestGitTransformURLtoFolderName(t *testing.T) {
"zarf.helm-2570741950",
"zarf-2175050463",
"big-bang-2705706079",
"helm-charts-1319967699",

// Smart Git Protocol URLs for proxying (https://www.git-scm.com/docs/http-protocol)
"zarf.helm-2570741950",
Expand Down Expand Up @@ -164,6 +167,7 @@ func TestGitTransformURLtoRepoName(t *testing.T) {
"zarf.helm-842267124",
"zarf-1211668992",
"big-bang-2366614037",
"helm-charts-3648076006",

// Smart Git Protocol URLs for proxying (https://www.git-scm.com/docs/http-protocol)
"zarf.helm-842267124",
Expand Down Expand Up @@ -202,6 +206,7 @@ func TestGitTransformURL(t *testing.T) {
"https://gitlab.com/repo-owner/zarf.helm-842267124.git",
"https://gitlab.com/repo-owner/zarf-1211668992.git",
"https://gitlab.com/repo-owner/big-bang-2366614037.git",
"https://gitlab.com/repo-owner/helm-charts-3648076006.git",

// Smart Git Protocol URLs for proxying (https://www.git-scm.com/docs/http-protocol)
"https://gitlab.com/repo-owner/zarf.helm-842267124.git/info/refs",
Expand Down