Skip to content

Commit

Permalink
make resources var consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
RamanaReddy0M committed Aug 22, 2024
1 parent c58b531 commit 5de0137
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions pkg/providers/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func worker(ctx context.Context, fn getResourcesFunc, ch chan<- result) {
}

func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {
finalList := schema.NewResources()
finalResources := schema.NewResources()

var workersWaitGroup sync.WaitGroup
results := make(chan result)
Expand Down Expand Up @@ -262,7 +262,7 @@ func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {
if result.err != nil {
continue
}
finalList.Merge(result.resources)
finalResources.Merge(result.resources)
}
return finalList, nil
return finalResources, nil
}
6 changes: 3 additions & 3 deletions pkg/providers/consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ const (

// Resources returns the provider for an resource deployment source.
func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {
finalList := schema.NewResources()
finalResources := schema.NewResources()
provider := &resourceProvider{client: p.client, id: p.id}
if resources, err := provider.GetResource(ctx); err == nil {
finalList.Merge(resources)
finalResources.Merge(resources)
}
return finalList, nil
return finalResources, nil
}
8 changes: 4 additions & 4 deletions pkg/providers/digitalocean/digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ const apiKey = "digitalocean_token"

// Resources returns the provider for an resource deployment source.
func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {
finalList := schema.NewResources()
finalResources := schema.NewResources()

if p.services.Has("droplet") || p.services.Has("instance") {
instanceprovider := &instanceProvider{client: p.client, id: p.id}
instances, err := instanceprovider.GetResource(ctx)
if err != nil {
return nil, err
}
finalList.Merge(instances)
finalResources.Merge(instances)
}

if p.services.Has("app") {
Expand All @@ -83,8 +83,8 @@ func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {
if err != nil {
return nil, err
}
finalList.Merge(apps)
finalResources.Merge(apps)
}

return finalList, nil
return finalResources, nil
}
16 changes: 8 additions & 8 deletions pkg/providers/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ func New(options schema.OptionBlock) (*Provider, error) {

// Resources returns the provider for an resource deployment source.
func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {
finalList := schema.NewResources()
finalResources := schema.NewResources()

if p.dns != nil {
cloudDNSProvider := &cloudDNSProvider{dns: p.dns, id: p.id, projects: p.projects}
zones, err := cloudDNSProvider.GetResource(ctx)
if err != nil {
return nil, err
}
finalList.Merge(zones)
finalResources.Merge(zones)
}

if p.gke != nil {
Expand All @@ -162,7 +162,7 @@ func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {
if err != nil {
gologger.Warning().Msgf("Could not get GKE resources: %s\n", err)
}
finalList.Merge(gkeData)
finalResources.Merge(gkeData)
}

if p.compute != nil {
Expand All @@ -171,7 +171,7 @@ func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {
if err != nil {
return nil, err
}
finalList.Merge(vmData)
finalResources.Merge(vmData)
}

if p.storage != nil {
Expand All @@ -180,7 +180,7 @@ func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {
if err != nil {
return nil, err
}
finalList.Merge(storageData)
finalResources.Merge(storageData)
}

if p.functions != nil {
Expand All @@ -189,7 +189,7 @@ func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {
if err != nil {
return nil, err
}
finalList.Merge(functionsData)
finalResources.Merge(functionsData)
}

if p.run != nil {
Expand All @@ -198,8 +198,8 @@ func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {
if err != nil {
return nil, err
}
finalList.Merge(cloudRunData)
finalResources.Merge(cloudRunData)
}

return finalList, nil
return finalResources, nil
}

0 comments on commit 5de0137

Please sign in to comment.