Skip to content

Commit

Permalink
fix: cleanup oauth logins when parent object is deleted
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Nov 15, 2024
1 parent 75e9ef3 commit c7e39e2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/storage/apis/otto.otto8.ai/v1/oauthapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/otto8-ai/nah/pkg/fields"
"github.com/otto8-ai/otto8/apiclient/types"
"github.com/otto8-ai/otto8/pkg/system"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -154,6 +155,11 @@ func (o *OAuthAppLogin) FieldNames() []string {
}

func (o *OAuthAppLogin) DeleteRefs() []Ref {
if system.IsAgentID(o.Spec.CredentialContext) {
return []Ref{{ObjType: new(Agent), Name: o.Spec.CredentialContext}}
} else if system.IsWorkflowID(o.Spec.CredentialContext) {
return []Ref{{ObjType: new(Workflow), Name: o.Spec.CredentialContext}}
}
return nil
}

Expand Down

0 comments on commit c7e39e2

Please sign in to comment.