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

ENG-14612: Implement cyral_policy_wizards resource #593

Merged
merged 8 commits into from
Dec 18, 2024
Merged

Conversation

yoursnerdly
Copy link
Contributor

@yoursnerdly yoursnerdly commented Dec 13, 2024

Description of the change

As title

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • Jira issue referenced in commit message and/or PR title

Testing

  • With wizard-id specified, the data source state shows only the requested wizard.
  • With no wizard-id specified, the data source state shows the list of all supported wizards.

Copy link
Contributor

@wcmjunior wcmjunior left a comment

Choose a reason for hiding this comment

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

A few suggestions:

  1. If the api is policyWizard in the singular, please use the same convention for the resource. I remember mentioning it should be in plural, but it was a mistake on my end as I did not check if the API was plural as well.
  2. As for code hygiene, I suggest to keep the policy_wizard in its own package. Seems like the package structure should be:
- policy
   |- set
   |- wizard

@yoursnerdly
Copy link
Contributor Author

  1. If the api is policyWizard in the singular, please use the same convention for the resource. I remember mentioning it should be in plural, but it was a mistake on my end as I did not check if the API was plural as well.

Well the REST path is GET /v1/policyWizards (plural) with optional id at the end. The gRPC methods are called ReadPolicyWizard (singular because it pertains to ONE wizard) and ListPolicyWizards (plural).

Also given that the data source returns a list of wizards, I'd suggest retaining the plural.

@@ -180,8 +180,6 @@ func getCredentials(d *schema.ResourceData) (string, string, diag.Diagnostics) {
return clientID, clientSecret, diags
}

var provider = Provider()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an unused private variable that causes a linter warning.

@yoursnerdly
Copy link
Contributor Author

- policy
   |- set
   |- wizard

Thanks for the suggestion, this is incorporated in the latest commit.

Copy link
Contributor

@gengdahlCyral gengdahlCyral left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@wcmjunior wcmjunior left a comment

Choose a reason for hiding this comment

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

The convention documented here used throughout the whole codebase makes it faster to anyone reading it to understand what is going on. Maybe the docs are not good enough to ask to follow the same naming conventions, but if you check all the other resources they will look the very same as the changes I propose in the review.

As we use clear and descriptive package names like policy.set and policy.wizard, we can use the same standards to make it easier to anyone used to read any of our resources and data sources. We also end up avoid Smurf naming convention.

cyral/internal/policy/set/constants.go Outdated Show resolved Hide resolved
cyral/internal/policy/set/datasource.go Outdated Show resolved Hide resolved
cyral/internal/policy/set/datasource.go Outdated Show resolved Hide resolved
cyral/internal/policy/set/datasource.go Outdated Show resolved Hide resolved
cyral/internal/policy/set/model.go Outdated Show resolved Hide resolved
cyral/internal/policy/set/resource.go Outdated Show resolved Hide resolved
cyral/internal/policy/set/resource.go Outdated Show resolved Hide resolved
cyral/internal/policy/set/resource.go Outdated Show resolved Hide resolved
@yoursnerdly
Copy link
Contributor Author

The convention documented here used throughout the whole codebase makes it faster to anyone reading it to understand what is going on. Maybe the docs are not good enough to ask to follow the same naming conventions, but if you check all the other resources they will look the very same as the changes I propose in the review.

As we use clear and descriptive package names like policy.set and policy.wizard, we can use the same standards to make it easier to anyone used to read any of our resources and data sources. We also end up avoid Smurf naming convention.

Yeah, this happened due to refactoring out into separate packages for policy set and wizard - I had to use different names when they were in the same package. Will fix.

@wcmjunior wcmjunior merged commit d8ce052 into main Dec 18, 2024
3 checks passed
@wcmjunior wcmjunior deleted the ENG-14612 branch December 18, 2024 06:31
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.

3 participants