Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Validated condition to STC #113

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading