crossplane-contrib / provider-keycloak

Apache License 2.0
25 stars 16 forks source link

Refer to parentId from Group in Child Group #46

Closed lewandowskim1988 closed 9 months ago

lewandowskim1988 commented 9 months ago

This is not an issue but rather question regarding creation of an resource.

I am trying to create keycloak Group and this works fine but the problem start when I am trying to create child-group since it need parentId of previously created Group and I am not sure how to pass it dynamically (I would like to create both resources in one go).

I already try writeConnectionSecretToRef (publishConnectionDetailsTo was not working for me for some reason) but it just created empty secret without any data. Also I am not sure how to refer to such secret when creating child-group since I don't see any option for that.

Should I use crossplane Composition to make it work as expected and if yes could you give me some example of how to do it since I am just starting exploring crossplane and it functionalities.

Thank you for any help!

Breee commented 9 months ago

Greetings, i'll look into it.

Usually you should have a parentIdRef in the group to just reference the parent group by name. It does not look like it is the case. I'll prepare a fix

Breee commented 9 months ago

Can you try: https://marketplace.upbound.io/providers/crossplane-contrib/provider-keycloak/v0.9.0

there you should be able to do something like that:

---
apiVersion: group.keycloak.crossplane.io/v1alpha1
kind: Group
metadata:
  name: parent-group
spec:
  forProvider:
    name: "parent-group"  # The name of the group in Keycloak
    realmId: "example-realm"  # The realm where this group belongs
---
apiVersion: group.keycloak.crossplane.io/v1alpha1
kind: Group
metadata:
  name: child-group
spec:
  forProvider:
    name: "ChildGroup"  # The name of the group in Keycloak
    realmId: "example-realm"  # The realm where this group belongs
    parentIdRef: 
      name: "parent-group"  # The ID of the parent group
lewandowskim1988 commented 9 months ago

Thank you for that improvement. Now it is working like a harm.