Skip to content

Commit

Permalink
Add fmt.Errorf in error returns
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKatsoulis committed Mar 6, 2024
1 parent d57fa5f commit 757fc01
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libbeat/processors/add_cloud_metadata/provider_azure_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,25 @@ var azureVMMetadataFetcher = provider{
// hfetcher represents an http fetcher to retrieve metadata from azure metadata endpoint
hfetcher, err := newMetadataFetcher(config, "azure", azHeaders, metadataHost, azHttpSchema, azMetadataURI)
if err != nil {
return hfetcher, err
return hfetcher, fmt.Errorf("failed to create new http metadata fetcher: %w", err)
}
// fetcher represents an azure metadata fetcher. The struct includes two type of fetchers.
// 1. An http fetcher(hfetcher) which retrieves metadata from azure metadata endpoint and
// 2. A generic fetcher(gfetcher) which uses azure sdk to retrieve metadata of azure managed clusters.
fetcher, err := newAzureMetadataFetcher("azure", hfetcher)
if err != nil {
return fetcher, err
return fetcher, fmt.Errorf("failed to create new azure metadata fetcher: %w", err)
}
// gfetcher is created and assinged to fetcher after the fetcher is created in order the
// fetchAzureClusterMeta to be a method of fetcher. This is needed so that the generic fetcher
// can use the results/metadata that are already retrieved from http fetcher. SubscriptionId and
// resourceGroupName are then used to filter azure managed clusters results.
gfetcher, err := newGenericMetadataFetcher(config, "azure", azGenSchema, fetcher.fetchAzureClusterMeta)
if err != nil {
return fetcher, err
return fetcher, fmt.Errorf("failed to create new generic metadata fetcher: %w", err)
}
fetcher.genericMetadataFetcher = gfetcher
return fetcher, err
return fetcher, nil
},
}

Expand Down

0 comments on commit 757fc01

Please sign in to comment.