Skip to content

Commit 7988706

Browse files
old and new mutations
1 parent 120474f commit 7988706

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

pkg/codefresh/argo_runtime.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
type (
1111
IRuntimeAPI interface {
1212
CreateUsingOldMutation(ctx context.Context, runtimeName, cluster, runtimeVersion, ingressHost string, componentNames []string) (*model.RuntimeCreationResponse, error)
13+
CreateUsingNewMutation(ctx context.Context, opts *model.RuntimeInstallationArgs) (*model.RuntimeCreationResponse, error)
14+
1315
Get(ctx context.Context, name string) (*model.Runtime, error)
1416
List(ctx context.Context) ([]model.Runtime, error)
1517
Delete(ctx context.Context, runtimeName string) (int, error)
@@ -86,6 +88,36 @@ func (r *argoRuntime) CreateUsingOldMutation(ctx context.Context, runtimeName, c
8688
return &res.Data.Runtime, nil
8789
}
8890

91+
func (r *argoRuntime) CreateUsingNewMutation(ctx context.Context, opts *model.RuntimeInstallationArgs) (*model.RuntimeCreationResponse, error) {
92+
jsonData := map[string]interface{}{
93+
"query": `
94+
mutation CreateRuntime($installationArgs: RuntimeInstallationArgs!) {
95+
runtime(installationArgs: $installationArgs) {
96+
name
97+
newAccessToken
98+
}
99+
}
100+
`,
101+
"variables": map[string]interface{}{
102+
"installationArgs": opts,
103+
},
104+
}
105+
106+
res := &graphQlRuntimeCreationResponse{}
107+
err := r.codefresh.graphqlAPI(ctx, jsonData, res)
108+
if err != nil {
109+
return nil, fmt.Errorf("failed making a graphql API call while creating runtime: %w", err)
110+
}
111+
112+
if len(res.Errors) > 0 {
113+
return nil, graphqlErrorResponse{errors: res.Errors}
114+
}
115+
116+
return &res.Data.Runtime, nil
117+
}
118+
119+
120+
89121
func (r *argoRuntime) Get(ctx context.Context, name string) (*model.Runtime, error) {
90122
jsonData := map[string]interface{}{
91123
"query": `

0 commit comments

Comments
 (0)