mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 16:42:51 +00:00
Fix some nits in the crawler and elsewhere.
This commit is contained in:
@@ -17,7 +17,7 @@ type AnnotationsTransformerPlugin struct {
|
||||
}
|
||||
|
||||
func (p *AnnotationsTransformerPlugin) Config(
|
||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||
_ *resmap.PluginHelpers, c []byte) (err error) {
|
||||
p.Annotations = nil
|
||||
p.FieldSpecs = nil
|
||||
return yaml.Unmarshal(c, p)
|
||||
|
||||
@@ -15,7 +15,7 @@ type HashTransformerPlugin struct {
|
||||
}
|
||||
|
||||
func (p *HashTransformerPlugin) Config(
|
||||
h *resmap.PluginHelpers, config []byte) (err error) {
|
||||
h *resmap.PluginHelpers, _ []byte) (err error) {
|
||||
p.hasher = h.ResmapFactory().RF().Hasher()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ type ImageTagTransformerPlugin struct {
|
||||
}
|
||||
|
||||
func (p *ImageTagTransformerPlugin) Config(
|
||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||
_ *resmap.PluginHelpers, c []byte) (err error) {
|
||||
p.ImageTag = types.Image{}
|
||||
p.FieldSpecs = nil
|
||||
return yaml.Unmarshal(c, p)
|
||||
|
||||
@@ -17,7 +17,7 @@ type LabelTransformerPlugin struct {
|
||||
}
|
||||
|
||||
func (p *LabelTransformerPlugin) Config(
|
||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||
_ *resmap.PluginHelpers, c []byte) (err error) {
|
||||
p.Labels = nil
|
||||
p.FieldSpecs = nil
|
||||
return yaml.Unmarshal(c, p)
|
||||
|
||||
@@ -20,7 +20,7 @@ type LegacyOrderTransformerPlugin struct{}
|
||||
|
||||
// Nothing needed for configuration.
|
||||
func (p *LegacyOrderTransformerPlugin) Config(
|
||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||
_ *resmap.PluginHelpers, _ []byte) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ type NamespaceTransformerPlugin struct {
|
||||
}
|
||||
|
||||
func (p *NamespaceTransformerPlugin) Config(
|
||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||
_ *resmap.PluginHelpers, c []byte) (err error) {
|
||||
p.Namespace = ""
|
||||
p.FieldSpecs = nil
|
||||
return yaml.Unmarshal(c, p)
|
||||
@@ -75,7 +75,7 @@ func (p *NamespaceTransformerPlugin) applicableFieldSpecs(id resid.ResId) []type
|
||||
}
|
||||
|
||||
func (p *NamespaceTransformerPlugin) changeNamespace(
|
||||
referrer *resource.Resource) func(in interface{}) (interface{}, error) {
|
||||
_ *resource.Resource) func(in interface{}) (interface{}, error) {
|
||||
return func(in interface{}) (interface{}, error) {
|
||||
switch in.(type) {
|
||||
case string:
|
||||
|
||||
@@ -33,7 +33,7 @@ var prefixSuffixFieldSpecsToSkip = []types.FieldSpec{
|
||||
}
|
||||
|
||||
func (p *PrefixSuffixTransformerPlugin) Config(
|
||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||
_ *resmap.PluginHelpers, c []byte) (err error) {
|
||||
p.Prefix = ""
|
||||
p.Suffix = ""
|
||||
p.FieldSpecs = nil
|
||||
|
||||
@@ -22,8 +22,7 @@ type ReplicaCountTransformerPlugin struct {
|
||||
}
|
||||
|
||||
func (p *ReplicaCountTransformerPlugin) Config(
|
||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||
|
||||
_ *resmap.PluginHelpers, c []byte) (err error) {
|
||||
p.Replica = types.Replica{}
|
||||
p.FieldSpecs = nil
|
||||
return yaml.Unmarshal(c, p)
|
||||
|
||||
@@ -92,7 +92,7 @@ func main() {
|
||||
_, err := idx.Put("", d)
|
||||
return err
|
||||
default:
|
||||
return fmt.Errorf("Type %T not supported", d)
|
||||
return fmt.Errorf("type %T not supported", d)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
"sigs.k8s.io/kustomize/api/internal/crawl/doc"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -32,7 +32,7 @@ func (c testCrawler) Match(d *doc.Document) bool {
|
||||
return d != nil && strings.HasPrefix(d.ID(), c.matchPrefix)
|
||||
}
|
||||
|
||||
func (c testCrawler) FetchDocument(ctx context.Context, d *doc.Document) error {
|
||||
func (c testCrawler) FetchDocument(_ context.Context, d *doc.Document) error {
|
||||
if i, ok := c.lukp[d.ID()]; ok {
|
||||
d.DocumentData = c.docs[i].DocumentData
|
||||
return nil
|
||||
@@ -51,7 +51,7 @@ func (c testCrawler) FetchDocument(ctx context.Context, d *doc.Document) error {
|
||||
d, c.matchPrefix)
|
||||
}
|
||||
|
||||
func (c testCrawler) SetCreated(ctx context.Context, d *doc.Document) error {
|
||||
func (c testCrawler) SetCreated(_ context.Context, d *doc.Document) error {
|
||||
d.CreationTime = &time.Time{}
|
||||
return nil
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func newCrawler(matchPrefix string, err error,
|
||||
}
|
||||
|
||||
// Crawl implements the Crawler interface for testing.
|
||||
func (c testCrawler) Crawl(ctx context.Context,
|
||||
func (c testCrawler) Crawl(_ context.Context,
|
||||
output chan<- CrawledDocument) error {
|
||||
|
||||
for i, d := range c.docs {
|
||||
|
||||
@@ -93,7 +93,7 @@ func (gc githubCrawler) Crawl(
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gc githubCrawler) FetchDocument(ctx context.Context, d *doc.Document) error {
|
||||
func (gc githubCrawler) FetchDocument(_ context.Context, d *doc.Document) error {
|
||||
repoURL := d.RepositoryURL + "/" + d.FilePath + "?ref=" + d.DefaultBranch
|
||||
repoSpec, err := git.NewRepoSpecFromUrl(repoURL)
|
||||
if err != nil {
|
||||
@@ -132,7 +132,7 @@ func (gc githubCrawler) FetchDocument(ctx context.Context, d *doc.Document) erro
|
||||
return fmt.Errorf("file not found: %s, error: %v", url, err)
|
||||
}
|
||||
|
||||
func (gc githubCrawler) SetCreated(ctx context.Context, d *doc.Document) error {
|
||||
func (gc githubCrawler) SetCreated(_ context.Context, d *doc.Document) error {
|
||||
fs := GhFileSpec{}
|
||||
fs.Repository.FullName = d.RepositoryURL + "/" + d.FilePath
|
||||
creationTime, err := gc.client.GetFileCreationTime(fs)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
const (
|
||||
perPageArg = "per_page"
|
||||
accessTokenArg = "access_token"
|
||||
)
|
||||
|
||||
const githubMaxPageSize = 100
|
||||
@@ -101,12 +100,6 @@ type RequestConfig struct {
|
||||
perPage uint64
|
||||
}
|
||||
|
||||
func NewRequestConfig(perPage uint64) RequestConfig {
|
||||
return RequestConfig{
|
||||
perPage: perPage,
|
||||
}
|
||||
}
|
||||
|
||||
// CodeSearchRequestWith given a list of query parameters that specify the
|
||||
// (patial) query, returns a request object with the (parital) query. Must call
|
||||
// the URL method to get the string value of the URL. See request.CopyWith, to
|
||||
|
||||
@@ -68,7 +68,6 @@ func TestQueryType(t *testing.T) {
|
||||
|
||||
func TestGithubSearchQuery(t *testing.T) {
|
||||
const (
|
||||
accessToken = "random_token"
|
||||
perPage = 100
|
||||
)
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ func (th Harness) MakeOptionsPluginsEnabled() krusty.Options {
|
||||
if strings.Contains(err.Error(), "unable to find plugin root") {
|
||||
th.t.Log(
|
||||
"Tests that want to run with plugins enabled must be " +
|
||||
"bookended by calls to MakeEnhancedHarness(), Reset().")
|
||||
"bookended by calls to MakeEnhancedHarness(), Reset().")
|
||||
}
|
||||
th.t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ package resmaptest_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
"sigs.k8s.io/kustomize/api/resource"
|
||||
)
|
||||
@@ -38,14 +37,6 @@ func (rm *rmBuilder) AddR(r *resource.Resource) *rmBuilder {
|
||||
return rm
|
||||
}
|
||||
|
||||
func (rm *rmBuilder) AddWithId(id resid.ResId, m map[string]interface{}) *rmBuilder {
|
||||
err := rm.m.Append(rm.rf.FromMap(m))
|
||||
if err != nil {
|
||||
rm.t.Fatalf("test setup failure: %v", err)
|
||||
}
|
||||
return rm
|
||||
}
|
||||
|
||||
func (rm *rmBuilder) AddWithName(n string, m map[string]interface{}) *rmBuilder {
|
||||
err := rm.m.Append(rm.rf.FromMapWithName(n, m))
|
||||
if err != nil {
|
||||
|
||||
@@ -36,12 +36,12 @@ func MakeFakeValidator() *fakeValidator {
|
||||
}
|
||||
|
||||
// ErrIfInvalidKey returns nil
|
||||
func (v *fakeValidator) ErrIfInvalidKey(k string) error {
|
||||
func (v *fakeValidator) ErrIfInvalidKey(_ string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsEnvVarName returns nil
|
||||
func (v *fakeValidator) IsEnvVarName(k string) error {
|
||||
func (v *fakeValidator) IsEnvVarName(_ string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ var errExpected = fmt.Errorf("oops")
|
||||
const originalValue = "tomato"
|
||||
const newValue = "notThe" + originalValue
|
||||
|
||||
func (m *noopMutator) mutate(in interface{}) (interface{}, error) {
|
||||
func (m *noopMutator) mutate(_ interface{}) (interface{}, error) {
|
||||
m.wasCalled = true
|
||||
return newValue, m.errorToReturn
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user