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

Export status condition constants #15

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions api/v1alpha1/dependencyrequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
ConditionTypeReady string = "Ready"
)

type KrakenResourceDependency struct {
Kind string `json:"kind,omitempty"`
Name string `json:"name,omitempty"`
Expand Down
22 changes: 10 additions & 12 deletions internal/controller/dependencyrequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ import (
const (
configMapDependenciesField string = ".spec.configMapDependencies"
krakenResourceDependenciesField string = ".spec.krakenResourceDependenciesField"

conditionTypeReady string = "Ready"
)

// DependencyRequestReconciler reconciles a DependencyRequest object
Expand Down Expand Up @@ -92,7 +90,7 @@ func (r *DependencyRequestReconciler) Reconcile(ctx context.Context, req ctrl.Re
meta.SetStatusCondition(
&dependencyRequest.Status.Conditions,
metav1.Condition{
Type: conditionTypeReady,
Type: v1alpha1.ConditionTypeReady,
Status: metav1.ConditionUnknown,
Reason: "Reconciling",
Message: "Initial reconciliation",
Expand Down Expand Up @@ -130,7 +128,7 @@ func (r *DependencyRequestReconciler) Reconcile(ctx context.Context, req ctrl.Re
meta.SetStatusCondition(
&dependencyRequest.Status.Conditions,
metav1.Condition{
Type: conditionTypeReady,
Type: v1alpha1.ConditionTypeReady,
Status: metav1.ConditionFalse,
Reason: "ConfigMapNotPresent",
Message: fmt.Sprintf("ConfigMap %s does not exist", cmDep.Name),
Expand All @@ -142,7 +140,7 @@ func (r *DependencyRequestReconciler) Reconcile(ctx context.Context, req ctrl.Re
meta.SetStatusCondition(
&dependencyRequest.Status.Conditions,
metav1.Condition{
Type: conditionTypeReady,
Type: v1alpha1.ConditionTypeReady,
Status: metav1.ConditionFalse,
Reason: "ErrorFetchingConfigMap",
Message: fmt.Sprintf("An error occurred fetching ConfigMap %s: %s", cmDep.Name, err),
Expand All @@ -159,7 +157,7 @@ func (r *DependencyRequestReconciler) Reconcile(ctx context.Context, req ctrl.Re
meta.SetStatusCondition(
&dependencyRequest.Status.Conditions,
metav1.Condition{
Type: conditionTypeReady,
Type: v1alpha1.ConditionTypeReady,
Status: metav1.ConditionFalse,
Reason: "ConfigMapKeyNotPresent",
Message: fmt.Sprintf("ConfigMap %s does not contain key %s", cmDep.Name, cmDep.Key),
Expand Down Expand Up @@ -199,7 +197,7 @@ func (r *DependencyRequestReconciler) Reconcile(ctx context.Context, req ctrl.Re
meta.SetStatusCondition(
&dependencyRequest.Status.Conditions,
metav1.Condition{
Type: conditionTypeReady,
Type: v1alpha1.ConditionTypeReady,
Status: metav1.ConditionFalse,
Reason: "StateDeclarationNotPresent",
Message: fmt.Sprintf("StateDeclaration %s does not exist", sdName),
Expand All @@ -211,7 +209,7 @@ func (r *DependencyRequestReconciler) Reconcile(ctx context.Context, req ctrl.Re
meta.SetStatusCondition(
&dependencyRequest.Status.Conditions,
metav1.Condition{
Type: conditionTypeReady,
Type: v1alpha1.ConditionTypeReady,
Status: metav1.ConditionFalse,
Reason: "ErrorFetchingStateDeclaration",
Message: fmt.Sprintf("An error occurred fetching StateDeclaration %s: %s", sdName, err),
Expand All @@ -228,7 +226,7 @@ func (r *DependencyRequestReconciler) Reconcile(ctx context.Context, req ctrl.Re
meta.SetStatusCondition(
&dependencyRequest.Status.Conditions,
metav1.Condition{
Type: conditionTypeReady,
Type: v1alpha1.ConditionTypeReady,
Status: metav1.ConditionFalse,
Reason: "JSONParseError",
Message: fmt.Sprintf("Path \"%s\" does not exist in StateDeclaration %s", krDep.Path, sdName),
Expand All @@ -245,7 +243,7 @@ func (r *DependencyRequestReconciler) Reconcile(ctx context.Context, req ctrl.Re
meta.SetStatusCondition(
&dependencyRequest.Status.Conditions,
metav1.Condition{
Type: conditionTypeReady,
Type: v1alpha1.ConditionTypeReady,
Status: metav1.ConditionFalse,
Reason: "PathDoesNotExist",
Message: fmt.Sprintf("Path \"%s\" does not exist in StateDeclaration %s", krDep.Path, sdName),
Expand All @@ -268,7 +266,7 @@ func (r *DependencyRequestReconciler) Reconcile(ctx context.Context, req ctrl.Re
meta.SetStatusCondition(
&dependencyRequest.Status.Conditions,
metav1.Condition{
Type: conditionTypeReady,
Type: v1alpha1.ConditionTypeReady,
Status: metav1.ConditionFalse,
Reason: "TypeMismatch",
Message: fmt.Sprintf("Expected type \"%s\" does not match type \"%s\"", krDep.ReflectKind.String(), actualKind.String()),
Expand Down Expand Up @@ -298,7 +296,7 @@ func (r *DependencyRequestReconciler) Reconcile(ctx context.Context, req ctrl.Re
meta.SetStatusCondition(
&dependencyRequest.Status.Conditions,
metav1.Condition{
Type: conditionTypeReady,
Type: v1alpha1.ConditionTypeReady,
Status: metav1.ConditionTrue,
Reason: "Reconciled",
Message: "Successfully retrieved all dependent values",
Expand Down
Loading