Skip to content

Commit

Permalink
Extracted clone submodules to subcommand (#1195)
Browse files Browse the repository at this point in the history
  • Loading branch information
satr authored Sep 20, 2024
1 parent f8f9ed6 commit 00a6c0e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/radix-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: radix-operator
version: 1.39.2
appVersion: 1.59.2
appVersion: 1.59.3
kubeVersion: ">=1.24.0"
description: Radix Operator
keywords:
Expand Down
2 changes: 1 addition & 1 deletion pipeline-runner/internal/jobs/build/acr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func assertACRJobSpec(t *testing.T, pushImage bool) {
assert.ElementsMatch(t, []string{"internal-nslookup", "clone", "internal-chmod"}, slice.Map(job.Spec.Template.Spec.InitContainers, func(c corev1.Container) string { return c.Name }))
cloneContainer, _ := slice.FindFirst(job.Spec.Template.Spec.InitContainers, func(c corev1.Container) bool { return c.Name == "clone" })
assert.Equal(t, args.GitCloneGitImage, cloneContainer.Image)
assert.Equal(t, []string{"sh", "-c", "git config --global --add safe.directory /workspace && git clone --recurse-submodules anycloneurl -b anybranch --verbose --progress /workspace && cd /workspace && if [ -n \"$(git lfs ls-files 2>/dev/null)\" ]; then git lfs install && echo 'Pulling large files...' && git lfs pull && echo 'Done'; fi && cd -"}, cloneContainer.Command)
assert.Equal(t, []string{"sh", "-c", "git config --global --add safe.directory /workspace && git clone anycloneurl -b anybranch --verbose --progress /workspace && (git submodule update --init --recursive || echo \"Warning: Unable to clone submodules, proceeding without them\") && cd /workspace && if [ -n \"$(git lfs ls-files 2>/dev/null)\" ]; then git lfs install && echo 'Pulling large files...' && git lfs pull && echo 'Done'; fi && cd -"}, cloneContainer.Command)
assert.Empty(t, cloneContainer.Args)
expectedCloneVolumeMounts := []corev1.VolumeMount{
{Name: git.BuildContextVolumeName, MountPath: git.Workspace},
Expand Down
2 changes: 1 addition & 1 deletion pipeline-runner/internal/jobs/build/buildkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func assertBuildKitJobSpec(t *testing.T, useCache, pushImage bool, buildSecrets
assert.ElementsMatch(t, []string{"internal-nslookup", "clone", "internal-chmod"}, slice.Map(job.Spec.Template.Spec.InitContainers, func(c corev1.Container) string { return c.Name }))
cloneContainer, _ := slice.FindFirst(job.Spec.Template.Spec.InitContainers, func(c corev1.Container) bool { return c.Name == "clone" })
assert.Equal(t, args.GitCloneGitImage, cloneContainer.Image)
assert.Equal(t, []string{"sh", "-c", "git config --global --add safe.directory /workspace && git clone --recurse-submodules anycloneurl -b anybranch --verbose --progress /workspace && cd /workspace && if [ -n \"$(git lfs ls-files 2>/dev/null)\" ]; then git lfs install && echo 'Pulling large files...' && git lfs pull && echo 'Done'; fi && cd -"}, cloneContainer.Command)
assert.Equal(t, []string{"sh", "-c", "git config --global --add safe.directory /workspace && git clone anycloneurl -b anybranch --verbose --progress /workspace && (git submodule update --init --recursive || echo \"Warning: Unable to clone submodules, proceeding without them\") && cd /workspace && if [ -n \"$(git lfs ls-files 2>/dev/null)\" ]; then git lfs install && echo 'Pulling large files...' && git lfs pull && echo 'Done'; fi && cd -"}, cloneContainer.Command)
assert.Empty(t, cloneContainer.Args)
expectedCloneVolumeMounts := []corev1.VolumeMount{
{Name: git.BuildContextVolumeName, MountPath: git.Workspace},
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/utils/git/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func CloneInitContainers(sshURL, branch string, config CloneConfig) []corev1.Con
// CloneInitContainersWithContainerName The sidecars for cloning repo
func CloneInitContainersWithContainerName(sshURL, branch, cloneContainerName string, config CloneConfig, useLfs bool) []corev1.Container {
gitConfigCommand := fmt.Sprintf("git config --global --add safe.directory %s", Workspace)
gitCloneCommand := fmt.Sprintf("git clone --recurse-submodules %s -b %s --verbose --progress %s", sshURL, branch, Workspace)
gitCloneCommand := fmt.Sprintf("git clone %s -b %s --verbose --progress %s && (git submodule update --init --recursive || echo \"Warning: Unable to clone submodules, proceeding without them\")", sshURL, branch, Workspace)
getLfsFilesCommands := fmt.Sprintf("cd %s && if [ -n \"$(git lfs ls-files 2>/dev/null)\" ]; then git lfs install && echo 'Pulling large files...' && git lfs pull && echo 'Done'; fi && cd -", Workspace)
gitCloneCmd := []string{"sh", "-c", fmt.Sprintf("%s && %s %s", gitConfigCommand, gitCloneCommand,
utils.TernaryString(useLfs, fmt.Sprintf("&& %s", getLfsFilesCommands), ""))}
Expand Down

0 comments on commit 00a6c0e

Please sign in to comment.