From 9042bf7596139a7448db6980c75099736a774881 Mon Sep 17 00:00:00 2001 From: raffis Date: Mon, 18 Mar 2024 11:20:01 +0100 Subject: [PATCH] fix: realm groups api spec, fixes #192 (#196) --- api/v1beta1/keycloakrealm_types.go | 12 +++- api/v1beta1/zz_generated.deepcopy.go | 63 ++++++++++++++++++- ...cloak.infra.doodle.com_keycloakrealms.yaml | 29 ++++++++- ...cloak.infra.doodle.com_keycloakrealms.yaml | 29 ++++++++- 4 files changed, 128 insertions(+), 5 deletions(-) diff --git a/api/v1beta1/keycloakrealm_types.go b/api/v1beta1/keycloakrealm_types.go index e939daba..5909836c 100644 --- a/api/v1beta1/keycloakrealm_types.go +++ b/api/v1beta1/keycloakrealm_types.go @@ -240,7 +240,7 @@ type KeycloakAPIRealm struct { // Enabled event types // +optional - Groups []string `json:"groups,omitempty"` + Groups []KeycloakAPIGroup `json:"groups,omitempty"` EnabledEventTypes []string `json:"enabledEventTypes,omitempty"` // Enable events recording @@ -862,3 +862,13 @@ type TokenResponse struct { // +optional ErrorDescription string `json:"error_description"` } + +type KeycloakAPIGroup struct { + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Path string `json:"path,omitempty"` + RealmRoles []string `json:"realmRoles,omitempty"` + Attributes map[string][]string `json:"attributes,omitempty"` + ClientRoles map[string][]string `json:"clientRoles,omitempty"` + SubGroups []extv1.JSON `json:"subGroups,omitempty"` +} diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 0a02d493..f91c287a 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -348,6 +348,63 @@ func (in *KeycloakAPIClient) DeepCopy() *KeycloakAPIClient { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KeycloakAPIGroup) DeepCopyInto(out *KeycloakAPIGroup) { + *out = *in + if in.RealmRoles != nil { + in, out := &in.RealmRoles, &out.RealmRoles + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Attributes != nil { + in, out := &in.Attributes, &out.Attributes + *out = make(map[string][]string, len(*in)) + for key, val := range *in { + var outVal []string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make([]string, len(*in)) + copy(*out, *in) + } + (*out)[key] = outVal + } + } + if in.ClientRoles != nil { + in, out := &in.ClientRoles, &out.ClientRoles + *out = make(map[string][]string, len(*in)) + for key, val := range *in { + var outVal []string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make([]string, len(*in)) + copy(*out, *in) + } + (*out)[key] = outVal + } + } + if in.SubGroups != nil { + in, out := &in.SubGroups, &out.SubGroups + *out = make([]apiextensionsv1.JSON, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KeycloakAPIGroup. +func (in *KeycloakAPIGroup) DeepCopy() *KeycloakAPIGroup { + if in == nil { + return nil + } + out := new(KeycloakAPIGroup) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KeycloakAPIPasswordReset) DeepCopyInto(out *KeycloakAPIPasswordReset) { *out = *in @@ -416,8 +473,10 @@ func (in *KeycloakAPIRealm) DeepCopyInto(out *KeycloakAPIRealm) { } if in.Groups != nil { in, out := &in.Groups, &out.Groups - *out = make([]string, len(*in)) - copy(*out, *in) + *out = make([]KeycloakAPIGroup, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } if in.EnabledEventTypes != nil { in, out := &in.EnabledEventTypes, &out.EnabledEventTypes diff --git a/chart/keycloak-controller/crds/keycloak.infra.doodle.com_keycloakrealms.yaml b/chart/keycloak-controller/crds/keycloak.infra.doodle.com_keycloakrealms.yaml index fa673257..e734198a 100644 --- a/chart/keycloak-controller/crds/keycloak.infra.doodle.com_keycloakrealms.yaml +++ b/chart/keycloak-controller/crds/keycloak.infra.doodle.com_keycloakrealms.yaml @@ -973,7 +973,34 @@ spec: type: integer groups: items: - type: string + properties: + attributes: + additionalProperties: + items: + type: string + type: array + type: object + clientRoles: + additionalProperties: + items: + type: string + type: array + type: object + id: + type: string + name: + type: string + path: + type: string + realmRoles: + items: + type: string + type: array + subGroups: + items: + x-kubernetes-preserve-unknown-fields: true + type: array + type: object type: array id: description: ID is the internal keycloak id diff --git a/config/base/crd/bases/keycloak.infra.doodle.com_keycloakrealms.yaml b/config/base/crd/bases/keycloak.infra.doodle.com_keycloakrealms.yaml index fa673257..e734198a 100644 --- a/config/base/crd/bases/keycloak.infra.doodle.com_keycloakrealms.yaml +++ b/config/base/crd/bases/keycloak.infra.doodle.com_keycloakrealms.yaml @@ -973,7 +973,34 @@ spec: type: integer groups: items: - type: string + properties: + attributes: + additionalProperties: + items: + type: string + type: array + type: object + clientRoles: + additionalProperties: + items: + type: string + type: array + type: object + id: + type: string + name: + type: string + path: + type: string + realmRoles: + items: + type: string + type: array + subGroups: + items: + x-kubernetes-preserve-unknown-fields: true + type: array + type: object type: array id: description: ID is the internal keycloak id