Skip to content

Commit 1293e05

Browse files
Merge pull request #404 from ARichman555/refresh-cache
Refresh the cached client when the issuer is updated
2 parents d7fa4e8 + 5493298 commit 1293e05

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

pkg/aws/pca.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ func ClearProvisioners() {
141141
collection.Clear()
142142
}
143143

144+
// DeleteProvisioner will remove a provisioner if it already exists
145+
func DeleteProvisioner(ctx context.Context, client client.Client, name types.NamespacedName) {
146+
_, exists := collection.Load(name)
147+
if exists {
148+
collection.Delete(name)
149+
}
150+
}
151+
144152
// GetProvisioner gets a provisioner that has previously been stored or creates a new one
145153
func GetProvisioner(ctx context.Context, client client.Client, name types.NamespacedName, spec *api.AWSPCAIssuerSpec) (GenericProvisioner, error) {
146154
value, _ := collection.Load(name)

pkg/aws/pca_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ func TestProvisonerOperation(t *testing.T) {
246246
output, err := GetProvisioner(context.TODO(), fakeClient, types.NamespacedName{Namespace: "ns1", Name: "issuer1"}, issSpec)
247247
assert.Equal(t, output, provisioner)
248248
assert.Equal(t, err, nil)
249+
250+
DeleteProvisioner(context.TODO(), fakeClient, types.NamespacedName{Namespace: "ns1", Name: "issuer1"})
251+
output, err = GetProvisioner(context.TODO(), fakeClient, types.NamespacedName{Namespace: "ns1", Name: "issuer1"}, issSpec)
252+
assert.NotEqual(t, output, provisioner)
253+
assert.Equal(t, err, nil)
249254
}
250255

251256
func TestPCATemplateArn(t *testing.T) {

pkg/controllers/genericissuer_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func (r *GenericIssuerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
7272
return ctrl.Result{}, err
7373
}
7474

75+
awspca.DeleteProvisioner(ctx, r.Client, req.NamespacedName)
7576
cfg, err := awspca.GetConfig(ctx, r.Client, spec)
7677
if err != nil {
7778
log.Error(err, "Error loading config")

0 commit comments

Comments
 (0)