Skip to content

Commit

Permalink
Rename dumpInstalledObject to be more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodm committed Jun 23, 2022
1 parent 80a61b0 commit 898f15f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions internal/dump/agentpolicies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
10 changes: 5 additions & 5 deletions internal/dump/installedobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 898f15f

Please sign in to comment.