Skip to content

Commit

Permalink
Unexport unnecessary structs
Browse files Browse the repository at this point in the history
  • Loading branch information
romulets committed Mar 22, 2024
1 parent 517c3df commit 8163db6
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion internal/inventory/awsfetcher/awsfetchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func New(logger *logp.Logger, identity *cloud.Identity, cfg aws.Config) []invent

return []inventory.AssetFetcher{
newEc2InstancesFetcher(logger, identity, ec2Provider),
NewS3BucketFetcher(logger, identity, s3Provider),
newS3BucketFetcher(logger, identity, s3Provider),
newIamUserFetcher(logger, identity, iamProvider),
newIamRoleFetcher(logger, identity, iamProvider),
newIamPolicyFetcher(logger, identity, iamProvider),
Expand Down
10 changes: 5 additions & 5 deletions internal/inventory/awsfetcher/fetcher_ec2_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
)

type Ec2InstanceFetcher struct {
type ec2InstanceFetcher struct {
logger *logp.Logger
provider ec2InstancesProvider
AccountId string
Expand All @@ -47,15 +47,15 @@ var ec2InstanceClassification = inventory.AssetClassification{
}

func newEc2InstancesFetcher(logger *logp.Logger, identity *cloud.Identity, provider ec2InstancesProvider) inventory.AssetFetcher {
return &Ec2InstanceFetcher{
return &ec2InstanceFetcher{
logger: logger,
provider: provider,
AccountId: identity.Account,
AccountName: identity.AccountAlias,
}
}

func (e *Ec2InstanceFetcher) Fetch(ctx context.Context, assetChannel chan<- inventory.AssetEvent) {
func (e *ec2InstanceFetcher) Fetch(ctx context.Context, assetChannel chan<- inventory.AssetEvent) {
e.logger.Info("Fetching EC2 Instances")
defer e.logger.Info("Fetching EC2 Instances - Finished")

Expand Down Expand Up @@ -125,7 +125,7 @@ func (e *Ec2InstanceFetcher) Fetch(ctx context.Context, assetChannel chan<- inve
}
}

func (e *Ec2InstanceFetcher) getTags(instance *ec2.Ec2Instance) map[string]string {
func (e *ec2InstanceFetcher) getTags(instance *ec2.Ec2Instance) map[string]string {
tags := make(map[string]string, len(instance.Tags))
for _, t := range instance.Tags {
if t.Key == nil {
Expand All @@ -137,7 +137,7 @@ func (e *Ec2InstanceFetcher) getTags(instance *ec2.Ec2Instance) map[string]strin
return tags
}

func (e *Ec2InstanceFetcher) getAvailabilityZone(instance *ec2.Ec2Instance) *string {
func (e *ec2InstanceFetcher) getAvailabilityZone(instance *ec2.Ec2Instance) *string {
if instance.Placement == nil {
return nil
}
Expand Down
14 changes: 7 additions & 7 deletions internal/inventory/awsfetcher/fetcher_iam_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import (
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
)

type IamPolicyFetcher struct {
type iamPolicyFetcher struct {
logger *logp.Logger
provider IamPolicyProvider
provider iamPolicyProvider
AccountId string
AccountName string
}

type IamPolicyProvider interface {
type iamPolicyProvider interface {
GetPolicies(ctx context.Context) ([]awslib.AwsResource, error)
}

Expand All @@ -47,16 +47,16 @@ var iamPolicyClassification = inventory.AssetClassification{
SubType: inventory.SubTypeIAM,
}

func newIamPolicyFetcher(logger *logp.Logger, identity *cloud.Identity, provider IamPolicyProvider) inventory.AssetFetcher {
return &IamPolicyFetcher{
func newIamPolicyFetcher(logger *logp.Logger, identity *cloud.Identity, provider iamPolicyProvider) inventory.AssetFetcher {
return &iamPolicyFetcher{
logger: logger,
provider: provider,
AccountId: identity.Account,
AccountName: identity.AccountAlias,
}
}

func (i *IamPolicyFetcher) Fetch(ctx context.Context, assetChannel chan<- inventory.AssetEvent) {
func (i *iamPolicyFetcher) Fetch(ctx context.Context, assetChannel chan<- inventory.AssetEvent) {
i.logger.Info("Fetching IAM Policies")
defer i.logger.Info("Fetching IAM Policies - Finished")

Expand Down Expand Up @@ -102,7 +102,7 @@ func (i *IamPolicyFetcher) Fetch(ctx context.Context, assetChannel chan<- invent
}
}

func (i *IamPolicyFetcher) getTags(policy iam.Policy) map[string]string {
func (i *iamPolicyFetcher) getTags(policy iam.Policy) map[string]string {
tags := make(map[string]string, len(policy.Tags))

for _, tag := range policy.Tags {
Expand Down
12 changes: 6 additions & 6 deletions internal/inventory/awsfetcher/fetcher_iam_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import (
"github.com/elastic/cloudbeat/internal/resources/utils/pointers"
)

type IamRoleFetcher struct {
type iamRoleFetcher struct {
logger *logp.Logger
provider IamRoleProvider
provider iamRoleProvider
AccountId string
AccountName string
}

type IamRoleProvider interface {
type iamRoleProvider interface {
ListRoles(ctx context.Context) ([]*iam.Role, error)
}

Expand All @@ -47,16 +47,16 @@ var iamRoleClassification = inventory.AssetClassification{
SubType: inventory.SubTypeIAM,
}

func newIamRoleFetcher(logger *logp.Logger, identity *cloud.Identity, provider IamRoleProvider) inventory.AssetFetcher {
return &IamRoleFetcher{
func newIamRoleFetcher(logger *logp.Logger, identity *cloud.Identity, provider iamRoleProvider) inventory.AssetFetcher {
return &iamRoleFetcher{
logger: logger,
provider: provider,
AccountId: identity.Account,
AccountName: identity.AccountAlias,
}
}

func (i *IamRoleFetcher) Fetch(ctx context.Context, assetChannel chan<- inventory.AssetEvent) {
func (i *iamRoleFetcher) Fetch(ctx context.Context, assetChannel chan<- inventory.AssetEvent) {
i.logger.Info("Fetching IAM Roles")
defer i.logger.Info("Fetching IAM Roles - Finished")

Expand Down
12 changes: 6 additions & 6 deletions internal/inventory/awsfetcher/fetcher_iam_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ import (
"github.com/elastic/cloudbeat/internal/resources/providers/awslib/iam"
)

type IamUserFetcher struct {
type iamUserFetcher struct {
logger *logp.Logger
provider IamUserProvider
provider iamUserProvider
AccountId string
AccountName string
}

type IamUserProvider interface {
type iamUserProvider interface {
GetUsers(ctx context.Context) ([]awslib.AwsResource, error)
}

Expand All @@ -46,16 +46,16 @@ var iamUserClassification = inventory.AssetClassification{
SubType: inventory.SubTypeIAM,
}

func newIamUserFetcher(logger *logp.Logger, identity *cloud.Identity, provider IamUserProvider) inventory.AssetFetcher {
return &IamUserFetcher{
func newIamUserFetcher(logger *logp.Logger, identity *cloud.Identity, provider iamUserProvider) inventory.AssetFetcher {
return &iamUserFetcher{
logger: logger,
provider: provider,
AccountId: identity.Account,
AccountName: identity.AccountAlias,
}
}

func (i *IamUserFetcher) Fetch(ctx context.Context, assetChannel chan<- inventory.AssetEvent) {
func (i *iamUserFetcher) Fetch(ctx context.Context, assetChannel chan<- inventory.AssetEvent) {
i.logger.Info("Fetching IAM Users")
defer i.logger.Info("Fetching IAM Users - Finished")

Expand Down
8 changes: 4 additions & 4 deletions internal/inventory/awsfetcher/fetcher_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/elastic/cloudbeat/internal/resources/providers/awslib/s3"
)

type S3BucketFetcher struct {
type s3BucketFetcher struct {
logger *logp.Logger
provider s3BucketProvider
AccountId string
Expand All @@ -47,16 +47,16 @@ type s3BucketProvider interface {
DescribeBuckets(ctx context.Context) ([]awslib.AwsResource, error)
}

func NewS3BucketFetcher(logger *logp.Logger, identity *cloud.Identity, provider s3BucketProvider) inventory.AssetFetcher {
return &S3BucketFetcher{
func newS3BucketFetcher(logger *logp.Logger, identity *cloud.Identity, provider s3BucketProvider) inventory.AssetFetcher {
return &s3BucketFetcher{
logger: logger,
provider: provider,
AccountId: identity.Account,
AccountName: identity.AccountAlias,
}
}

func (s *S3BucketFetcher) Fetch(ctx context.Context, assetChannel chan<- inventory.AssetEvent) {
func (s *s3BucketFetcher) Fetch(ctx context.Context, assetChannel chan<- inventory.AssetEvent) {
s.logger.Info("Fetching S3 Bucket")
defer s.logger.Info("Fetching S3 Bucket - Finished")

Expand Down
2 changes: 1 addition & 1 deletion internal/inventory/awsfetcher/fetcher_s3_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func TestS3BucketFetcher_Fetch(t *testing.T) {
provider.EXPECT().DescribeBuckets(mock.Anything).Return(in, nil)

identity := &cloud.Identity{Account: "123", AccountAlias: "alias"}
fetcher := NewS3BucketFetcher(logger, identity, provider)
fetcher := newS3BucketFetcher(logger, identity, provider)

collectResourcesAndMatch(t, fetcher, expected)
}

0 comments on commit 8163db6

Please sign in to comment.