Skip to content

Commit d72589e

Browse files
authored
feat: add common api package (#79)
* add common api package with reference and status types * add constants for ClusterRequest and AccessRequest phases
1 parent 76041b4 commit d72589e

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

api/clusters/v1alpha1/accessrequest_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import (
55
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
66
)
77

8+
const (
9+
// AccessRequestPending is the phase if the AccessRequest has not been scheduled yet.
10+
AccessRequestPending = "Pending"
11+
// AccessRequestGranted is the phase if the AccessRequest has been granted.
12+
AccessRequestGranted = "Granted"
13+
)
14+
815
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.clusterRef) || has(self.clusterRef)", message="clusterRef may not be removed once set"
916
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.requestRef) || has(self.requestRef)", message="requestRef may not be removed once set"
1017
type AccessRequestSpec struct {

api/clusters/v1alpha1/clusterrequest_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import (
44
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
55
)
66

7+
const (
8+
// ClusterRequestPending is the phase if the ClusterRequest has not been scheduled yet.
9+
ClusterRequestPending = "Pending"
10+
// ClusterRequestScheduled is the phase if the ClusterRequest has been scheduled.
11+
ClusterRequestScheduled = "Scheduled"
12+
)
13+
714
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="spec is immutable"
815
type ClusterRequestSpec struct {
916
// Purpose is the purpose of the requested cluster.

api/common/reference_types.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package common
2+
3+
import (
4+
corev1 "k8s.io/api/core/v1"
5+
apimachinery "k8s.io/apimachinery/pkg/types"
6+
)
7+
8+
// ObjectReference is a reference to an object in any namespace.
9+
type ObjectReference apimachinery.NamespacedName
10+
11+
// LocalObjectReference is a reference to an object in the same namespace as the resource referencing it.
12+
type LocalObjectReference corev1.LocalObjectReference
13+
14+
// SecretReference is a reference to a secret in any namespace with a key.
15+
type SecretReference struct {
16+
ObjectReference `json:",inline"`
17+
// Key is the key in the secret to use.
18+
Key string `json:"key"`
19+
}
20+
21+
// LocalSecretReference is a reference to a secret in the same namespace as the resource referencing it with a key.
22+
type LocalSecretReference struct {
23+
LocalObjectReference `json:",inline"`
24+
// Key is the key in the secret to use.
25+
Key string `json:"key"`
26+
}

api/common/status_types.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package common
2+
3+
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4+
5+
const (
6+
// StatusPhaseReady indicates that the resource is ready. All conditions are met and are in status "True".
7+
StatusPhaseReady = "Ready"
8+
// StatusPhaseProgressing indicates that the resource is not ready and being created or updated. At least one condition is not met and is in status "False".
9+
StatusPhaseProgressing = "Progressing"
10+
// StatusPhaseTerminating indicates that the resource is not ready and in deletion. At least one condition is not met and is in status "False".
11+
StatusPhaseTerminating = "Terminating"
12+
)
13+
14+
// Status represents the status of an openMCP resource.
15+
type Status struct {
16+
// ObservedGeneration is the generation of this resource that was last reconciled by the controller.
17+
ObservedGeneration int64 `json:"observedGeneration"`
18+
19+
// Phase is the current phase of the resource.
20+
Phase string `json:"phase"`
21+
22+
// Conditions contains the conditions.
23+
// +optional
24+
Conditions []metav1.Condition `json:"conditions,omitempty"`
25+
}

0 commit comments

Comments
 (0)