From 898f15f22a9f7afe249be7a96fa4cfbeba4dffc0 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Date: Thu, 23 Jun 2022 18:01:18 +0200 Subject: [PATCH] Rename dumpInstalledObject to be more generic --- internal/dump/agentpolicies.go | 6 +++--- internal/dump/installedobjects.go | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/dump/agentpolicies.go b/internal/dump/agentpolicies.go index 7646dba1f..b789c8932 100644 --- a/internal/dump/agentpolicies.go +++ b/internal/dump/agentpolicies.go @@ -61,7 +61,7 @@ func (d *AgentPoliciesDumper) DumpByName(ctx context.Context, dir, name string) } dir = filepath.Join(dir, AgentPoliciesDumpDir) - err = dumpInstalledObject(dir, agentPolicy) + err = dumpJSONResource(dir, agentPolicy) if err != nil { return fmt.Errorf("failed to dump agent policy %s: %w", agentPolicy.Name(), err) } @@ -149,7 +149,7 @@ func (d *AgentPoliciesDumper) DumpAll(ctx context.Context, dir string) (count in dir = filepath.Join(dir, AgentPoliciesDumpDir) for _, agentPolicy := range agentPolicies { - err := dumpInstalledObject(dir, agentPolicy) + err := dumpJSONResource(dir, agentPolicy) if err != nil { return 0, fmt.Errorf("failed to dump agent policy %s: %w", agentPolicy.Name(), err) } @@ -166,7 +166,7 @@ func (d *AgentPoliciesDumper) DumpByPackage(ctx context.Context, dir, packageNam dir = filepath.Join(dir, AgentPoliciesDumpDir) for _, agentPolicy := range agentPolicies { - err := dumpInstalledObject(dir, agentPolicy) + err := dumpJSONResource(dir, agentPolicy) if err != nil { return 0, fmt.Errorf("failed to dump agent policy %s: %w", agentPolicy.Name(), err) } diff --git a/internal/dump/installedobjects.go b/internal/dump/installedobjects.go index c3f099410..f2de84001 100644 --- a/internal/dump/installedobjects.go +++ b/internal/dump/installedobjects.go @@ -77,7 +77,7 @@ type DumpableInstalledObject interface { JSON() []byte } -func dumpInstalledObject(dir string, object DumpableInstalledObject) error { +func dumpJSONResource(dir string, object DumpableInstalledObject) error { if err := os.MkdirAll(dir, 0755); err != nil { return fmt.Errorf("failed to create dump directory: %w", err) } @@ -110,7 +110,7 @@ func (e *InstalledObjectsDumper) dumpIndexTemplates(ctx context.Context, dir str dir = filepath.Join(dir, IndexTemplatesDumpDir) for i, t := range indexTemplates { - err := dumpInstalledObject(dir, t) + err := dumpJSONResource(dir, t) if err != nil { return i, fmt.Errorf("failed to dump index template %s: %w", t.Name(), err) } @@ -138,7 +138,7 @@ func (e *InstalledObjectsDumper) dumpComponentTemplates(ctx context.Context, dir dir = filepath.Join(dir, ComponentTemplatesDumpDir) for i, t := range componentTemplates { - err := dumpInstalledObject(dir, t) + err := dumpJSONResource(dir, t) if err != nil { return i, fmt.Errorf("failed to dump component template %s: %w", t.Name(), err) } @@ -187,7 +187,7 @@ func (e *InstalledObjectsDumper) dumpILMPolicies(ctx context.Context, dir string dir = filepath.Join(dir, ILMPoliciesDumpDir) for i, t := range ilmPolicies { - err := dumpInstalledObject(dir, t) + err := dumpJSONResource(dir, t) if err != nil { return i, fmt.Errorf("failed to dump ILM policy %s: %w", t.Name(), err) } @@ -231,7 +231,7 @@ func (e *InstalledObjectsDumper) dumpIngestPipelines(ctx context.Context, dir st dir = filepath.Join(dir, IngestPipelinesDumpDir) for i, t := range ingestPipelines { - err := dumpInstalledObject(dir, t) + err := dumpJSONResource(dir, t) if err != nil { return i, fmt.Errorf("failed to dump ingest pipeline %s: %w", t.Name(), err) }