-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Processor: add_cloud_metadata] Use AWS client to get instance metada…
…ta and EKS cluster name (#35182) * add generic metadata fetcher Signed-off-by: Tetiana Kravchenko <[email protected]> * merge main Signed-off-by: Tetiana Kravchenko <[email protected]> * clean up Signed-off-by: Tetiana Kravchenko <[email protected]> * move tagDescribe to different func Signed-off-by: Tetiana Kravchenko <[email protected]> * add tests for add_cloud_metadata Signed-off-by: Tetiana Kravchenko <[email protected]> * Tiltfile: fix docker_registry, use more generic value Signed-off-by: Tetiana Kravchenko <[email protected]> * add notice file Signed-off-by: Tetiana Kravchenko <[email protected]> * fix tests - add former test cases; fix linter issues Signed-off-by: Tetiana Kravchenko <[email protected]> * handle correctly result.err Signed-off-by: Tetiana Kravchenko <[email protected]> * add generic metadata fetcher Signed-off-by: Tetiana Kravchenko <[email protected]> * merge main Signed-off-by: Tetiana Kravchenko <[email protected]> * clean up Signed-off-by: Tetiana Kravchenko <[email protected]> * move tagDescribe to different func Signed-off-by: Tetiana Kravchenko <[email protected]> * add tests for add_cloud_metadata Signed-off-by: Tetiana Kravchenko <[email protected]> * Tiltfile: fix docker_registry, use more generic value Signed-off-by: Tetiana Kravchenko <[email protected]> * add notice file Signed-off-by: Tetiana Kravchenko <[email protected]> * fix tests - add former test cases; fix linter issues Signed-off-by: Tetiana Kravchenko <[email protected]> * handle correctly result.err Signed-off-by: Tetiana Kravchenko <[email protected]> * address reviews Signed-off-by: Tetiana Kravchenko <[email protected]> * Update dev-tools/kubernetes/Tiltfile Co-authored-by: kaiyan-sheng <[email protected]> * fix the types.TagDescription struct Signed-off-by: Tetiana Kravchenko <[email protected]> * remove not used variable; fix types.TagDescription struct Signed-off-by: Tetiana Kravchenko <[email protected]> * add a changelog record Signed-off-by: Tetiana Kravchenko <[email protected]> * change Debugf to Warnf Signed-off-by: Tetiana Kravchenko <[email protected]> --------- Signed-off-by: Tetiana Kravchenko <[email protected]> Co-authored-by: kaiyan-sheng <[email protected]>
- Loading branch information
1 parent
d9d0db0
commit 6c7cfb4
Showing
8 changed files
with
593 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package add_cloud_metadata | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
cfg "github.com/elastic/elastic-agent-libs/config" | ||
"github.com/elastic/elastic-agent-libs/mapstr" | ||
) | ||
|
||
type genericFetcher struct { | ||
provider string | ||
schema schemaConv | ||
fetchRawProviderMetadata func(context.Context, http.Client, *result) | ||
} | ||
|
||
func newGenericMetadataFetcher( | ||
c *cfg.C, | ||
provider string, | ||
conv schemaConv, | ||
genericFetcherMeta func(context.Context, http.Client, *result), | ||
) (*genericFetcher, error) { | ||
|
||
gFetcher := &genericFetcher{provider, conv, genericFetcherMeta} | ||
return gFetcher, nil | ||
} | ||
|
||
func (g *genericFetcher) fetchMetadata(ctx context.Context, client http.Client) result { | ||
res := result{provider: g.provider, metadata: mapstr.M{}} | ||
g.fetchRawProviderMetadata(ctx, client, &res) | ||
if res.err != nil { | ||
return res | ||
} | ||
res.metadata = g.schema(res.metadata) | ||
_, _ = res.metadata.Put("cloud.provider", g.provider) | ||
|
||
return res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.