Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion pkg/codefresh/git-source.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (

type (
IGitSourceAPI interface {
List(ctc context.Context, runtimeName string) ([]model.GitSource, error)
List(ctx context.Context, runtimeName string) ([]model.GitSource, error)
Delete(ctx context.Context, runtimeName string, name string) error
}

gitSource struct {
Expand All @@ -22,6 +23,10 @@ type (
}
Errors []graphqlError
}

graphQlDeleteGitSourceResponse struct {
Errors []graphqlError
}
)

func newGitSourceAPI(codefresh *codefresh) IGitSourceAPI {
Expand Down Expand Up @@ -72,3 +77,29 @@ func (g *gitSource) List(ctx context.Context, runtimeName string) ([]model.GitSo

return gitSources, nil
}

func (g *gitSource) Delete(ctx context.Context, runtimeName string, name string) error {
jsonData := map[string]interface{}{
"query": `
mutation RemoveGitSource($runtime: String, $name: String) {
removeGitSource(runtime: $runtime, name: $name)
}
`,
"variables": map[string]interface{}{
"runtime": runtimeName,
"name": name,
},
}

res := graphQlDeleteGitSourceResponse{}
err := g.codefresh.graphqlAPI(ctx, jsonData, res)
if err != nil {
return fmt.Errorf("failed making a graphql API call to removeGitSource: %w", err)
}

if len(res.Errors) > 0 {
return graphqlErrorResponse{errors: res.Errors}
}

return nil
}