mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-09 00:09:43 +00:00
irsa Status Management
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package v1alpha1
|
||||
|
||||
const (
|
||||
// ReadyCondition indicates the resource is ready and fully reconciled.
|
||||
// If the Condition is False, the resource SHOULD be considered to be in the process of reconciling and not a
|
||||
// representation of actual state.
|
||||
ReadyCondition string = "Ready"
|
||||
)
|
||||
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
@@ -55,12 +56,47 @@ type IamRole struct {
|
||||
|
||||
// IRSAStatus defines the observed state of IRSA
|
||||
type IRSAStatus struct {
|
||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||
// Important: Run "make" to regenerate code after modifying this file
|
||||
Conditions []metav1.Condition `json:"conditions,omitempty"`
|
||||
}
|
||||
|
||||
// GetIRSAStatusConditions returns a pointer to the Status.Conditions slice
|
||||
func (in *IRSA) GetIRSAStatusConditions() *[]metav1.Condition {
|
||||
return &in.Status.Conditions
|
||||
}
|
||||
|
||||
func IRSAStatusReady(irsa IRSA, reason, message string) IRSA {
|
||||
newCondition := metav1.Condition{
|
||||
Type: ReadyCondition,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: reason,
|
||||
Message: message,
|
||||
}
|
||||
apimeta.SetStatusCondition(irsa.GetIRSAStatusConditions(), newCondition)
|
||||
return irsa
|
||||
}
|
||||
|
||||
func IRSAStatusNotReady(irsa IRSA, reason, message string) IRSA {
|
||||
newCondition := metav1.Condition{
|
||||
Type: ReadyCondition,
|
||||
Status: metav1.ConditionFalse,
|
||||
Reason: reason,
|
||||
Message: message,
|
||||
}
|
||||
apimeta.SetStatusCondition(irsa.GetIRSAStatusConditions(), newCondition)
|
||||
return irsa
|
||||
}
|
||||
|
||||
type IRSAReason string
|
||||
|
||||
const (
|
||||
IRSAReasonFailedRoleUpdate IRSAReason = "IRSAFailedRoleUpdate"
|
||||
IRSAReasonFailedK8sApply IRSAReason = "IRSAFailedApplyingResources"
|
||||
IRSAReasonReady IRSAReason = "IRSAReady"
|
||||
)
|
||||
|
||||
//+kubebuilder:object:root=true
|
||||
//+kubebuilder:subresource:status
|
||||
//+kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
|
||||
|
||||
// IRSA is the Schema for the irsas API
|
||||
type IRSA struct {
|
||||
|
||||
@@ -17,7 +17,6 @@ limitations under the License.
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
@@ -81,14 +80,14 @@ type IRSASetupStatus struct {
|
||||
SelfHostedSetup []metav1.Condition `json:"selfHostedSetup,omitempty"`
|
||||
}
|
||||
|
||||
// GetStatusConditions returns a pointer to the Status.Conditions slice
|
||||
// GetSelfhostedStatusConditions returns a pointer to the Status.Conditions slice
|
||||
func (in *IRSASetup) GetSelfhostedStatusConditions() *[]metav1.Condition {
|
||||
return &in.Status.SelfHostedSetup
|
||||
}
|
||||
|
||||
func SetupSelfHostedStatusReady(irsa IRSASetup, reason, message string) IRSASetup {
|
||||
newCondition := metav1.Condition{
|
||||
Type: meta.ReadyCondition,
|
||||
Type: ReadyCondition,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: reason,
|
||||
Message: message,
|
||||
@@ -99,7 +98,7 @@ func SetupSelfHostedStatusReady(irsa IRSASetup, reason, message string) IRSASetu
|
||||
|
||||
func SelfHostedStatusNotReady(irsa IRSASetup, reason, message string) IRSASetup {
|
||||
newCondition := metav1.Condition{
|
||||
Type: meta.ReadyCondition,
|
||||
Type: ReadyCondition,
|
||||
Status: metav1.ConditionFalse,
|
||||
Reason: reason,
|
||||
Message: message,
|
||||
@@ -110,7 +109,7 @@ func SelfHostedStatusNotReady(irsa IRSASetup, reason, message string) IRSASetup
|
||||
|
||||
// SelfHostedReadyStatus
|
||||
func SelfHostedReadyStatus(irsa IRSASetup) *metav1.Condition {
|
||||
if c := apimeta.FindStatusCondition(irsa.Status.SelfHostedSetup, meta.ReadyCondition); c != nil {
|
||||
if c := apimeta.FindStatusCondition(irsa.Status.SelfHostedSetup, ReadyCondition); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
@@ -130,7 +129,7 @@ func HasConditionReason(cond *metav1.Condition, reasons ...string) bool {
|
||||
}
|
||||
|
||||
func IsSelfHostedReadyConditionTrue(irsa IRSASetup) bool {
|
||||
return apimeta.IsStatusConditionTrue(irsa.Status.SelfHostedSetup, meta.ReadyCondition)
|
||||
return apimeta.IsStatusConditionTrue(irsa.Status.SelfHostedSetup, ReadyCondition)
|
||||
}
|
||||
|
||||
type SelfHostedReason string
|
||||
|
||||
@@ -63,7 +63,7 @@ func (in *IRSA) DeepCopyInto(out *IRSA) {
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
out.Status = in.Status
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IRSA.
|
||||
@@ -259,6 +259,13 @@ func (in *IRSASpec) DeepCopy() *IRSASpec {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IRSAStatus) DeepCopyInto(out *IRSAStatus) {
|
||||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]v1.Condition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IRSAStatus.
|
||||
|
||||
Reference in New Issue
Block a user