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

dbforpostgresql: add FlexibleServerActiveDirectoryAdministrator #530

Merged
merged 2 commits into from
Sep 7, 2023

Conversation

ytsarev
Copy link
Collaborator

@ytsarev ytsarev commented Aug 29, 2023

Description of your changes

Add support for FlexibleServerActiveDirectoryAdministrator

I have:

  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

 k get managed
NAME                                                                            READY   SYNCED   EXTERNAL-NAME                                    AGE
resourcegroup.azure.upbound.io/example-flex-server-pg-ad-admin-yury-delete-me   True    True     example-flex-server-pg-ad-admin-yury-delete-me   10m

NAME                                                                                             READY   SYNCED   EXTERNAL-NAME                                    AGE
flexibleserver.dbforpostgresql.azure.upbound.io/example-flex-server-pg-ad-admin-yury-delete-me   True    True     example-flex-server-pg-ad-admin-yury-delete-me   10m

NAME                                                                                  READY   SYNCED   EXTERNAL-NAME                                                                                                                                                                                                                                                              AGE
flexibleserveractivedirectoryadministrator.dbforpostgresql.azure.upbound.io/example   True    True     /subscriptions/<redacted>/resourceGroups/example-flex-server-pg-ad-admin-yury-delete-me/providers/Microsoft.DBforPostgreSQL/flexibleServers/example-flex-server-pg-ad-admin-yury-delete-me/administrators/<redacted>   10m

Please follow uptest run status below before the merge

@ytsarev
Copy link
Collaborator Author

ytsarev commented Aug 29, 2023

/test-examples="examples/dbforpostgresql/flexibleserver-all-in-one.yaml"

Signed-off-by: Yury Tsarev <yury@upbound.io>
@ytsarev
Copy link
Collaborator Author

ytsarev commented Aug 29, 2023

/test-examples="examples/dbforpostgresql/flexibleserver-all-in-one.yaml"

* dedicated uptest example
* proper selector

Signed-off-by: Yury Tsarev <yury@upbound.io>
@ytsarev
Copy link
Collaborator Author

ytsarev commented Sep 7, 2023

/test-examples="examples/dbforpostgresql/flexibleserveractivedirectoryadministrator.yaml"

Copy link
Collaborator

@turkenf turkenf 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 @ytsarev, LGTM.

@@ -645,7 +645,9 @@ var ExternalNameConfigs = map[string]config.ExternalName{
"azurerm_postgresql_flexible_server_firewall_rule": config.TemplatedStringAsIdentifier("name", "{{ .parameters.server_id }}/firewallRules/{{ .external_name }}"),
"azurerm_postgresql_firewall_rule": config.TemplatedStringAsIdentifier("name", "/subscriptions/{{ .setup.configuration.subscription_id }}/resourceGroups/{{ .parameters.resource_group_name }}/providers/Microsoft.DBforPostgreSQL/servers/{{ .parameters.server_name }}/firewallRules/{{ .external_name }}"),
"azurerm_postgresql_flexible_server": config.TemplatedStringAsIdentifier("name", "/subscriptions/{{ .setup.configuration.subscription_id }}/resourceGroups/{{ .parameters.resource_group_name }}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{{ .external_name }}"),
"azurerm_postgresql_virtual_network_rule": config.TemplatedStringAsIdentifier("name", "/subscriptions/{{ .setup.configuration.subscription_id }}/resourceGroups/{{ .parameters.resource_group_name }}/providers/Microsoft.DBforPostgreSQL/servers/{{ .parameters.server_name }}/virtualNetworkRules/{{ .external_name }}"),
// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/myserver/administrators/objectId
"azurerm_postgresql_flexible_server_active_directory_administrator": config.TemplatedStringAsIdentifier("", "/subscriptions/{{ .setup.configuration.subscription_id }}/resourceGroups/{{ .parameters.resource_group_name }}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{{ .parameters.server_name }}/administrators/{{ .parameters.object_id }}"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just asking for understanding, why didn't we use the configuration in externalnamenottested.go?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@turkenf good question, configuration from the externalnamenottested.go is the first thing i tried,

 config.TemplatedStringAsIdentifier("object_id", "/subscriptions/{{ .setup.configuration.subscription_id }}/resourceGroups/{{ .parameters.resource_group_name }}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{{ .parameters.server_name }}/administrators/{{ .external_name }}"),

in this case it was omitting objectId from the spec and using it as a name/externalname. ObjectId has uuid format like 13747b18-0617-4569-b94d-0cabe84934f8 and it would be quite obscure, non-obvious UX to make an AD object reference through the MR object name. That's why I decided to move it more straightforward spec.forProvider.objectId . Hope it helps! :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Many thanks for the explanation @ytsarev 👍

@ytsarev ytsarev merged commit f7e22c9 into crossplane-contrib:main Sep 7, 2023
10 checks passed
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.

None yet

2 participants