mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Address new linter complaints
This commit is contained in:
@@ -113,7 +113,6 @@ func debug(fMap filterMap) {
|
||||
// 'spec/scaleTargetRef/name' field. Return a filter that can do that.
|
||||
func (t *nameReferenceTransformer) determineFilters(
|
||||
resources []*resource.Resource) (fMap filterMap) {
|
||||
|
||||
// We cache the resource OrgId values because they don't change and otherwise are very visible in a memory pprof
|
||||
resourceOrgIds := make([]resid.ResId, len(resources))
|
||||
for i, resource := range resources {
|
||||
|
||||
@@ -107,7 +107,6 @@ func (ra *ResAccumulator) findVarValueFromResources(v types.Var) (interface{}, e
|
||||
for _, res := range ra.resMap.Resources() {
|
||||
for _, varName := range res.GetRefVarNames() {
|
||||
if varName == v.Name {
|
||||
//nolint: staticcheck
|
||||
s, err := res.GetFieldValue(v.FieldRef.FieldPath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf(
|
||||
|
||||
@@ -78,15 +78,15 @@ func (x *RepoSpec) Cleaner(fSys filesys.FileSystem) func() error {
|
||||
return func() error { return fSys.RemoveAll(x.Dir.String()) }
|
||||
}
|
||||
|
||||
// NewRepoSpecFromUrl parses git-like urls.
|
||||
// NewRepoSpecFromURL parses git-like urls.
|
||||
// From strings like git@github.com:someOrg/someRepo.git or
|
||||
// https://github.com/someOrg/someRepo?ref=someHash, extract
|
||||
// the parts.
|
||||
func NewRepoSpecFromUrl(n string) (*RepoSpec, error) {
|
||||
func NewRepoSpecFromURL(n string) (*RepoSpec, error) {
|
||||
if filepath.IsAbs(n) {
|
||||
return nil, fmt.Errorf("uri looks like abs path: %s", n)
|
||||
}
|
||||
host, orgRepo, path, gitRef, gitSubmodules, suffix, gitTimeout := parseGitUrl(n)
|
||||
host, orgRepo, path, gitRef, gitSubmodules, suffix, gitTimeout := parseGitURL(n)
|
||||
if orgRepo == "" {
|
||||
return nil, fmt.Errorf("url lacks orgRepo: %s", n)
|
||||
}
|
||||
@@ -108,9 +108,8 @@ const (
|
||||
// From strings like git@github.com:someOrg/someRepo.git or
|
||||
// https://github.com/someOrg/someRepo?ref=someHash, extract
|
||||
// the parts.
|
||||
func parseGitUrl(n string) (
|
||||
func parseGitURL(n string) (
|
||||
host string, orgRepo string, path string, gitRef string, gitSubmodules bool, gitSuff string, gitTimeout time.Duration) {
|
||||
|
||||
if strings.Contains(n, gitDelimiter) {
|
||||
index := strings.Index(n, gitDelimiter)
|
||||
// Adding _git/ to host
|
||||
@@ -229,7 +228,7 @@ func parseHostSpec(n string) (string, string) {
|
||||
if strings.HasSuffix(host, p) {
|
||||
i := strings.Index(n, "/")
|
||||
if i > -1 {
|
||||
host = host + n[0:i+1]
|
||||
host += n[0 : i+1]
|
||||
n = n[i+1:]
|
||||
}
|
||||
break
|
||||
|
||||
@@ -37,7 +37,7 @@ var hostNamesRawAndNormalized = [][]string{
|
||||
{"git@github.com/", "git@github.com:"},
|
||||
}
|
||||
|
||||
func makeUrl(hostFmt, orgRepo, path, href string) string {
|
||||
func makeURL(hostFmt, orgRepo, path, href string) string {
|
||||
if len(path) > 0 {
|
||||
orgRepo = filepath.Join(orgRepo, path)
|
||||
}
|
||||
@@ -56,8 +56,8 @@ func TestNewRepoSpecFromUrl(t *testing.T) {
|
||||
for _, orgRepo := range orgRepos {
|
||||
for _, pathName := range pathNames {
|
||||
for _, hrefArg := range hrefArgs {
|
||||
uri := makeUrl(hostRaw, orgRepo, pathName, hrefArg)
|
||||
rs, err := NewRepoSpecFromUrl(uri)
|
||||
uri := makeURL(hostRaw, orgRepo, pathName, hrefArg)
|
||||
rs, err := NewRepoSpecFromURL(uri)
|
||||
if err != nil {
|
||||
t.Errorf("problem %v", err)
|
||||
}
|
||||
@@ -99,7 +99,7 @@ var badData = [][]string{
|
||||
|
||||
func TestNewRepoSpecFromUrlErrors(t *testing.T) {
|
||||
for _, tuple := range badData {
|
||||
_, err := NewRepoSpecFromUrl(tuple[0])
|
||||
_, err := NewRepoSpecFromURL(tuple[0])
|
||||
if err == nil {
|
||||
t.Error("expected error")
|
||||
}
|
||||
@@ -191,7 +191,7 @@ func TestNewRepoSpecFromUrl_CloneSpecs(t *testing.T) {
|
||||
}
|
||||
for tn, tc := range testcases {
|
||||
t.Run(tn, func(t *testing.T) {
|
||||
rs, err := NewRepoSpecFromUrl(tc.input)
|
||||
rs, err := NewRepoSpecFromURL(tc.input)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tc.cloneSpec, rs.CloneSpec(), "cloneSpec mismatch")
|
||||
assert.Equal(t, tc.absPath, rs.AbsPath(), "absPath mismatch")
|
||||
|
||||
@@ -36,7 +36,7 @@ const (
|
||||
|
||||
var stringToBuiltinPluginTypeMap map[string]BuiltinPluginType
|
||||
|
||||
func init() {
|
||||
func init() { //nolint:gochecknoinits
|
||||
stringToBuiltinPluginTypeMap = makeStringToBuiltinPluginTypeMap()
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,6 @@ metadata:
|
||||
`
|
||||
if expected != string(p.Cfg()) {
|
||||
t.Fatalf("expected cfg '%s', got '%s'", expected, string(p.Cfg()))
|
||||
|
||||
}
|
||||
if len(p.Args()) != 6 {
|
||||
t.Fatalf("unexpected arg len %d, %#v", len(p.Args()), p.Args())
|
||||
|
||||
@@ -105,10 +105,10 @@ func TestUpdateResourceOptionsWithInvalidHashAnnotationValues(t *testing.T) {
|
||||
"TrUe",
|
||||
"potato",
|
||||
}
|
||||
for i, c := range cases {
|
||||
for i := range cases {
|
||||
name := fmt.Sprintf("test%d", i)
|
||||
in := resmap.New()
|
||||
err := in.Append(makeConfigMap(rf, name, "", &c))
|
||||
err := in.Append(makeConfigMap(rf, name, "", &cases[i]))
|
||||
require.NoError(t, err)
|
||||
_, err = UpdateResourceOptions(in)
|
||||
require.Error(t, err)
|
||||
|
||||
Reference in New Issue
Block a user