-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
724 bi collection improvments (#770)
* bi collect aws account id * wip * bi collect account id - cont * revert adapter changes; fix tests * Create cloud package * wip * Add MetadataProvider to cloud package * CR fixes * CR fix: remove unneeded alias * CR fixes: account id hashing, split metadata fields * rename constants * fix import cycle and lint errors
- Loading branch information
Showing
23 changed files
with
274 additions
and
161 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
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
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,41 @@ | ||
package aws | ||
|
||
import ( | ||
"crypto/md5" //nolint:gosec | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/s3" | ||
"github.com/aws/aws-sdk-go/service/sts" | ||
"github.com/treeverse/lakefs/cloud" | ||
"github.com/treeverse/lakefs/logging" | ||
) | ||
|
||
type MetadataProvider struct { | ||
logger logging.Logger | ||
awsConfig *aws.Config | ||
} | ||
|
||
func NewMetadataProvider(logger logging.Logger, awsConfig *aws.Config) *MetadataProvider { | ||
return &MetadataProvider{logger: logger, awsConfig: awsConfig} | ||
} | ||
|
||
func (m *MetadataProvider) GetMetadata() map[string]string { | ||
sess, err := session.NewSession(m.awsConfig) | ||
if err != nil { | ||
m.logger.Warnf("%v: failed to create AWS session for BI", err) | ||
return nil | ||
} | ||
sess.ClientConfig(s3.ServiceName) | ||
stsClient := sts.New(sess) | ||
identity, err := stsClient.GetCallerIdentity(&sts.GetCallerIdentityInput{}) | ||
if err != nil { | ||
m.logger.Warnf("%v: failed to get AWS account ID for BI", err) | ||
return nil | ||
} | ||
return map[string]string{ | ||
cloud.IDKey: fmt.Sprintf("%x", md5.Sum([]byte(*identity.Account))), //nolint:gosec | ||
cloud.IDTypeKey: "aws_account_id", | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
inventory/s3/orc_reader.go → cloud/aws/s3inventory/orc_reader.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package s3 | ||
package s3inventory | ||
|
||
import ( | ||
"context" | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package s3 | ||
package s3inventory | ||
|
||
import ( | ||
"context" | ||
|
2 changes: 1 addition & 1 deletion
2
inventory/s3/parquet_reader.go → cloud/aws/s3inventory/parquet_reader.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package s3 | ||
package s3inventory | ||
|
||
import "github.com/xitongsys/parquet-go/reader" | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package s3 | ||
package s3inventory | ||
|
||
import ( | ||
"context" | ||
|
Oops, something went wrong.