Skip to content

Conversation

manupedrozo
Copy link
Collaborator

Description

Allow overriding an attribute's type in the autogen config.
Currently supporting set to list and list to set overrides.

Any other override requires more complexity in the conversion and is unlikely to be required.

  • Overriding the roles attribute in the org_service_account_api resource from list to set. This is necessary since the API spec is missing the uniqueItems: true configuration (see CLOUDP-348768).

  • Enabling the TestAccOrgServiceAccountAPI_rolesOrdering acceptance test.

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

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. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • 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 have added appropriate changelog entries.
  • 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.

Further comments


func configBasic(orgID, name, description string, roles []string, secretExpiresAfterHours int) string {
rolesStr := fmt.Sprintf(`%q`, strings.Join(roles, `", "`))
rolesStr := `"` + strings.Join(roles, `", "`) + `"`
Copy link
Collaborator Author

@manupedrozo manupedrozo Oct 10, 2025

Choose a reason for hiding this comment

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

Fixing non-matching escapes

Copy link
Member

Choose a reason for hiding this comment

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

was this also incorrect in non-api resource test, to fix it there too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No handwritten resource for this one yet. I did check that we are using this in other tests.

@manupedrozo manupedrozo force-pushed the CLOUDP-349935-autogen-basic-type-override branch from cc755b3 to 752cdb6 Compare October 10, 2025 15:31
@manupedrozo manupedrozo marked this pull request as ready for review October 10, 2025 15:32
@manupedrozo manupedrozo requested a review from a team as a code owner October 10, 2025 15:32
@manupedrozo manupedrozo changed the title chore: Add autogen type overrride support for sets and lists chore: Add autogen type override support for sets and lists Oct 10, 2025
func applyTypeOverride(override *config.Override, attr *Attribute) {
switch *override.Type {
case config.Set:
if attr.List != nil {
Copy link
Member

Choose a reason for hiding this comment

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

should we throw an error if trying to override to set something that is not a list? same for list

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently we ignore it and print a warning, similar to applyTimeoutConfig() below.
+1 on moving to errors - ideally in another PR since we need a refactor.

Copy link
Member

Choose a reason for hiding this comment

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

good to have it in another PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 for errors in this case, warnings may be easy to miss in automation

overrides:
list_string:
type: set
description: "List overridden to set"
Copy link
Member

Choose a reason for hiding this comment

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

what's description used for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just indicating that we are overriding the type. Could have gone for a comment as well.

Copy link
Member

Choose a reason for hiding this comment

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

i'd probably go for a comment if we're not using the field

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done 941ed34

- Test Singleton Resource
"/api/atlas/v2/groups/{groupId}/testResourceWithCollections":
delete:
description: DELETE API description
Copy link
Member

Choose a reason for hiding this comment

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

similarly as in another comment, what is description used for here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We set them for all operations, kept for consistency.

@manupedrozo manupedrozo merged commit 5b07072 into master Oct 15, 2025
46 checks passed
@manupedrozo manupedrozo deleted the CLOUDP-349935-autogen-basic-type-override branch October 15, 2025 08:51
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