From 792dd0914826d3b84eed8a681e13340c60771222 Mon Sep 17 00:00:00 2001 From: Eti Zaguri Date: Thu, 8 Dec 2022 12:37:22 +0200 Subject: [PATCH] CR-15158 (#449) * CR-15158 * wip --- VERSION | 2 +- pkg/codefresh/argo_runtime.go | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 84767f2..fdbbf17 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.50.0 \ No newline at end of file +0.51.0 \ No newline at end of file diff --git a/pkg/codefresh/argo_runtime.go b/pkg/codefresh/argo_runtime.go index 1b6a046..4e480d4 100644 --- a/pkg/codefresh/argo_runtime.go +++ b/pkg/codefresh/argo_runtime.go @@ -16,6 +16,7 @@ type ( Delete(ctx context.Context, runtimeName string) (int, error) DeleteManaged(ctx context.Context, runtimeName string) (int, error) SetSharedConfigRepo(ctx context.Context, suggestedSharedConfigRepo string) (string, error) + ResetSharedConfigRepo(ctx context.Context) error } argoRuntime struct { @@ -64,13 +65,16 @@ type ( Errors []graphqlError } - graphQlSuggestIscRepoResponse struct { Data struct { SuggestIscRepo string } Errors []graphqlError } + + graphQlResetIscRepoResponse struct { + Errors []graphqlError + } ) func newArgoRuntimeAPI(codefresh *codefresh) IRuntimeAPI { @@ -314,3 +318,24 @@ func (r *argoRuntime) SetSharedConfigRepo(ctx context.Context, suggestedSharedCo return res.Data.SuggestIscRepo, nil } + +func (r *argoRuntime) ResetSharedConfigRepo(ctx context.Context) error { + jsonData := map[string]interface{}{ + "query": ` + mutation resetIscRepo { + resetIscRepo + } + `} + + res := &graphQlResetIscRepoResponse{} + err := r.codefresh.graphqlAPI(ctx, jsonData, res) + + if err != nil { + fmt.Errorf("failed making a graphql API call while resetting shared config repo: %w", err) + } + + if len(res.Errors) > 0 { + return graphqlErrorResponse{errors: res.Errors} + } + return nil +}