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

manage admin user for mongodb + use ValidateDiagFunc #609

Merged
merged 6 commits into from
Apr 10, 2024

Conversation

lpatte
Copy link
Contributor

@lpatte lpatte commented Apr 8, 2024

Description

Manage mongodb admin user like avnadmin user for other engines

Related #588 (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (improve existing resource(s) or datasource(s))
  • Documentation update

return func(v any, p cty.Path) (diags diag.Diagnostics) {
err := ValidateStringEnum(v.(string), enum)
if err != nil {
diags = append(diags, diag.Diagnostic{
Copy link
Contributor

Choose a reason for hiding this comment

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

note: you could just use diags.AddError()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"terraform-plugin-framework/diag" has it not "terraform-plugin-sdk/v2/diag"

diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Missing authentication database",
Detail: fmt.Sprintf("value %s do not have authentication database", value),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Detail: fmt.Sprintf("value %s do not have authentication database", value),
Detail: fmt.Sprintf("value %s does not have authentication database", value),

if err := config.OVHClient.GetWithContext(ctx, listEndpoint, &listRes); err != nil {
return diag.Errorf("Error calling GET %s:\n\t %q", listEndpoint, err)
}

name := d.Get("name").(string)
if name == "admin" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes because the special case for user admin in ovh/resource_cloud_project_database_mongodb_user.go will call ovh/data_cloud_project_database_mongodb_user.go:dataSourceCloudProjectDatabaseMongodbUserRead() with name = "admin"


* `name` - (Required, Forces new resource) Name of the user.

* `name` - (Required, Forces new resource) Name of the user. A user named "admin" is map with already created admin@admin user instead of create a new user.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `name` - (Required, Forces new resource) Name of the user. A user named "admin" is map with already created admin@admin user instead of create a new user.
* `name` - (Required, Forces new resource) Name of the user. A user named "admin" is mapped with already created admin@admin user instead of creating a new user.


* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is map with already created admin user instead of create a new user.

* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is map with already created admin user instead of creating a new user.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is map with already created admin user instead of creating a new user.
* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is mapped with already created admin user instead of creating a new user.


* `name` - (Required, Forces new resource) Username affected by this acl. A user named "avnadmin" is map with already created admin user and reset his password instead of create a new user.

* `name` - (Required, Forces new resource) Username affected by this acl. A user named "avnadmin" is map with already created admin user and reset his password instead of creating a new user.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `name` - (Required, Forces new resource) Username affected by this acl. A user named "avnadmin" is map with already created admin user and reset his password instead of creating a new user.
* `name` - (Required, Forces new resource) Username affected by this acl. A user named "avnadmin" is mapped with already created admin user and reset his password instead of creating a new user.


* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is map with already created admin user and reset his password instead of create a new user.

* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is map with already created admin user and reset his password instead of creating a new user.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is map with already created admin user and reset his password instead of creating a new user.
* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is mapped with already created admin user and reset his password instead of creating a new user.


* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is map with already created admin user and reset his password instead of create a new user. The "Grafana" engine only allows the "avnadmin" mapping.

* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is map with already created admin user and reset his password instead of creating a new user. The "Grafana" engine only allows the "avnadmin" mapping.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is map with already created admin user and reset his password instead of creating a new user. The "Grafana" engine only allows the "avnadmin" mapping.
* `name` - (Required, Forces new resource) Name of the user. A user named "avnadmin" is mapped with already created admin user and reset his password instead of creating a new user. The "Grafana" engine only allows the "avnadmin" mapping.

@amstuta amstuta merged commit dd08eda into master Apr 10, 2024
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.

2 participants