Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat cloud cost credentials data - 218 #317

Merged
merged 16 commits into from
Apr 17, 2022
Merged

Conversation

samuel-br
Copy link
Contributor

Issue & Steps to Reproduce / Feature Request

#218

Solution

  • add data resource for each cloud cost credentials
  • add UT for each cloud cost credentials

**part of solution for #218, along with #252 **

@samuel-br samuel-br self-assigned this Apr 3, 2022
@samuel-br samuel-br added this to In progress in Ongoing Issues via automation Apr 3, 2022
@eranelbaz eranelbaz requested a review from a team April 4, 2022 08:05
Copy link
Contributor

@yaronya yaronya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good overall
Left a few comments

Comment on lines 53 to 54
d.SetId(credentials.Id)
d.Set("name", credentials.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the new common writeResourceData instead. Have a look at existing usages of it to get the idea.

Note: this comment is relevant to all other resources

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point ill do it, just a little note, the function you mention based on the name of the field in schema against the field name in the struct , in aws creds we have 'arn' in schema but the struct field is 'RoleArn so in some places like that we cant use those functions, or we can just change the name of the field in struct/schema

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how did you solve that arn -> RoleArn tranform?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this specific code there is no arn attribute so I do used the function you suggested , but in resource(no data resource) for example I cant use it, another problem in this function is when the value of the filed in the struct is struct itself like value in awscredentialscreate but for this I have a solution, anyway its not enough because the problem we talked above, unless we change the schema field name to role_arn

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok understood.
Regarding your last sentence - I do think we should change it to role_arn so:

  1. api and schema are aligned
  2. We can use this util

env0/data_aws_cost_credentials.go Outdated Show resolved Hide resolved
}

if len(credentialsByNameAndType) > 1 {
return client.Credentials{}, diag.Errorf("Found multiple Google cost Credentials for name: %s", name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please align this error message with all other error messages in this file...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

samuel-br and others added 4 commits April 4, 2022 23:00
Copy link
Member

@eranelbaz eranelbaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why for data we have 3 different functions for that?
the only difference is the credentials.Type
please DRY that

@eranelbaz
Copy link
Member

@samuel-br let's put this PR on hold until we finish with #307 as I see similar typos here and there

Also, did you see

Why for data we have 3 different functions for that?
the only difference is the credentials.Type
please DRY that

@samuel-br
Copy link
Contributor Author

@samuel-br let's put this PR on hold until we finish with #307 as I see similar typos here and there

Also, did you see

Why for data we have 3 different functions for that?
the only difference is the credentials.Type
please DRY that

I fix it as we did in #307 with little help from function closers, also fix typo I found

Copy link
Member

@eranelbaz eranelbaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added ready to merge PR approved - can be merged once the PR owner is ready and removed pending final review labels Apr 14, 2022
@yaronya yaronya merged commit 5433e6a into main Apr 17, 2022
@yaronya yaronya deleted the feat_cloud_cost_cred_data-#218 branch April 17, 2022 08:36
Ongoing Issues automation moved this from In progress to Done Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-client provider ready to merge PR approved - can be merged once the PR owner is ready
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants