Skip to content

Commit

Permalink
[GEN-1541] Add delete action mutation (#1609)
Browse files Browse the repository at this point in the history
This pull request introduces changes to the `DeleteAction` functionality
in the `frontend/graph` package, adding support for an `actionType`
parameter. This enhancement allows for more specific handling of
different action types during deletion.

Key changes include:

### GraphQL Schema and Resolvers

*
[`frontend/graph/schema.graphqls`](diffhunk://#diff-bc07b91dedd1782d9ddbbb6374ad97c7604f9a267de5174645723d863c732f80L314-R314):
Updated the `deleteAction` mutation to include an `actionType`
parameter.
*
[`frontend/graph/schema.resolvers.go`](diffhunk://#diff-8e6e95029056db2c0301fc338e0ca5a04356ce5d45ee9514bbd167f2d85bae70L603-R620):
Modified the `DeleteAction` resolver to handle different action types
based on the `actionType` parameter.

### Generated Code

*
[`frontend/graph/generated.go`](diffhunk://#diff-4bacf1f13939a5c243f3f83d21f4560b331d13667d81ea5945ed1f57ddb205f2L200-R200):
Updated the `DeleteAction` method signatures and complexity calculations
to include the `actionType` parameter.
[[1]](diffhunk://#diff-4bacf1f13939a5c243f3f83d21f4560b331d13667d81ea5945ed1f57ddb205f2L200-R200)
[[2]](diffhunk://#diff-4bacf1f13939a5c243f3f83d21f4560b331d13667d81ea5945ed1f57ddb205f2L266-R266)
[[3]](diffhunk://#diff-4bacf1f13939a5c243f3f83d21f4560b331d13667d81ea5945ed1f57ddb205f2L911-R911)
[[4]](diffhunk://#diff-4bacf1f13939a5c243f3f83d21f4560b331d13667d81ea5945ed1f57ddb205f2R1342-R1350)
[[5]](diffhunk://#diff-4bacf1f13939a5c243f3f83d21f4560b331d13667d81ea5945ed1f57ddb205f2L5793-R5802)

### Action Services

*
[`frontend/services/actions/addclusterinfo.go`](diffhunk://#diff-c2da2861415e61f772e3b44d22810aa34b4eba6070f744709c4b1b6b919a3f09R148-R162):
Added the `DeleteAddClusterInfo` function to handle the deletion of
`AddClusterInfo` actions.
*
[`frontend/services/actions/addclusterinfo.go`](diffhunk://#diff-c2da2861415e61f772e3b44d22810aa34b4eba6070f744709c4b1b6b919a3f09R13):
Imported `apierrors` for error handling in the new deletion function.
  • Loading branch information
alonkeyval authored Oct 22, 2024
1 parent d456363 commit f435deb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
17 changes: 13 additions & 4 deletions frontend/graph/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/graph/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -311,5 +311,5 @@ type Mutation {

createAction(action: ActionInput!): Action!
updateAction(id: ID!, action: ActionInput!): Action!
deleteAction(id: ID!): Boolean!
deleteAction(id: ID!, actionType: String!): Boolean!
}
20 changes: 18 additions & 2 deletions frontend/graph/schema.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions frontend/services/actions/addclusterinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/odigos-io/odigos/frontend/graph/model"
"github.com/odigos-io/odigos/frontend/kube"
"github.com/odigos-io/odigos/frontend/services"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -144,3 +145,18 @@ func UpdateAddClusterInfo(ctx context.Context, id string, action model.ActionInp

return response, nil
}

func DeleteAddClusterInfo(ctx context.Context, id string) error {
odigosns := consts.DefaultOdigosNamespace

// Delete the action by its ID from Kubernetes
err := kube.DefaultClient.ActionsClient.AddClusterInfos(odigosns).Delete(ctx, id, metav1.DeleteOptions{})
if err != nil {
if apierrors.IsNotFound(err) {
return fmt.Errorf("AddClusterInfo action with ID %s not found", id)
}
return fmt.Errorf("failed to delete AddClusterInfo action: %v", err)
}

return nil
}

0 comments on commit f435deb

Please sign in to comment.