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

View File

@@ -18,4 +18,4 @@ version: 0.1.6
# 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.
# It is recommended to use it with quotes.
appVersion: "0.1.7"
appVersion: "0.1.8"

View File

@@ -95,6 +95,9 @@ spec:
- secretName
- secretNamespace
type: object
resyncInterval:
default: 60
type: integer
tokenSecretReference:
properties:
secretName:
@@ -109,6 +112,7 @@ spec:
type: object
required:
- managedSecretReference
- resyncInterval
type: object
status:
description: InfisicalSecretStatus defines the observed state of InfisicalSecret

View File

@@ -42,6 +42,9 @@ type InfisicalSecretSpec struct {
// +kubebuilder:validation:Required
ManagedSecretReference KubeSecretReference `json:"managedSecretReference"`
// +kubebuilder:default:=60
ResyncInterval int `json:"resyncInterval"`
// Infisical host to pull secrets from
// +kubebuilder:validation:Optional
HostAPI string `json:"hostAPI"`

View File

@@ -95,6 +95,9 @@ spec:
- secretName
- secretNamespace
type: object
resyncInterval:
default: 60
type: integer
tokenSecretReference:
properties:
secretName:
@@ -109,6 +112,7 @@ spec:
type: object
required:
- managedSecretReference
- resyncInterval
type: object
status:
description: InfisicalSecretStatus defines the observed state of InfisicalSecret

View File

@@ -4,6 +4,7 @@ metadata:
name: infisicalsecret-sample
spec:
hostAPI: http://localhost:7070/api
resyncInterval: 60
authentication:
serviceAccount:
serviceAccountSecretReference:

View File

@@ -33,8 +33,8 @@ type InfisicalSecretReconciler struct {
// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.1/pkg/reconcile
func (r *InfisicalSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
requeueTime := time.Minute * 1
var infisicalSecretCR v1alpha1.InfisicalSecret
requeueTime := time.Minute // seconds
err := r.Get(ctx, req.NamespacedName, &infisicalSecretCR)
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
if infisicalSecretCR.GetDeletionTimestamp() != nil {
return ctrl.Result{

View File

@@ -101,6 +101,9 @@ spec:
- secretName
- secretNamespace
type: object
resyncInterval:
default: 60
type: integer
tokenSecretReference:
properties:
secretName:
@@ -115,6 +118,7 @@ spec:
type: object
required:
- managedSecretReference
- resyncInterval
type: object
status:
description: InfisicalSecretStatus defines the observed state of InfisicalSecret