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

chore: Updates SDK for database-user v20231115002 to v20231115008 #1014

Merged
merged 2 commits into from
Apr 26, 2024

Conversation

EspenAlbert
Copy link
Contributor

@EspenAlbert EspenAlbert commented Apr 25, 2024

Proposed changes

Updates SDK for database-user v20231115002 to v20231115008
See the Jira issue for the upgrade strategy.

Link to any related issue(s): CLOUDP-222755

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as
    expected)
  • This change requires a documentation update
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Manual QA performed:

  • cfn invoke for each of CRUDL/cfn test
  • Updated resource in example
  • Published to AWS private registry
  • Used the template in example to create and update a stack in AWS
  • Deleted stack to ensure resources are deleted
  • Created multiple resources in same stack
  • Validated in Atlas UI
  • Included screenshots

Required Checklist:

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • For CFN Resources: I have released by changes in the private registry and proved by change
    works in Atlas

Further comments

@EspenAlbert EspenAlbert requested a review from a team as a code owner April 25, 2024 08:59
@@ -119,8 +119,7 @@ func Read(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
_, _ = logger.Debugf("databaseUser:%+v", databaseUser)
var roles []RoleDefinition

for i := range databaseUser.Roles {
r := databaseUser.Roles[i]
for _, r := range databaseUser.GetRoles() {
role := RoleDefinition{
CollectionName: r.CollectionName,
DatabaseName: &r.DatabaseName,
Copy link
Member

Choose a reason for hiding this comment

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

can it also be used Get functions here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems a bit weird, since the RoleDefinition expects a pointer. WDYT?

@@ -133,8 +132,7 @@ func Read(req handler.Request, prevModel *Model, currentModel *Model) (handler.P

var labels []LabelDefinition

for i := range databaseUser.Labels {
l := databaseUser.Labels[i]
for _, l := range databaseUser.GetLabels() {
label := LabelDefinition{
Key: l.Key,
Copy link
Member

Choose a reason for hiding this comment

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

same, GetKey(), etc. can be used here?

@@ -293,7 +290,7 @@ func List(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
}

func setModel(currentModel *Model) (*admin.CloudDatabaseUser, error) {
var roles []admin.DatabaseUserRole
roles := []admin.DatabaseUserRole{}
Copy link
Member

Choose a reason for hiding this comment

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

knit: better performance but not so important here

roles := make([]admin.DatabaseUserRole, 0, len(currentModel.Roles))

Labels: labels,
Scopes: scopes,
Labels: &labels,
Scopes: &scopes,
Copy link
Member

Choose a reason for hiding this comment

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

knit: to make it clear that this is never nil and can take the pointer, you can define:

scopes := &[]admin.UserScope{} and then:

Scopes: scopes,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm. After changing the definitions above, it is not possible to use the & in the definition.
But not sure what is best practice.
Please let me know your preference :D

Copy link
Member

@lantoli lantoli Apr 26, 2024

Choose a reason for hiding this comment

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

ok as it is. it's a best practice when you do & to try to make it clear in the code (as close as possible to &) that it will never fail

@@ -15,6 +15,13 @@ Resources:
Principal:
Service: resources.cloudformation.amazonaws.com
Action: sts:AssumeRole
Condition:
Copy link
Member

Choose a reason for hiding this comment

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

why has this file changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did a make build.
cfn generate changes this file.

Copy link
Member

Choose a reason for hiding this comment

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

thanks, i guessed that, but this probably means that we didn't do it in previous PRs

lantoli
lantoli previously approved these changes Apr 25, 2024
AgustinBettati
AgustinBettati previously approved these changes Apr 25, 2024
Copy link
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

LGTM. Regarding the approach of a PR per resource, would doing a group of resources per PR be more efficient? Just thinking that with this approach we would have 40+ PRs in total

@EspenAlbert EspenAlbert dismissed stale reviews from AgustinBettati and lantoli via f34b99c April 25, 2024 12:32
@lantoli
Copy link
Member

lantoli commented Apr 26, 2024

@AgustinBettati @EspenAlbert i see the point of efficiency of doing grouped PRs, but also it's normally better to do focused PRs. Bigger PRs are harder to do and review, and easier to miss some possible bugs

@EspenAlbert EspenAlbert added this pull request to the merge queue Apr 26, 2024
Merged via the queue into master with commit dcad588 Apr 26, 2024
31 checks passed
@EspenAlbert EspenAlbert deleted the CLOUDP-222755_database-user branch April 26, 2024 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants