Skip to content

Commit

Permalink
Merge pull request #113 from lsviben/stc-condition
Browse files Browse the repository at this point in the history
Add Validated condition to STC
  • Loading branch information
lsviben authored Aug 27, 2024
2 parents aa4f6ab + ea5c6b5 commit 0247a75
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions apis/observability/v1alpha1/telemetry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const SharedTelemetryConfigAnnotation = "spaces.upbound.io/sharedtelemetryconfig
// +kubebuilder:printcolumn:name="Selected",type="string",JSONPath=`.metadata.annotations.sharedtelemetryconfig\.internal\.spaces\.upbound\.io/selected`
// +kubebuilder:printcolumn:name="Failed",type="string",JSONPath=`.metadata.annotations.sharedtelemetryconfig\.internal\.spaces\.upbound\.io/failed`
// +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=`.metadata.annotations.sharedtelemetryconfig\.internal\.spaces\.upbound\.io/provisioned`
// +kubebuilder:printcolumn:name="Validated",type="string",JSONPath=".status.conditions[?(@.type=='Validated')].status"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:resource:scope=Namespaced,categories=observability,shortName=stc

Expand Down Expand Up @@ -145,6 +146,9 @@ const (
// ConditionTypeFailed indicates that the controlplane telemetry
// provisioning has failed.
ConditionTypeFailed xpv1.ConditionType = "Failed"
// ConditionTypeValidated indicates if the telemetry configuration
// is valid.
ConditionTypeValidated xpv1.ConditionType = "Validated"
)

const (
Expand All @@ -154,6 +158,12 @@ const (
// ReasonInvalidConfig indicates that the telemetry configuration is
// invalid.
ReasonInvalidConfig xpv1.ConditionReason = "InvalidTelemetryConfig"
// ReasonValidExportConfig indicates that the telemetry export configuration has
// been tested and is valid.
ReasonValidExportConfig xpv1.ConditionReason = "ValidExportConfig"
// ReasonInvalidExportConfig indicates that the telemetry export configuration has
// been tested and is invalid.
ReasonInvalidExportConfig xpv1.ConditionReason = "InvalidExportConfig"
)

// SelectorConflict returns a condition that indicates the controlplane is
Expand All @@ -180,6 +190,29 @@ func InvalidConfig(msg string) xpv1.Condition {
}
}

// InvalidExportConfig returns a condition that indicates the telemetry export
// configuration is invalid.
func InvalidExportConfig(msg string) xpv1.Condition {
return xpv1.Condition{
Type: ConditionTypeValidated,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonInvalidExportConfig,
Message: msg,
}
}

// ValidExportConfig returns a condition that indicates the telemetry export
// configuration is valid.
func ValidExportConfig() xpv1.Condition {
return xpv1.Condition{
Type: ConditionTypeValidated,
Status: corev1.ConditionTrue,
LastTransitionTime: metav1.Now(),
Reason: ReasonValidExportConfig,
}
}

var (
// SharedTelemetryConfigKind is the kind of a SharedTelemetryConfig.
SharedTelemetryConfigKind = reflect.TypeOf(SharedTelemetryConfig{}).Name()
Expand Down

0 comments on commit 0247a75

Please sign in to comment.