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

fix: add opensearch_acl to data.digitalocean_database_user schema #1290

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

andrewsomething
Copy link
Member

This bug was introduced when opensearch_acl support was added to the database cluster resource (#1215). The resource and data source share the flattenUserSettings method. When the data source attempts to set the empty opensearch_acl to state, it errors as it is not part of the datasource schema.

func flattenUserSettings(settings *godo.DatabaseUserSettings) []map[string]interface{} {
result := make([]map[string]interface{}, 0, 1)
if settings != nil {
r := make(map[string]interface{})
r["acl"] = flattenUserACLs(settings.ACL)
r["opensearch_acl"] = flattenOpenSearchUserACLs(settings.OpenSearchACL)
result = append(result, r)
}
return result
}

The acceptance test did not catch this as the user needs to have a setting block in the API response as the method checks it settings is nil. A brand new Postgres user does not, but a doadmin user does, e.g.

{
  "user": {
    "name": "doadmin",
    "role": "primary",
    "password": "<redacted>",
    "settings": {
      "pg_allow_replication": true
    }
  }
}

Updated test now passes, but before the change would fail with:

panic: Invalid address to set: []string{"settings", "0", "opensearch_acl"}

Fixes: #1289

Copy link
Contributor

@loosla loosla left a comment

Choose a reason for hiding this comment

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

🙏 Thank you

@andrewsomething andrewsomething merged commit 794ac7d into main Dec 18, 2024
3 checks passed
@andrewsomething andrewsomething deleted the asb/issues/1289 branch December 18, 2024 14:56
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.

opensearch_acl attempting to be set in digitalocean_database_user data, even when no settings block
2 participants