forked from kubernetes-sigs/kustomize
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/dependency pinning and update automation (kubernetes-sigs#5451)
* * handle local flag * add managerfactory handling for local flag * add shortName handling for local flag * add dot git file handling for local flag * add tests * fix normal listing * add ParseGitRepository function, add viper, add testing for utils * add latest tag logic, add auto pinning and auto fetching * makke gorepomod list works with --local * make pinning works with local flag, enable auto update on fork and non-fork repo * fix: refactor to pass linter * refactor code and fix comments * edit README * refactor code to pass linting * refactor code * refactor code and enable patch branch label * ru add license * fbackward compatibility for unpin
- Loading branch information
Showing
18 changed files
with
1,186 additions
and
85 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright 2023 The Kubernetes Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"os/exec" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestListCommand(t *testing.T) { | ||
// Assuming gorepomod is installed | ||
var testCases = map[string]struct { | ||
isFork bool | ||
cmd string | ||
expected string | ||
}{ | ||
"upstreamWithLocalFlag": { | ||
isFork: false, | ||
cmd: "cd ../.. && gorepomod list --local", | ||
}, | ||
"upstreamWithNoLocalFlag": { | ||
isFork: false, | ||
cmd: "cd ../.. && gorepomod list", | ||
}, | ||
"forkWithLocalFlag": { | ||
isFork: true, | ||
cmd: "cd ../.. && gorepomod list --local", | ||
}, | ||
"forkWithNoLocalFlag": { | ||
isFork: true, | ||
cmd: "cd ../.. && gorepomod list", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
bash, err := exec.LookPath("bash") | ||
if err != nil { | ||
t.Error("bash not found") | ||
} | ||
out, err := exec.Command(bash, "-c", tc.cmd).Output() | ||
if err != nil { | ||
assert.Error(t, err, "exit status 1") | ||
} | ||
assert.Greater(t, len(string(out)), 1) | ||
} | ||
} | ||
|
||
func TestPinCommand(t *testing.T) { | ||
// Assuming gorepomod is installed | ||
var testCases = map[string]struct { | ||
isFork bool | ||
cmd string | ||
}{ | ||
"upstreamWithLocalFlag": { | ||
isFork: false, | ||
cmd: "cd ../.. && gorepomod pin kyaml --local", | ||
}, | ||
"upstreamWithNoLocalFlag": { | ||
isFork: false, | ||
cmd: "cd ../.. && gorepomod pin kyaml", | ||
}, | ||
"forkWithLocalFlag": { | ||
isFork: true, | ||
cmd: "cd ../.. && gorepomod pin kyaml --local", | ||
}, | ||
"forkWithNoLocalFlag": { | ||
isFork: true, | ||
cmd: "cd ../.. && gorepomod pin kyaml", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
bash, err := exec.LookPath("bash") | ||
if err != nil { | ||
t.Error("bash not found") | ||
} | ||
out, err := exec.Command(bash, "-c", tc.cmd).Output() | ||
if err != nil { | ||
assert.Error(t, err, "exit status 1") | ||
} | ||
assert.Greater(t, len(string(out)), 1) | ||
} | ||
} |
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
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.