mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Update full linter list and enable some easily resolved new ones
This commit is contained in:
@@ -341,6 +341,7 @@ data:
|
||||
// The return value indicates whether we should skip the rest of the test case
|
||||
// due to the error result.
|
||||
func SkipRest(t *testing.T, desc string, err error, contains string) bool {
|
||||
t.Helper()
|
||||
if err != nil {
|
||||
if len(contains) == 0 {
|
||||
t.Errorf("case %q, expect nil error but got %q", desc, err.Error())
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func makeResAccumulator(t *testing.T) *ResAccumulator {
|
||||
t.Helper()
|
||||
ra := MakeEmptyAccumulator()
|
||||
err := ra.MergeConfig(builtinconfig.MakeDefaultConfig())
|
||||
if err != nil {
|
||||
@@ -133,6 +134,7 @@ func TestResolveVarsOneUnused(t *testing.T) {
|
||||
}
|
||||
|
||||
func expectLog(t *testing.T, log bytes.Buffer, expect string) {
|
||||
t.Helper()
|
||||
if !strings.Contains(log.String(), expect) {
|
||||
t.Fatalf("expected log containing '%s', got '%s'", expect, log.String())
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ func makeAndLoadKustTarget(
|
||||
t *testing.T,
|
||||
fSys filesys.FileSystem,
|
||||
root string) *target.KustTarget {
|
||||
t.Helper()
|
||||
kt := makeKustTargetWithRf(t, fSys, root, provider.NewDefaultDepProvider())
|
||||
if err := kt.Load(); err != nil {
|
||||
t.Fatalf("Unexpected load error %v", err)
|
||||
@@ -32,6 +33,7 @@ func makeKustTargetWithRf(
|
||||
fSys filesys.FileSystem,
|
||||
root string,
|
||||
pvd *provider.DepProvider) *target.KustTarget {
|
||||
t.Helper()
|
||||
ldr, err := fLdr.NewLoader(fLdr.RestrictionRootOnly, root, fSys)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -179,9 +179,11 @@ func TestDefaultAbsPluginHomeNoXdgJustHomeDir(t *testing.T) {
|
||||
}
|
||||
|
||||
func setenv(t *testing.T, key, value string) {
|
||||
t.Helper()
|
||||
require.NoError(t, os.Setenv(key, value))
|
||||
}
|
||||
|
||||
func unsetenv(t *testing.T, key string) {
|
||||
t.Helper()
|
||||
require.NoError(t, os.Unsetenv(key))
|
||||
}
|
||||
|
||||
@@ -214,6 +214,7 @@ spec:
|
||||
}
|
||||
|
||||
func skipIfNoDocker(t *testing.T) {
|
||||
t.Helper()
|
||||
if _, err := exec.LookPath("docker"); err != nil {
|
||||
t.Skip("skipping because docker binary wasn't found in PATH")
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ metadata:
|
||||
}
|
||||
|
||||
func makeTmpDir(t *testing.T) string {
|
||||
t.Helper()
|
||||
base, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("err %v", err)
|
||||
|
||||
@@ -240,6 +240,7 @@ func commonSetupForLoaderRestrictionTest() (string, filesys.FileSystem, error) {
|
||||
// in or below the loader root.
|
||||
func doSanityChecksAndDropIntoBase(
|
||||
t *testing.T, l ifc.Loader) ifc.Loader {
|
||||
t.Helper()
|
||||
data, err := l.Load(path.Join("base", "okayData"))
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
|
||||
@@ -56,12 +56,14 @@ var origin2 = &resource.Origin{
|
||||
}
|
||||
|
||||
func doAppend(t *testing.T, w ResMap, r *resource.Resource) {
|
||||
t.Helper()
|
||||
err := w.Append(r)
|
||||
if err != nil {
|
||||
t.Fatalf("append error: %v", err)
|
||||
}
|
||||
}
|
||||
func doRemove(t *testing.T, w ResMap, id resid.ResId) {
|
||||
t.Helper()
|
||||
err := w.Remove(id)
|
||||
if err != nil {
|
||||
t.Fatalf("remove error: %v", err)
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func setupRMForPatchTargets(t *testing.T) ResMap {
|
||||
t.Helper()
|
||||
result, err := rmF.NewResMapFromBytes([]byte(`
|
||||
apiVersion: group1/v1
|
||||
kind: Kind1
|
||||
|
||||
@@ -26,7 +26,6 @@ type Resource struct {
|
||||
refVarNames []string
|
||||
}
|
||||
|
||||
// nolint
|
||||
var BuildAnnotations = []string{
|
||||
utils.BuildAnnotationPreviousKinds,
|
||||
utils.BuildAnnotationPreviousNames,
|
||||
|
||||
@@ -32,6 +32,7 @@ func run(input string, f kio.Filter) (string, error) {
|
||||
|
||||
// RunFilter runs filter and panic if there is error
|
||||
func RunFilter(t *testing.T, input string, f kio.Filter) string {
|
||||
t.Helper()
|
||||
output, err := run(input, f)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
@@ -41,6 +42,7 @@ func RunFilter(t *testing.T, input string, f kio.Filter) string {
|
||||
|
||||
// RunFilterE runs filter and return error if there is
|
||||
func RunFilterE(t *testing.T, input string, f kio.Filter) (string, error) {
|
||||
t.Helper()
|
||||
output, err := run(input, f)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -22,11 +22,13 @@ type Harness struct {
|
||||
}
|
||||
|
||||
func MakeHarness(t *testing.T) Harness {
|
||||
t.Helper()
|
||||
return MakeHarnessWithFs(t, filesys.MakeFsInMemory())
|
||||
}
|
||||
|
||||
func MakeHarnessWithFs(
|
||||
t *testing.T, fSys filesys.FileSystem) Harness {
|
||||
t.Helper()
|
||||
return Harness{
|
||||
t: t,
|
||||
fSys: fSys,
|
||||
|
||||
@@ -47,6 +47,7 @@ type HarnessEnhanced struct {
|
||||
}
|
||||
|
||||
func MakeEnhancedHarness(t *testing.T) *HarnessEnhanced {
|
||||
t.Helper()
|
||||
r := makeBaseEnhancedHarness(t)
|
||||
r.Harness = MakeHarnessWithFs(t, filesys.MakeFsInMemory())
|
||||
// Point the Harness's file loader to the root ('/')
|
||||
@@ -56,6 +57,7 @@ func MakeEnhancedHarness(t *testing.T) *HarnessEnhanced {
|
||||
}
|
||||
|
||||
func MakeEnhancedHarnessWithTmpRoot(t *testing.T) *HarnessEnhanced {
|
||||
t.Helper()
|
||||
r := makeBaseEnhancedHarness(t)
|
||||
fSys := filesys.MakeFsOnDisk()
|
||||
r.Harness = MakeHarnessWithFs(t, fSys)
|
||||
@@ -72,6 +74,7 @@ func MakeEnhancedHarnessWithTmpRoot(t *testing.T) *HarnessEnhanced {
|
||||
}
|
||||
|
||||
func makeBaseEnhancedHarness(t *testing.T) *HarnessEnhanced {
|
||||
t.Helper()
|
||||
rf := resmap.NewFactory(
|
||||
provider.NewDefaultDepProvider().GetResourceFactory())
|
||||
return &HarnessEnhanced{
|
||||
|
||||
@@ -26,6 +26,7 @@ func AssertActualEqualsExpectedWithTweak(
|
||||
t *testing.T,
|
||||
m resmap.ResMap,
|
||||
tweaker func([]byte) []byte, expected string) {
|
||||
t.Helper()
|
||||
if m == nil {
|
||||
t.Fatalf("Map should not be nil.")
|
||||
}
|
||||
@@ -49,13 +50,14 @@ func AssertActualEqualsExpectedWithTweak(
|
||||
// Pretty printing of file differences.
|
||||
func reportDiffAndFail(
|
||||
t *testing.T, actual []byte, expected string) {
|
||||
t.Helper()
|
||||
sE, maxLen := convertToArray(expected)
|
||||
sA, _ := convertToArray(string(actual))
|
||||
fmt.Println("===== ACTUAL BEGIN ========================================")
|
||||
fmt.Print(string(actual))
|
||||
fmt.Println("===== ACTUAL END ==========================================")
|
||||
format := fmt.Sprintf("%%s %%-%ds %%s\n", maxLen+4)
|
||||
limit := 0
|
||||
var limit int
|
||||
if len(sE) < len(sA) {
|
||||
limit = len(sE)
|
||||
} else {
|
||||
|
||||
@@ -25,6 +25,7 @@ type pluginTestEnv struct {
|
||||
|
||||
// newPluginTestEnv returns a new instance of pluginTestEnv.
|
||||
func newPluginTestEnv(t *testing.T) *pluginTestEnv {
|
||||
t.Helper()
|
||||
return &pluginTestEnv{t: t}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,18 +20,22 @@ type rmBuilder struct {
|
||||
}
|
||||
|
||||
func NewSeededRmBuilder(t *testing.T, rf *resource.Factory, m resmap.ResMap) *rmBuilder {
|
||||
t.Helper()
|
||||
return &rmBuilder{t: t, rf: rf, m: m}
|
||||
}
|
||||
|
||||
func NewRmBuilder(t *testing.T, rf *resource.Factory) *rmBuilder {
|
||||
t.Helper()
|
||||
return NewSeededRmBuilder(t, rf, resmap.New())
|
||||
}
|
||||
|
||||
func NewRmBuilderDefault(t *testing.T) *rmBuilder {
|
||||
t.Helper()
|
||||
return NewSeededRmBuilderDefault(t, resmap.New())
|
||||
}
|
||||
|
||||
func NewSeededRmBuilderDefault(t *testing.T, m resmap.ResMap) *rmBuilder {
|
||||
t.Helper()
|
||||
return NewSeededRmBuilder(
|
||||
t, provider.NewDefaultDepProvider().GetResourceFactory(), m)
|
||||
}
|
||||
|
||||
@@ -22,11 +22,13 @@ const SAD = "i'm not happy Bob, NOT HAPPY"
|
||||
|
||||
// MakeHappyMapValidator makes a fakeValidator that always passes.
|
||||
func MakeHappyMapValidator(t *testing.T) *fakeValidator {
|
||||
t.Helper()
|
||||
return &fakeValidator{happy: true, t: t}
|
||||
}
|
||||
|
||||
// MakeSadMapValidator makes a fakeValidator that always fails.
|
||||
func MakeSadMapValidator(t *testing.T) *fakeValidator {
|
||||
t.Helper()
|
||||
return &fakeValidator{happy: false, t: t}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ type HelmChart struct {
|
||||
|
||||
// IncludeCRDs specifies if Helm should also generate CustomResourceDefinitions.
|
||||
// Defaults to 'false'.
|
||||
IncludeCRDs bool `json:"includeCRDs,omitempty" yaml:"includeCRDs,omitempty"`
|
||||
IncludeCRDs bool `json:"includeCRDs,omitempty" yaml:"includeCRDs,omitempty"` // nolint: tagliatelle
|
||||
}
|
||||
|
||||
// HelmChartArgs contains arguments to helm.
|
||||
|
||||
Reference in New Issue
Block a user