Skip to content

Commit

Permalink
chore: [chaoscenter]: Added git ops functionality in experiment handl…
Browse files Browse the repository at this point in the history
…ers (#4446)

* chore: [chaoscenter]: Added git ops functionality in experiment handlers

Signed-off-by: Amit Kumar Das <[email protected]>

* chore: [chaoscenter]: Gofmt fix

Signed-off-by: Amit Kumar Das <[email protected]>

* go mod tidy

Signed-off-by: Amit Kumar Das <[email protected]>

---------

Signed-off-by: Amit Kumar Das <[email protected]>
Co-authored-by: Sarthak Jain <[email protected]>
Co-authored-by: Saranya Jena <[email protected]>
  • Loading branch information
3 people authored Mar 13, 2024
1 parent 731bdc4 commit 6f24d44
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion chaoscenter/graphql/server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ require (
github.com/goccy/go-json v0.10.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
Expand Down
3 changes: 1 addition & 2 deletions chaoscenter/graphql/server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,8 @@ github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4=
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk=
github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6/go.mod h1:DbHgvLiFKX1Sh2T1w8Q/h4NAI8MHIpzCdnBUDTXU3I0=
Expand Down
10 changes: 10 additions & 0 deletions chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ func (c *ChaosExperimentHandler) DeleteChaosExperiment(ctx context.Context, proj
return false, err
}
}
wf := model.ChaosExperimentRequest{
ExperimentID: &workflow.ExperimentID,
ExperimentName: workflow.Name,
}

err = c.gitOpsService.DeleteExperimentFromGit(ctx, projectID, &wf)
if err != nil {
logrus.Errorf("error deleting experiment manifest from git, err: %v", err)
return false, err
}
// Delete experiment
err = c.chaosExperimentService.ProcessExperimentDelete(query, workflow, uid, r)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion chaoscenter/graphql/server/pkg/gitops/gitops.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (c GitConfig) GitGetStatus() (bool, error) {
return status.IsClean(), nil
}

// getRepositoryWorktreeReference returns the git.Repository and git.Worktree instanes for the repo
// getRepositoryWorktreeReference returns the git.Repository and git.Worktree instances for the repo
func (c GitConfig) getRepositoryWorktreeReference() (*git.Repository, *git.Worktree, error) {
repo, err := git.PlainOpen(c.LocalPath)
if err != nil {
Expand Down

0 comments on commit 6f24d44

Please sign in to comment.