func (r *EncryptionKeysReconciler) rotateKey(ctx context.Context, secret *corev1.Secret) error {
	newKey, err := propagator.GenerateEncryptionKey()
	if err != nil {
		return err
	}

	secret.Data["previousKey"] = secret.Data["key"]
	secret.Data["key"] = newKey

	annotations := secret.GetAnnotations()
	if annotations == nil {
		annotations = map[string]string{}
	}

	lastRotatedTS := time.Now().UTC().Format(time.RFC3339)
	annotations[propagator.LastRotatedAnnotation] = lastRotatedTS
	secret.SetAnnotations(annotations)

	return r.Update(ctx, secret)
}
// rotateKey will generate a new encryption key to replace the "key" field/key on the Secret. The
// old key is stored as the "previousKey" field/key on the Secret. The Secret is then updated
// with the Kubernetes API server. An error is returned if the key can't be generated or the
// update on the API servier fails.
rotateKey will generate a new encryption key to replace the "key" field/key on the Secret. The
old key is stored as the "previousKey" field/key on the Secret. The Secret is then updated
with the Kubernetes API server. An error is returned if the key can't be generated or the
update on the API servier fails.
// rotateKey will generate a new encryption key to replace the " key " field / key on the Secret . The // old key is stored as the " previousKey " field / key on the Secret . The Secret is then updated // with the Kubernetes API server . An error is returned if the key can ' t be generated or the // update on the API servier fails .
func (r *EncryptionKeysReconciler) rotateKey(ctx context.Context, secret *corev1.Secret) error {
	newKey, err := propagator.GenerateEncryptionKey()
	if err != nil {
		return err
	}
	secret.Data["previousKey"] = secret.Data["key"]
	secret.Data["key"] = newKey
	annotations := secret.GetAnnotations()
	if annotations == nil {
		annotations = map[string]string{}
	}
	lastRotatedTS := time.Now().UTC().Format(time.RFC3339)
	annotations[propagator.LastRotatedAnnotation] = lastRotatedTS
	secret.SetAnnotations(annotations)
	return r.Update(ctx, secret)
}
func ( r * EncryptionKeysReconciler ) rotateKey ( ctx context . Context , secret * corev1 . Secret ) error { newKey , err := propagator . GenerateEncryptionKey ( ) if err != nil { return err } secret . Data [ " " ] = secret . Data [ " " ] secret . Data [ " " ] = newKey annotations := secret . GetAnnotations ( ) if annotations == nil { annotations = map [ string ] string { } } lastRotatedTS := time . Now ( ) . UTC ( ) . Format ( time . RFC3339 ) annotations [ propagator . LastRotatedAnnotation ] = lastRotatedTS secret . SetAnnotations ( annotations ) return r . Update ( ctx , secret ) }
rotateKey will generate a new encryption key to replace the "key" field/key on the Secret.
rotateKey will generate a new encryption key to replace the " key " field / key on the Secret .