mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-23 07:17:02 +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
|
||||
}
|
||||
|
||||
@@ -31,10 +31,6 @@ func newCmdAddBase(fSys filesys.FileSystem) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = o.Complete(cmd, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunAddBase(fSys)
|
||||
},
|
||||
}
|
||||
@@ -50,11 +46,6 @@ func (o *addBaseOptions) Validate(args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Complete completes addBase command.
|
||||
func (o *addBaseOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunAddBase runs addBase command (do real work).
|
||||
func (o *addBaseOptions) RunAddBase(fSys filesys.FileSystem) error {
|
||||
mf, err := kustfile.NewKustomizationFile(fSys)
|
||||
|
||||
@@ -32,10 +32,6 @@ func newCmdAddPatch(fSys filesys.FileSystem) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = o.Complete(cmd, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunAddPatch(fSys)
|
||||
},
|
||||
}
|
||||
@@ -51,11 +47,6 @@ func (o *addPatchOptions) Validate(args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Complete completes addPatch command.
|
||||
func (o *addPatchOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunAddPatch runs addPatch command (do real work).
|
||||
func (o *addPatchOptions) RunAddPatch(fSys filesys.FileSystem) error {
|
||||
patches, err := util.GlobPatterns(fSys, o.patchFilePaths)
|
||||
|
||||
@@ -31,10 +31,6 @@ func newCmdAddResource(fSys filesys.FileSystem) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = o.Complete(cmd, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunAddResource(fSys)
|
||||
},
|
||||
}
|
||||
@@ -50,11 +46,6 @@ func (o *addResourceOptions) Validate(args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Complete completes addResource command.
|
||||
func (o *addResourceOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunAddResource runs addResource command (do real work).
|
||||
func (o *addResourceOptions) RunAddResource(fSys filesys.FileSystem) error {
|
||||
resources, err := util.GlobPatterns(fSys, o.resourceFilePaths)
|
||||
|
||||
@@ -34,10 +34,6 @@ func newCmdRemovePatch(fSys filesys.FileSystem) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = o.Complete(cmd, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunRemovePatch(fSys)
|
||||
},
|
||||
}
|
||||
@@ -53,11 +49,6 @@ func (o *removePatchOptions) Validate(args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Complete completes removePatch command.
|
||||
func (o *removePatchOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunRemovePatch runs removePatch command (do real work).
|
||||
func (o *removePatchOptions) RunRemovePatch(fSys filesys.FileSystem) error {
|
||||
patches, err := util.GlobPatterns(fSys, o.patchFilePaths)
|
||||
|
||||
@@ -35,10 +35,6 @@ func newCmdRemoveResource(fSys filesys.FileSystem) *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = o.Complete(cmd, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunRemoveResource(fSys)
|
||||
},
|
||||
}
|
||||
@@ -54,11 +50,6 @@ func (o *removeResourceOptions) Validate(args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Complete completes removeResource command.
|
||||
func (o *removeResourceOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunRemoveResource runs Resource command (do real work).
|
||||
func (o *removeResourceOptions) RunRemoveResource(fSys filesys.FileSystem) error {
|
||||
|
||||
|
||||
@@ -33,10 +33,6 @@ and overwrite the value with "acme-" if the field does exist.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = o.Complete(cmd, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunSetNamePrefix(fSys)
|
||||
},
|
||||
}
|
||||
@@ -53,11 +49,6 @@ func (o *setNamePrefixOptions) Validate(args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Complete completes setNamePrefix command.
|
||||
func (o *setNamePrefixOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunSetNamePrefix runs setNamePrefix command (does real work).
|
||||
func (o *setNamePrefixOptions) RunSetNamePrefix(fSys filesys.FileSystem) error {
|
||||
mf, err := kustfile.NewKustomizationFile(fSys)
|
||||
|
||||
@@ -33,10 +33,6 @@ and overwrite the value with "-acme" if the field does exist.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = o.Complete(cmd, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return o.RunSetNameSuffix(fSys)
|
||||
},
|
||||
}
|
||||
@@ -53,11 +49,6 @@ func (o *setNameSuffixOptions) Validate(args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Complete completes setNameSuffix command.
|
||||
func (o *setNameSuffixOptions) Complete(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunSetNameSuffix runs setNameSuffix command (does real work).
|
||||
func (o *setNameSuffixOptions) RunSetNameSuffix(fSys filesys.FileSystem) error {
|
||||
mf, err := kustfile.NewKustomizationFile(fSys)
|
||||
|
||||
@@ -21,9 +21,9 @@ func NewCmdVersion(w io.Writer) *cobra.Command {
|
||||
Example: `kustomize version`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if short {
|
||||
fmt.Println(provenance.GetProvenance().Short())
|
||||
fmt.Fprintln(w, provenance.GetProvenance().Short())
|
||||
} else {
|
||||
fmt.Println(provenance.GetProvenance().Full())
|
||||
fmt.Fprintln(w, provenance.GetProvenance().Full())
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ type plugin struct {
|
||||
var KustomizePlugin plugin
|
||||
|
||||
func (p *plugin) 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)
|
||||
|
||||
@@ -19,7 +19,7 @@ type plugin struct {
|
||||
var KustomizePlugin plugin
|
||||
|
||||
func (p *plugin) Config(
|
||||
h *resmap.PluginHelpers, config []byte) (err error) {
|
||||
h *resmap.PluginHelpers, _ []byte) (err error) {
|
||||
p.hasher = h.ResmapFactory().RF().Hasher()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ type plugin struct {
|
||||
var KustomizePlugin plugin
|
||||
|
||||
func (p *plugin) 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)
|
||||
|
||||
@@ -21,7 +21,7 @@ type plugin struct {
|
||||
var KustomizePlugin plugin
|
||||
|
||||
func (p *plugin) 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)
|
||||
|
||||
@@ -24,7 +24,7 @@ var KustomizePlugin plugin
|
||||
|
||||
// Nothing needed for configuration.
|
||||
func (p *plugin) Config(
|
||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||
_ *resmap.PluginHelpers, _ []byte) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ type plugin struct {
|
||||
var KustomizePlugin plugin
|
||||
|
||||
func (p *plugin) Config(
|
||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||
_ *resmap.PluginHelpers, c []byte) (err error) {
|
||||
p.Namespace = ""
|
||||
p.FieldSpecs = nil
|
||||
return yaml.Unmarshal(c, p)
|
||||
@@ -79,7 +79,7 @@ func (p *plugin) applicableFieldSpecs(id resid.ResId) []types.FieldSpec {
|
||||
}
|
||||
|
||||
func (p *plugin) 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:
|
||||
|
||||
@@ -37,7 +37,7 @@ var prefixSuffixFieldSpecsToSkip = []types.FieldSpec{
|
||||
}
|
||||
|
||||
func (p *plugin) Config(
|
||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||
_ *resmap.PluginHelpers, c []byte) (err error) {
|
||||
p.Prefix = ""
|
||||
p.Suffix = ""
|
||||
p.FieldSpecs = nil
|
||||
|
||||
@@ -26,8 +26,7 @@ type plugin struct {
|
||||
var KustomizePlugin plugin
|
||||
|
||||
func (p *plugin) 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)
|
||||
|
||||
Reference in New Issue
Block a user