Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
6ad599ce71
|
|||
|
a8f58c13ce
|
|||
|
a1589c8290
|
|||
|
dedee24389
|
@@ -21,6 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"slices"
|
"slices"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
@@ -160,11 +161,16 @@ func (c *ApplicationController) ensureFinalizers(ctx context.Context, app *v1alp
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *ApplicationController) reconcileDelete(ctx context.Context, app *v1alpha1.Application) error {
|
func (c *ApplicationController) reconcileDelete(ctx context.Context, app *v1alpha1.Application) error {
|
||||||
r, err := c.authentik.CoreApi.CoreApplicationsDestroy(ctx, app.Status.PK).Execute()
|
pk, err := strconv.ParseInt(app.Status.PK, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// This handles an edge-case, where when the Application on Authentik has already been deleted, but the finalizer is still present. We just remove the finalizer and return.
|
return fmt.Errorf("error parsing PK: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
r, err := c.authentik.ProvidersApi.ProvidersProxyDestroy(ctx, int32(pk)).Execute()
|
||||||
|
if err != nil {
|
||||||
|
// This handles an edge-case, where when the ProxyProvider on Authentik has already been deleted, but the finalizer is still present. We just remove the finalizer and return.
|
||||||
if r != nil && r.StatusCode != http.StatusNotFound {
|
if r != nil && r.StatusCode != http.StatusNotFound {
|
||||||
return fmt.Errorf("error when calling `CoreAPI.CoreApplicationsDestroy`: %w with response %v", err, r)
|
return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyDestroy`: %w with response %v", err, r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +197,7 @@ func (c *ApplicationController) reconcileUpdate(ctx context.Context, app *v1alph
|
|||||||
}
|
}
|
||||||
resp, r, err := c.authentik.CoreApi.CoreApplicationsPartialUpdate(ctx, app.Spec.Slug).PatchedApplicationRequest(*patchedApplicationRequest).Execute()
|
resp, r, err := c.authentik.CoreApi.CoreApplicationsPartialUpdate(ctx, app.Spec.Slug).PatchedApplicationRequest(*patchedApplicationRequest).Execute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error when calling `CoreAPI.CoreApplicationsPartialUpdate`: %w with response %v", err, r)
|
return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyPartialUpdate`: %w with response %v", err, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Status.PK = resp.Pk
|
app.Status.PK = resp.Pk
|
||||||
|
|||||||
Reference in New Issue
Block a user