Skip to content

Commit 349f26e

Browse files
authored
CR-18009 - added updateCsdpSettings mutation (#454)
* updated version to `0.56.0`
1 parent 249208a commit 349f26e

File tree

7 files changed

+86
-70
lines changed

7 files changed

+86
-70
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.55.0
1+
0.56.0

pkg/codefresh/account_v2.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package codefresh
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
8+
)
9+
10+
type (
11+
IAccountV2API interface {
12+
UpdateCsdpSettings(ctx context.Context, gitProvider platmodel.GitProviders, gitApiUrl, sharedConfigRepo string) error
13+
}
14+
15+
accountV2 struct {
16+
codefresh *codefresh
17+
}
18+
)
19+
20+
func newAccountV2API(codefresh *codefresh) IAccountV2API {
21+
return &accountV2{codefresh: codefresh}
22+
}
23+
24+
func (c *accountV2) UpdateCsdpSettings(ctx context.Context, gitProvider platmodel.GitProviders, gitApiUrl, sharedConfigRepo string) error {
25+
jsonData := map[string]interface{}{
26+
"query": `
27+
mutation updateCsdpSettings($gitProvider: GitProviders!, $gitApiUrl: String!, $sharedConfigRepo: String!) {
28+
updateCsdpSettings(gitProvider: $gitProvider, gitApiUrl: $gitApiUrl, sharedConfigRepo: $sharedConfigRepo)
29+
}
30+
`,
31+
"variables": map[string]interface{}{
32+
"gitProvider": gitProvider,
33+
"gitApiUrl": gitApiUrl,
34+
"sharedConfigRepo": sharedConfigRepo,
35+
},
36+
}
37+
res := &graphqlVoidResponse{}
38+
err := c.codefresh.graphqlAPI(ctx, jsonData, res)
39+
if err != nil {
40+
return fmt.Errorf("failed making a graphql API call to update csdp settings: %w", err)
41+
}
42+
43+
if len(res.Errors) > 0 {
44+
return graphqlErrorResponse{errors: res.Errors}
45+
}
46+
47+
return nil
48+
}

pkg/codefresh/ap_clusters.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,19 @@ import (
88
type (
99
IAppProxyClustersAPI interface {
1010
CreateArgoRollouts(ctx context.Context, server string, namespace string) error
11-
Delete(ctx context.Context, server string, runtime string) error
11+
Delete(ctx context.Context, server string, runtime string) error
1212
}
1313

1414
appProxyClusters struct {
1515
codefresh *codefresh
1616
}
17-
18-
graphqlClusterResponse struct {
19-
Errors []graphqlError
20-
}
2117
)
2218

2319
func newAppProxyClustersAPI(c *codefresh) IAppProxyClustersAPI {
2420
return &appProxyClusters{codefresh: c}
2521
}
2622

27-
func (c *appProxyClusters)CreateArgoRollouts(ctx context.Context, server string, namespace string) error {
23+
func (c *appProxyClusters) CreateArgoRollouts(ctx context.Context, server string, namespace string) error {
2824
jsonData := map[string]interface{}{
2925
"query": `
3026
mutation createArgoRollouts($args: CreateArgoRolloutsInput!) {
@@ -33,13 +29,13 @@ func (c *appProxyClusters)CreateArgoRollouts(ctx context.Context, server string,
3329
`,
3430
"variables": map[string]interface{}{
3531
"args": map[string]interface{}{
36-
"destServer": server,
32+
"destServer": server,
3733
"destNamespace": namespace,
3834
},
3935
},
4036
}
4137

42-
res := &graphqlClusterResponse{}
38+
res := &graphqlVoidResponse{}
4339
err := c.codefresh.graphqlAPI(ctx, jsonData, res)
4440

4541
if err != nil {
@@ -53,20 +49,20 @@ func (c *appProxyClusters)CreateArgoRollouts(ctx context.Context, server string,
5349
return nil
5450
}
5551

56-
func (c *appProxyClusters)Delete(ctx context.Context, server string, runtime string) error {
52+
func (c *appProxyClusters) Delete(ctx context.Context, server string, runtime string) error {
5753
jsonData := map[string]interface{}{
5854
"query": `
5955
mutation RemoveCluster($server: String!, $runtime: String!) {
6056
removeCluster(server: $server, runtime: $runtime)
6157
}
6258
`,
6359
"variables": map[string]interface{}{
64-
"server": server,
60+
"server": server,
6561
"runtime": runtime,
6662
},
6763
}
6864

69-
res := &graphqlClusterResponse{}
65+
res := &graphqlVoidResponse{}
7066
err := c.codefresh.graphqlAPI(ctx, jsonData, res)
7167

7268
if err != nil {
@@ -78,4 +74,4 @@ func (c *appProxyClusters)Delete(ctx context.Context, server string, runtime str
7874
}
7975

8076
return nil
81-
}
77+
}

pkg/codefresh/ap_git-sources.go

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,12 @@ type (
2525
}
2626
Errors []graphqlError
2727
}
28-
29-
graphqlGitSourceCreateResponse struct {
30-
Errors []graphqlError
31-
}
32-
33-
graphqlGitSourceDeleteResponse struct {
34-
Errors []graphqlError
35-
}
36-
37-
graphqlGitSourceEditResponse struct {
38-
Errors []graphqlError
39-
}
4028
)
4129

4230
func newAppProxyGitSourcesAPI(c *codefresh) IAppProxyGitSourcesAPI {
4331
return &appProxyGitSources{codefresh: c}
4432
}
4533

46-
4734
func (c *appProxyGitSources) Create(ctx context.Context, opts *appProxyModel.CreateGitSourceInput) error {
4835
jsonData := map[string]interface{}{
4936
"query": `
@@ -64,7 +51,7 @@ func (c *appProxyGitSources) Create(ctx context.Context, opts *appProxyModel.Cre
6451
},
6552
}
6653

67-
res := &graphqlGitSourceCreateResponse{}
54+
res := &graphqlVoidResponse{}
6855
err := c.codefresh.graphqlAPI(ctx, jsonData, res)
6956

7057
if err != nil {
@@ -92,7 +79,7 @@ func (c *appProxyGitSources) Delete(ctx context.Context, appName string) error {
9279
},
9380
}
9481

95-
res := &graphqlGitSourceDeleteResponse{}
82+
res := &graphqlVoidResponse{}
9683
err := c.codefresh.graphqlAPI(ctx, jsonData, res)
9784

9885
if err != nil {
@@ -123,7 +110,7 @@ func (c *appProxyGitSources) Edit(ctx context.Context, opts *appProxyModel.EditG
123110
},
124111
}
125112

126-
res := &graphqlGitSourceEditResponse{}
113+
res := &graphqlVoidResponse{}
127114
err := c.codefresh.graphqlAPI(ctx, jsonData, res)
128115

129116
if err != nil {

pkg/codefresh/ap_git_integrations.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ type (
5050
Errors []graphqlError
5151
}
5252

53-
graphqlGitIntegrationsRemoveResponse struct {
54-
Errors []graphqlError
55-
}
56-
5753
graphqlGitIntegrationsRegisterResponse struct {
5854
Data struct {
5955
RegisterToGitIntegration *model.GitIntegration

pkg/codefresh/codefresh.go

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,42 @@ import (
2121

2222
type (
2323
Codefresh interface {
24-
Pipelines() IPipelineAPI
25-
Tokens() ITokenAPI
26-
RuntimeEnvironments() IRuntimeEnvironmentAPI
27-
Workflows() IWorkflowAPI
28-
Progresses() IProgressAPI
24+
AppProxy(ctx context.Context, runtime string, insecure bool) (AppProxyAPI, error)
25+
Argo() ArgoAPI
2926
Clusters() IClusterAPI
3027
Contexts() IContextAPI
31-
Users() UsersAPI
32-
Argo() ArgoAPI
3328
Gitops() GitopsAPI
29+
Pipelines() IPipelineAPI
30+
Progresses() IProgressAPI
31+
RuntimeEnvironments() IRuntimeEnvironmentAPI
32+
Tokens() ITokenAPI
33+
Users() UsersAPI
3434
V2() V2API
35-
AppProxy(ctx context.Context, runtime string, insecure bool) (AppProxyAPI, error)
35+
Workflows() IWorkflowAPI
3636
}
3737

3838
V2API interface {
39-
UsersV2() IUsersV2API
40-
Runtime() IRuntimeAPI
39+
AccountV2() IAccountV2API
40+
CliReleases() ICliReleasesAPI
4141
Cluster() IClusterV2API
42-
GitSource() IGitSourceAPI
4342
Component() IComponentAPI
44-
Workflow() IWorkflowV2API
43+
GitSource() IGitSourceAPI
4544
Pipeline() IPipelineV2API
46-
CliReleases() ICliReleasesAPI
45+
Runtime() IRuntimeAPI
46+
UsersV2() IUsersV2API
47+
Workflow() IWorkflowV2API
4748
}
4849

4950
AppProxyAPI interface {
5051
AppProxyClusters() IAppProxyClustersAPI
51-
GitIntegrations() IAppProxyGitIntegrationsAPI
52-
VersionInfo() IAppProxyVersionInfoAPI
5352
AppProxyGitSources() IAppProxyGitSourcesAPI
5453
AppProxyIsc() IAppProxyIscAPI
54+
GitIntegrations() IAppProxyGitIntegrationsAPI
55+
VersionInfo() IAppProxyVersionInfoAPI
56+
}
57+
58+
graphqlVoidResponse struct {
59+
Errors []graphqlError
5560
}
5661
)
5762

@@ -107,6 +112,10 @@ func (c *codefresh) V2() V2API {
107112
return c
108113
}
109114

115+
func (c *codefresh) AccountV2() IAccountV2API {
116+
return newAccountV2API(c)
117+
}
118+
110119
func (c *codefresh) Runtime() IRuntimeAPI {
111120
return newArgoRuntimeAPI(c)
112121
}

pkg/codefresh/argo_runtime.go renamed to pkg/codefresh/runtime_v2.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package codefresh
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67

78
"github.com/codefresh-io/go-sdk/pkg/codefresh/model"
@@ -71,10 +72,6 @@ type (
7172
}
7273
Errors []graphqlError
7374
}
74-
75-
graphQlResetIscRepoResponse struct {
76-
Errors []graphqlError
77-
}
7875
)
7976

8077
func newArgoRuntimeAPI(codefresh *codefresh) IRuntimeAPI {
@@ -321,22 +318,5 @@ func (r *argoRuntime) SetSharedConfigRepo(ctx context.Context, suggestedSharedCo
321318
}
322319

323320
func (r *argoRuntime) ResetSharedConfigRepo(ctx context.Context) error {
324-
jsonData := map[string]interface{}{
325-
"query": `
326-
mutation resetIscRepo {
327-
resetIscRepo
328-
}
329-
`}
330-
331-
res := &graphQlResetIscRepoResponse{}
332-
err := r.codefresh.graphqlAPI(ctx, jsonData, res)
333-
334-
if err != nil {
335-
fmt.Errorf("failed making a graphql API call while resetting shared config repo: %w", err)
336-
}
337-
338-
if len(res.Errors) > 0 {
339-
return graphqlErrorResponse{errors: res.Errors}
340-
}
341-
return nil
321+
return errors.New("DEPRECATED: use UpdateCsdpSettings instead")
342322
}

0 commit comments

Comments
 (0)