Add oidcappref

[ZITADOPER-1]
This commit is contained in:
Haim Kortovich
2024-05-21 19:10:32 -05:00
parent f2da8be209
commit dac9d1a52f
3 changed files with 44 additions and 0 deletions

View File

@@ -4,6 +4,13 @@ import (
corev1 "k8s.io/api/core/v1"
)
type OIDCAppRef struct {
// ObjectReference is a reference to a object.
// +kubebuilder:validation:Required
// +operator-sdk:csv:customresourcedefinitions:type=spec
corev1.ObjectReference `json:",inline"`
}
type CrdbClusterRef struct {
// ObjectReference is a reference to a object.
// +kubebuilder:validation:Required

View File

@@ -42,6 +42,27 @@ func (r *RefResolver) ZitadelCluster(ctx context.Context, ref *ZitadelClusterRef
return &zitadel, nil
}
func (r *RefResolver) OIDCAppRef(ctx context.Context, ref *OIDCAppRef,
namespace string) (*OIDCApp, error) {
if ref.Kind != "" && ref.Kind != "OIDCApp" {
return nil, fmt.Errorf("Unsupported reference kind: '%s'", ref.Kind)
}
key := types.NamespacedName{
Name: ref.Name,
Namespace: namespace,
}
if ref.Namespace != "" {
key.Namespace = ref.Namespace
}
var zitadel OIDCApp
if err := r.client.Get(ctx, key, &zitadel); err != nil {
return nil, err
}
return &zitadel, nil
}
func (r *RefResolver) ProjectRef(ctx context.Context, ref *ProjectRef,
namespace string) (*Project, error) {
if ref.Kind != "" && ref.Kind != "Project" {

View File

@@ -353,6 +353,22 @@ func (in *OIDCAppList) DeepCopyObject() runtime.Object {
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *OIDCAppRef) DeepCopyInto(out *OIDCAppRef) {
*out = *in
out.ObjectReference = in.ObjectReference
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OIDCAppRef.
func (in *OIDCAppRef) DeepCopy() *OIDCAppRef {
if in == nil {
return nil
}
out := new(OIDCAppRef)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *OIDCAppSpec) DeepCopyInto(out *OIDCAppSpec) {
*out = *in