Skip to content

Commit c6e326e

Browse files
feat: use commonapi.ObjectReference
1 parent 0b54820 commit c6e326e

10 files changed

+41
-74
lines changed

api/clusters/v1alpha1/accessrequest_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ type AccessRequestSpec struct {
2222
// This value is immutable.
2323
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="clusterRef is immutable"
2424
// +optional
25-
ClusterRef *NamespacedObjectReference `json:"clusterRef,omitempty"`
25+
ClusterRef *commonapi.ObjectReference `json:"clusterRef,omitempty"`
2626

2727
// RequestRef is the reference to the ClusterRequest for whose Cluster access is requested.
2828
// Is ignored if clusterRef is set.
2929
// This value is immutable.
3030
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="requestRef is immutable"
3131
// +optional
32-
RequestRef *NamespacedObjectReference `json:"requestRef,omitempty"`
32+
RequestRef *commonapi.ObjectReference `json:"requestRef,omitempty"`
3333

3434
// Permissions are the requested permissions.
3535
Permissions []PermissionsRequest `json:"permissions"`
@@ -51,7 +51,7 @@ type AccessRequestStatus struct {
5151
commonapi.Status `json:",inline"`
5252

5353
// SecretRef holds the reference to the secret that contains the actual credentials.
54-
SecretRef *NamespacedObjectReference `json:"secretRef,omitempty"`
54+
SecretRef *commonapi.ObjectReference `json:"secretRef,omitempty"`
5555
}
5656

5757
func (ars AccessRequestStatus) IsGranted() bool {

api/clusters/v1alpha1/cluster_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type ClusterSpec struct {
2020
// ClusterConfigs allows to reference any amount of provider-specific cluster configuration objects.
2121
// The k8s resource kind that is referenced by this depends on the provider (which is defined by the profile).
2222
// +optional
23-
ClusterConfigs []ObjectReference `json:"clusterConfigs,omitempty"`
23+
ClusterConfigs []commonapi.ObjectReference `json:"clusterConfigs,omitempty"`
2424

2525
// Kubernetes configuration for the cluster.
2626
Kubernetes K8sConfiguration `json:"kubernetes,omitempty"`

api/clusters/v1alpha1/clusterprofile_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ package v1alpha1
22

33
import (
44
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
6+
commonapi "github.com/openmcp-project/openmcp-operator/api/common"
57
)
68

79
// ClusterProfileSpec defines the desired state of Provider.
810
type ClusterProfileSpec struct {
911
// ProviderRef is a reference to the ClusterProvider
10-
ProviderRef ObjectReference `json:"providerRef"`
12+
ProviderRef commonapi.ObjectReference `json:"providerRef"`
1113

1214
// ProviderConfigRef is a reference to the provider-specific configuration.
13-
ProviderConfigRef ObjectReference `json:"providerConfigRef"`
15+
ProviderConfigRef commonapi.ObjectReference `json:"providerConfigRef"`
1416

1517
// SupportedVersions are the supported Kubernetes versions.
1618
SupportedVersions []SupportedK8sVersion `json:"supportedVersions"`

api/clusters/v1alpha1/clusterrequest_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type ClusterRequestStatus struct {
2828
// Note that this information needs to be recoverable in case this status is lost, e.g. by adding a back reference in form of a finalizer to the Cluster resource.
2929
// +optional
3030
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="cluster is immutable"
31-
Cluster *NamespacedObjectReference `json:"cluster,omitempty"`
31+
Cluster *commonapi.ObjectReference `json:"cluster,omitempty"`
3232
}
3333

3434
func (crs ClusterRequestStatus) IsGranted() bool {

api/clusters/v1alpha1/shared_types.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,6 @@ func (cc Condition) IsUnknown() bool {
101101
return cc.Status == CONDITION_UNKNOWN
102102
}
103103

104-
type ObjectReference struct {
105-
// Name is the name of the referenced resource.
106-
// +kubebuilder:validation:MinLength=1
107-
Name string `json:"name"`
108-
}
109-
110-
type NamespacedObjectReference struct {
111-
ObjectReference `json:",inline"`
112-
113-
// Namespace is the namespace of the referenced resource.
114-
Namespace string `json:"namespace"`
115-
}
116-
117104
// CommonStatus is a status shared by multiple resource.
118105
// Note that a 'phase' is also part of the status, but it cannot be included in this struct.
119106
// The reason is that we want to use string-like types for the phase, but the goddamn code generation does not support generics, no matter which annotations are added.

api/clusters/v1alpha1/zz_generated.deepcopy.go

Lines changed: 7 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/crds/manifests/clusters.openmcp.cloud_accessrequests.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ spec:
5454
This value is immutable.
5555
properties:
5656
name:
57-
description: Name is the name of the referenced resource.
58-
minLength: 1
57+
description: Name is the name of the object.
5958
type: string
6059
namespace:
61-
description: Namespace is the namespace of the referenced resource.
60+
description: Namespace is the namespace of the object.
6261
type: string
6362
required:
6463
- name
@@ -139,11 +138,10 @@ spec:
139138
This value is immutable.
140139
properties:
141140
name:
142-
description: Name is the name of the referenced resource.
143-
minLength: 1
141+
description: Name is the name of the object.
144142
type: string
145143
namespace:
146-
description: Namespace is the namespace of the referenced resource.
144+
description: Namespace is the namespace of the object.
147145
type: string
148146
required:
149147
- name
@@ -233,11 +231,10 @@ spec:
233231
the actual credentials.
234232
properties:
235233
name:
236-
description: Name is the name of the referenced resource.
237-
minLength: 1
234+
description: Name is the name of the object.
238235
type: string
239236
namespace:
240-
description: Namespace is the namespace of the referenced resource.
237+
description: Namespace is the namespace of the object.
241238
type: string
242239
required:
243240
- name

api/crds/manifests/clusters.openmcp.cloud_clusterprofiles.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,27 @@ spec:
5555
configuration.
5656
properties:
5757
name:
58-
description: Name is the name of the referenced resource.
59-
minLength: 1
58+
description: Name is the name of the object.
59+
type: string
60+
namespace:
61+
description: Namespace is the namespace of the object.
6062
type: string
6163
required:
6264
- name
65+
- namespace
6366
type: object
6467
providerRef:
6568
description: ProviderRef is a reference to the ClusterProvider
6669
properties:
6770
name:
68-
description: Name is the name of the referenced resource.
69-
minLength: 1
71+
description: Name is the name of the object.
72+
type: string
73+
namespace:
74+
description: Namespace is the namespace of the object.
7075
type: string
7176
required:
7277
- name
78+
- namespace
7379
type: object
7480
supportedVersions:
7581
description: SupportedVersions are the supported Kubernetes versions.

api/crds/manifests/clusters.openmcp.cloud_clusterrequests.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,10 @@ spec:
7474
Note that this information needs to be recoverable in case this status is lost, e.g. by adding a back reference in form of a finalizer to the Cluster resource.
7575
properties:
7676
name:
77-
description: Name is the name of the referenced resource.
78-
minLength: 1
77+
description: Name is the name of the object.
7978
type: string
8079
namespace:
81-
description: Namespace is the namespace of the referenced resource.
80+
description: Namespace is the namespace of the object.
8281
type: string
8382
required:
8483
- name

api/crds/manifests/clusters.openmcp.cloud_clusters.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,18 @@ spec:
7474
ClusterConfigs allows to reference any amount of provider-specific cluster configuration objects.
7575
The k8s resource kind that is referenced by this depends on the provider (which is defined by the profile).
7676
items:
77+
description: ObjectReference is a reference to an object in any
78+
namespace.
7779
properties:
7880
name:
79-
description: Name is the name of the referenced resource.
80-
minLength: 1
81+
description: Name is the name of the object.
82+
type: string
83+
namespace:
84+
description: Namespace is the namespace of the object.
8185
type: string
8286
required:
8387
- name
88+
- namespace
8489
type: object
8590
type: array
8691
kubernetes:

0 commit comments

Comments
 (0)