add re-sync interval

This commit is contained in:
Maidul Islam
2023-06-29 15:02:53 -04:00
parent a32df58f46
commit cb5c371a4f
7 changed files with 25 additions and 2 deletions
+1 -1
View File
@@ -18,4 +18,4 @@ version: 0.1.6
# incremented each time you make changes to the application. Versions are not expected to # incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using. # follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes. # It is recommended to use it with quotes.
appVersion: "0.1.7" appVersion: "0.1.8"
@@ -95,6 +95,9 @@ spec:
- secretName - secretName
- secretNamespace - secretNamespace
type: object type: object
resyncInterval:
default: 60
type: integer
tokenSecretReference: tokenSecretReference:
properties: properties:
secretName: secretName:
@@ -109,6 +112,7 @@ spec:
type: object type: object
required: required:
- managedSecretReference - managedSecretReference
- resyncInterval
type: object type: object
status: status:
description: InfisicalSecretStatus defines the observed state of InfisicalSecret description: InfisicalSecretStatus defines the observed state of InfisicalSecret
@@ -42,6 +42,9 @@ type InfisicalSecretSpec struct {
// +kubebuilder:validation:Required // +kubebuilder:validation:Required
ManagedSecretReference KubeSecretReference `json:"managedSecretReference"` ManagedSecretReference KubeSecretReference `json:"managedSecretReference"`
// +kubebuilder:default:=60
ResyncInterval int `json:"resyncInterval"`
// Infisical host to pull secrets from // Infisical host to pull secrets from
// +kubebuilder:validation:Optional // +kubebuilder:validation:Optional
HostAPI string `json:"hostAPI"` HostAPI string `json:"hostAPI"`
@@ -95,6 +95,9 @@ spec:
- secretName - secretName
- secretNamespace - secretNamespace
type: object type: object
resyncInterval:
default: 60
type: integer
tokenSecretReference: tokenSecretReference:
properties: properties:
secretName: secretName:
@@ -109,6 +112,7 @@ spec:
type: object type: object
required: required:
- managedSecretReference - managedSecretReference
- resyncInterval
type: object type: object
status: status:
description: InfisicalSecretStatus defines the observed state of InfisicalSecret description: InfisicalSecretStatus defines the observed state of InfisicalSecret
+1
View File
@@ -4,6 +4,7 @@ metadata:
name: infisicalsecret-sample name: infisicalsecret-sample
spec: spec:
hostAPI: http://localhost:7070/api hostAPI: http://localhost:7070/api
resyncInterval: 60
authentication: authentication:
serviceAccount: serviceAccount:
serviceAccountSecretReference: serviceAccountSecretReference:
@@ -33,8 +33,8 @@ type InfisicalSecretReconciler struct {
// For more details, check Reconcile and its Result here: // For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile // - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
func (r *InfisicalSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { func (r *InfisicalSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
requeueTime := time.Minute * 1
var infisicalSecretCR v1alpha1.InfisicalSecret var infisicalSecretCR v1alpha1.InfisicalSecret
requeueTime := time.Minute // seconds
err := r.Get(ctx, req.NamespacedName, &infisicalSecretCR) err := r.Get(ctx, req.NamespacedName, &infisicalSecretCR)
if err != nil { if err != nil {
@@ -51,6 +51,13 @@ func (r *InfisicalSecretReconciler) Reconcile(ctx context.Context, req ctrl.Requ
} }
} }
if infisicalSecretCR.Spec.ResyncInterval != 0 {
requeueTime = time.Second * time.Duration(infisicalSecretCR.Spec.ResyncInterval)
fmt.Println("Manual re-sync interval set", "requeueAfter", requeueTime)
}
fmt.Println("Requeue duration set", "requeueAfter", requeueTime)
// Check if the resource is already marked for deletion // Check if the resource is already marked for deletion
if infisicalSecretCR.GetDeletionTimestamp() != nil { if infisicalSecretCR.GetDeletionTimestamp() != nil {
return ctrl.Result{ return ctrl.Result{
@@ -101,6 +101,9 @@ spec:
- secretName - secretName
- secretNamespace - secretNamespace
type: object type: object
resyncInterval:
default: 60
type: integer
tokenSecretReference: tokenSecretReference:
properties: properties:
secretName: secretName:
@@ -115,6 +118,7 @@ spec:
type: object type: object
required: required:
- managedSecretReference - managedSecretReference
- resyncInterval
type: object type: object
status: status:
description: InfisicalSecretStatus defines the observed state of InfisicalSecret description: InfisicalSecretStatus defines the observed state of InfisicalSecret