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 condition status to SharedSecretStoreStatus #106

Merged
merged 2 commits into from
Aug 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
66 changes: 66 additions & 0 deletions apis/spaces/v1alpha1/secretstore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ package v1alpha1
import (
"reflect"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
corev1 "k8s.io/api/core/v1"

esv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -100,6 +103,67 @@ type SharedSecretStoreSpec struct {
RefreshInterval int `json:"refreshInterval,omitempty"`
}

const (
// ConditionSecretRefReady indicates the status of any referenced secrets
// for API objects that reference a secret.
ConditionSecretRefReady = xpv1.ConditionType("SecretRefsReady")
)

const (
// ReasonSecretRefMissing is added to object if the referenced secret(s) do not exist
ReasonSecretRefMissing = xpv1.ConditionReason("ReferencedSecretNotFound")
// ReasonSecretRefMissingKey is added when the object if the secret(s) exists, but the key data is missing
ReasonSecretRefMissingKey = xpv1.ConditionReason("ReferencedSecretKeyNotFound")
// ReasonSecretRefReady is added when the referenced secret(s) and data are found
ReasonSecretRefReady = xpv1.ConditionReason("ReferencedSecretsReady")
// ReasonSecretRefNone is added when object does not reference a secret
ReasonSecretRefNone = xpv1.ConditionReason("NoReferencedSecrets")
)

// SecretRefsReadyMissing returns a condition indicating that the referenced
// secret(s) do not exist.
func SecretRefsReadyMissing() xpv1.Condition {
return xpv1.Condition{
Type: ConditionSecretRefReady,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonSecretRefMissing,
}
}

// SecretRefsReadyMissingKey returns a condition indicating that the referenced
// secret(s) exist, but the key data is missing.
func SecretRefsReadyMissingKey() xpv1.Condition {
return xpv1.Condition{
Type: ConditionSecretRefReady,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonSecretRefMissingKey,
}
}

// SecretRefsReadyReady returns a condition indicating that the referenced
// secret(s) and data are found.
func SecretRefsReadyReady() xpv1.Condition {
return xpv1.Condition{
Type: ConditionSecretRefReady,
Status: corev1.ConditionTrue,
LastTransitionTime: metav1.Now(),
Reason: ReasonSecretRefReady,
}
}

// SecretRefsReadyNone returns a condition indicating that the referenced
// object is not a secret.
func SecretRefsReadyNone() xpv1.Condition {
return xpv1.Condition{
Type: ConditionSecretRefReady,
Status: corev1.ConditionFalse,
LastTransitionTime: metav1.Now(),
Reason: ReasonSecretRefNone,
}
}

// SharedSecretStoreStatus defines the observed state of the SecretStore.
type SharedSecretStoreStatus struct {

Expand All @@ -123,6 +187,8 @@ type SharedSecretStoreStatus struct {
// +listType=map
// +listMapKey=controlPlane
Provisioned []SecretStoreProvisioningSuccess `json:"provisioned,omitempty"`

xpv1.ResourceStatus `json:",inline"`
}

// SecretStoreProvisioningFailure defines secret store provisioning failure.
Expand Down
1 change: 1 addition & 0 deletions apis/spaces/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading