Skip to content

Commit

Permalink
feat: reference group in qos (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
tenstad authored Feb 1, 2025
1 parent f53e471 commit 09ffc2f
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 1 deletion.
13 changes: 13 additions & 0 deletions apis/user/v1alpha1/groupqualityofservicelimits_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ import (

// GroupQualityOfServiceLimitsParameters are the configurable fields of a GroupQualityOfServiceLimits.
type GroupQualityOfServiceLimitsParameters struct {
// Group for the quality of service limits.
// +optional
// +immutable
GroupID string `json:"groupId,omitempty"`

// GroupIDRef is a reference to a group to retrieve its groupId.
// +optional
// +immutable
GroupIDRef *xpv1.Reference `json:"groupIdRef,omitempty"`

// GroupIDSelector selects reference to a group to retrieve its groupId.
// +optional
GroupIDSelector *xpv1.Selector `json:"groupIdSelector,omitempty"`
}

// GroupQualityOfServiceLimitsObservation are the observable fields of a GroupQualityOfServiceLimits.
Expand Down
22 changes: 22 additions & 0 deletions apis/user/v1alpha1/referencers.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@ func (mg *User) ResolveReferences(ctx context.Context, c client.Reader) error {
return nil
}

// ResolveReferences of this GroupQualityOfServiceLimits
func (mg *GroupQualityOfServiceLimits) ResolveReferences(ctx context.Context, c client.Reader) error {
r := reference.NewAPIResolver(c, mg)

// resolve spec.forProvider.group
rsp, err := r.Resolve(ctx, reference.ResolutionRequest{
CurrentValue: mg.Spec.ForProvider.GroupID,
Reference: mg.Spec.ForProvider.GroupIDRef,
Selector: mg.Spec.ForProvider.GroupIDSelector,
To: reference.To{Managed: &Group{}, List: &GroupList{}},
Extract: reference.ExternalName(),
})
if err != nil {
return errors.Wrap(err, "spec.forProvider.group")
}

mg.Spec.ForProvider.GroupID = rsp.ResolvedValue
mg.Spec.ForProvider.GroupIDRef = rsp.ResolvedReference

return nil
}

// ResolveReferences of this AccessKey
func (mg *AccessKey) ResolveReferences(ctx context.Context, c client.Reader) error {
r := reference.NewAPIResolver(c, mg)
Expand Down
12 changes: 11 additions & 1 deletion apis/user/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,86 @@ spec:
forProvider:
description: GroupQualityOfServiceLimitsParameters are the configurable
fields of a GroupQualityOfServiceLimits.
properties:
groupId:
description: Group for the quality of service limits.
type: string
groupIdRef:
description: GroupIDRef is a reference to a group to retrieve
its groupId.
properties:
name:
description: Name of the referenced object.
type: string
policy:
description: Policies for referencing.
properties:
resolution:
default: Required
description: |-
Resolution specifies whether resolution of this reference is required.
The default is 'Required', which means the reconcile will fail if the
reference cannot be resolved. 'Optional' means this reference will be
a no-op if it cannot be resolved.
enum:
- Required
- Optional
type: string
resolve:
description: |-
Resolve specifies when this reference should be resolved. The default
is 'IfNotPresent', which will attempt to resolve the reference only when
the corresponding field is not present. Use 'Always' to resolve the
reference on every reconcile.
enum:
- Always
- IfNotPresent
type: string
type: object
required:
- name
type: object
groupIdSelector:
description: GroupIDSelector selects reference to a group to retrieve
its groupId.
properties:
matchControllerRef:
description: |-
MatchControllerRef ensures an object with the same controller reference
as the selecting object is selected.
type: boolean
matchLabels:
additionalProperties:
type: string
description: MatchLabels ensures an object with matching labels
is selected.
type: object
policy:
description: Policies for selection.
properties:
resolution:
default: Required
description: |-
Resolution specifies whether resolution of this reference is required.
The default is 'Required', which means the reconcile will fail if the
reference cannot be resolved. 'Optional' means this reference will be
a no-op if it cannot be resolved.
enum:
- Required
- Optional
type: string
resolve:
description: |-
Resolve specifies when this reference should be resolved. The default
is 'IfNotPresent', which will attempt to resolve the reference only when
the corresponding field is not present. Use 'Always' to resolve the
reference on every reconcile.
enum:
- Always
- IfNotPresent
type: string
type: object
type: object
type: object
managementPolicies:
default:
Expand Down

0 comments on commit 09ffc2f

Please sign in to comment.