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: Migrates federated_settings_identity_provider to new auto-generated SDK #1808

Merged
merged 16 commits into from
Jan 12, 2024

Conversation

oarbusi
Copy link
Collaborator

@oarbusi oarbusi commented Jan 4, 2024

Description

migrates federated_settings_identity_provider to new auto-generated SDK
Because a breaking change in the latest version of the federated settings API, some changes needed to be made to grant users a grace period to avoid breaking changes in next release:

  • Allow both formats for identityProviderId.
  • Put a warning when using the old ID, and linking to the migration guide. In the future only new format for identityProviderId will be allowed.

Link to any related issue(s): https://jira.mongodb.org/browse/CLOUDP-220807

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

Copy link
Collaborator Author

@oarbusi oarbusi Jan 4, 2024

Choose a reason for hiding this comment

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

moved all flatteners to this new file. Some of the flatteners are also used in federated_settings_org_config so I did not change those to new SDK. Instead, created new methods for the ones used by new SDK.

@oarbusi oarbusi changed the title chore: migrates federated_settings_identity_provider to new auto-generated SDK chore: Migrates federated_settings_identity_provider to new auto-generated SDK Jan 4, 2024
if !federationSettingsIDOk {
return diag.FromErr(errors.New("federation_settings_id must be configured"))
}
// There is no available paginated method
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as of now there is no way to paginate results in the new SDK

Copy link
Member

Choose a reason for hiding this comment

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

Although the old SDK defined list options they were not used as the options are not present in the v1 API: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v1/#tag/Federated-Authentication/operation/listIdentityProviders

Given that page_num and items_per_page are not being used, should we create a followup ticket to deprecate them?

Copy link
Collaborator Author

@oarbusi oarbusi Jan 5, 2024

Choose a reason for hiding this comment

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

Makes sense to me. I can create the ticket
edit: Created the ticket: CLOUDP-221367

@oarbusi oarbusi marked this pull request as ready for review January 4, 2024 15:34
@oarbusi oarbusi requested a review from a team as a code owner January 4, 2024 15:34
@marcosuma
Copy link
Collaborator

LGTM! Good to have a second look for this change

@@ -201,7 +201,7 @@ func DataSource() *schema.Resource {
}
func dataSourceMongoDBAtlasFederatedSettingsIdentityProviderRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
// Get client connection.
conn := meta.(*config.MongoDBClient).Atlas
connV2 := meta.(*config.MongoDBClient).AtlasV2
Copy link
Member

Choose a reason for hiding this comment

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

As acceptance test for the resource and data sources are not being run in the CI, wanted to confirm if you were able to run them locally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have run all acceptance tests locally successfully

@@ -11,13 +11,13 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
matlas "go.mongodb.org/atlas/mongodbatlas"
"go.mongodb.org/atlas-sdk/v20231115002/admin"
)

func TestAccFedRSFederatedSettingsIdentityProvider_basic(t *testing.T) {
Copy link
Collaborator

@maastha maastha Jan 5, 2024

Choose a reason for hiding this comment

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

When do you plan to add migration tests? If planning to merge this to master right away we should add some as part of this PR and update in subsequent PRs

* `identity_provider_id` - (Required) Unique 20-hexadecimal digit string that identifies the IdP.
* `identity_provider_id` - (Required) Unique 20-hexadecimal or 24-hexadecimal digit string that identifies the IdP.

**WARNING:** Starting at terraform provider 1.16.0 the allowed format for `identity_provider_id` will only be 24-hexadecimal digit string. See more [here](../guides/1.15.0-upgrade-guide.html.markdown)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will create a draft of the upgrade guide in a follow up PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Zuhairahmed your input for these changes in documentation would be appreciated.

@@ -58,4 +59,6 @@ Identity Provider **must** be imported before using federation_settings_id-idp_i
$ terraform import mongodbatlas_federated_settings_identity_provider.identity_provider 6287a663c660f52b1c441c6c-0oad4fas87jL5Xnk1297
```

**WARNING:** Starting from terraform provider version 1.16.0, to import Identity Provider, `id` will have to be used instead of `okta_idp_id`. See more [here](../guides/1.15.0-upgrade-guide.html.markdown)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will create a draft of the upgrade guide in a follow up PR

Severity: diag.Warning,
Summary: "Warning: deprecated identity provider id",
Detail: "Identity provider id value used will be deprecated. Please start using the new value.\n" +
" Follow instructions here: https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/1.15.0-upgrade-guide",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Zuhairahmed your input would be appreciated here

@@ -49,6 +49,7 @@ In addition to all arguments above, the following attributes are exported:
### FederatedSettingsIdentityProvider

* `okta_idp_id` - Unique 20-hexadecimal digit string that identifies the IdP.
* `id` - Unique 24-hexadecimal digit string that identifies the IdP.
Copy link
Member

Choose a reason for hiding this comment

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

Is this accurate? From my understanding the id of the resource is not modified, and continues to be de the encoded value of the federation_settings_id and okta_idp_id.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you are right, the terraform state id continues to be de the encoded value of the federation_settings_id and okta_idp_id. But once users start using the new id, terraform state id will be federation_settings_id and id encoded

Copy link
Member

@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.

I do agree that if the users does an import command, the id value of the resource with be the encoded value of federation_settings_id + identity provider id (both new and old format will be supported). However, my question is if this documentation of id which was added is accurate, because the id value will still be an encoded value which I doubt users will be able to use.

@@ -58,4 +59,6 @@ Identity Provider **must** be imported before using federation_settings_id-idp_i
$ terraform import mongodbatlas_federated_settings_identity_provider.identity_provider 6287a663c660f52b1c441c6c-0oad4fas87jL5Xnk1297
```

**WARNING:** Starting from terraform provider version 1.16.0, to import Identity Provider, `id` will have to be used instead of `okta_idp_id`. See more [here](../guides/1.15.0-upgrade-guide.html.markdown)
Copy link
Member

Choose a reason for hiding this comment

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

I believe it might be hard for users to understand what id is, might be better to rephrase to 24-hexadecimal digit string that identifies the IdP

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

oarbusi and others added 2 commits January 12, 2024 09:08
…derated_settings_identity_provider.go

Co-authored-by: Agustin Bettati <[email protected]>
@oarbusi oarbusi merged commit 9cf3f9f into master Jan 12, 2024
@oarbusi oarbusi deleted the CLOUDP-220807 branch January 12, 2024 08:16
@oarbusi oarbusi restored the CLOUDP-220807 branch January 18, 2024 10:31
@oarbusi oarbusi deleted the CLOUDP-220807 branch January 18, 2024 10:33
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.

5 participants