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: Defines new schema scaffolding command using terraform code generation tools #1827

Merged
merged 11 commits into from
Jan 12, 2024

Conversation

AgustinBettati
Copy link
Member

@AgustinBettati AgustinBettati commented Jan 10, 2024

Description

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

This PR also includes updates to our CONTRIBUTING.md guide providing guidance on the usage of the command.

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals, I defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.

Further comments

@AgustinBettati AgustinBettati changed the title chore: New schema scaffolding command using terraform code generation tools chore: Defines new schema scaffolding command using terraform code generation tools Jan 10, 2024
@AgustinBettati
Copy link
Member Author

Will look into failing synk checks that appeared in this PR. Currently not able to obtain more details.

@AgustinBettati AgustinBettati marked this pull request as ready for review January 10, 2024 13:19
@AgustinBettati AgustinBettati requested a review from a team as a code owner January 10, 2024 13:19
@@ -12,6 +12,8 @@ Thanks for your interest in contributing to MongoDB Atlas Terraform Provider, th
- [Running Acceptance Tests](#running-acceptance-tests)
Copy link
Member

Choose a reason for hiding this comment

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

not for this PR but I'm feeling more and more the pain @gssbzn mentions about contributing file size :-)
maybe at some moment we can have in this file the very basic stuff that people need to start contributing, and refer to other files for more specific details.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes makes sense, one option I see is to define a README.md in scaffolding folder and reference it from CONTRIBUTING.md file.



# URL to download Atlas Admin API Spec
atlas_admin_api_spec="https://raw.githubusercontent.com/mongodb/atlas-sdk-go/main/openapi/atlas-api-transformed.yaml"
Copy link
Collaborator

@andreaangiolillo andreaangiolillo Jan 10, 2024

Choose a reason for hiding this comment

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

Could we explain somewhere why we are using this file instead of https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/d05d140a757e46f9ce25ee52b17ae91335003c32-v2-2023-11-15.json? I want to make sure to capture the reasons behind this decision so that we don't forget it

Copy link
Member Author

@AgustinBettati AgustinBettati Jan 10, 2024

Choose a reason for hiding this comment

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

I added details in the Spec document with the reasoning behind this decision, as well as a point in the risks section. If we are for seeing a significant maintenance cost we can adjust here.

GNUmakefile Outdated
Comment on lines 126 to 127
scaffold-schemas:
@tools/scaffold/scripts/schema-scaffold.sh $(name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

should the scaffold command call the scaffold-schemas?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is not the initial idea, but can be looked into. The scaffold-schemas requires the generator_config.yml file to be defined with the mapping of the endpoints that will be used. CLOUDP-221362: Adjust existing scaffolding command will include the generation of a template for the generator_config.yml file, but will require defining the endpoints and possibly additional configuration before running scaffold-schemas.

GNUmakefile Outdated
# details on usage can be found in CONTRIBUTING.md under "Scaffolding Schema and Model Definitions"
.PHONY: scaffold-schemas
scaffold-schemas:
@tools/scaffold/scripts/schema-scaffold.sh $(name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@tools/scaffold/scripts/schema-scaffold.sh $(name)
@tools/scaffold/scripts/schema-scaffold.sh $(resource_name)

In my PR for generating doc #1829 I am using resource_name to add additional context. let me know if you have a strong opinion in using name instead

Copy link
Member Author

Choose a reason for hiding this comment

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

resource_name sounds good. This is a small nit: both scaffold commands receive the resource_name in camel case, while in docs receives it is in snake case. I think the formats received in both cases are out of convenience, just stating in case it is something simple to align.

Copy link
Collaborator

Choose a reason for hiding this comment

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

unfortunately, we are forced to use the snake case for tfplugindocs. We could rename the name in the script but it would require additional code to handle it

@@ -115,9 +115,14 @@ link-git-hooks: ## Install git hooks
update-atlas-sdk: ## Update the atlas-sdk dependency
./scripts/update-sdk.sh

# details on usage can be found in CONTRIBUTING.md under "Creating New Resource and Data Sources"
# details on usage can be found in CONTRIBUTING.md under "Scaffolding initial Code and File Structure"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there any reasons why we are not adding how to use the script here instead of asking the user to open another file? I'd expect to have here a description on how to use the script and then add in CONTRIBUTING how to use the makefile command

Copy link
Member Author

@AgustinBettati AgustinBettati Jan 12, 2024

Choose a reason for hiding this comment

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

Contributing file does contain more detailed description of the intent, limitations, and further guidance. I can add an example of how command is run in the make file for users which are familiar with this information. Is this question related to how the docs command will be documented? If it is does not have much context to be provided, I believe it makes sense to just describe how it is run in the make file.

Copy link
Collaborator

@andreaangiolillo andreaangiolillo left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for all the follow ups

@AgustinBettati AgustinBettati merged commit 98054a6 into master Jan 12, 2024
@AgustinBettati AgustinBettati deleted the CLOUDP-221360 branch January 12, 2024 15:16
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.

4 participants