Skip to content

Commit ff5944a

Browse files
new cli with old platform
1 parent 3b6abf2 commit ff5944a

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

pkg/codefresh/argo_runtime.go

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ type (
3434
}
3535

3636
graphQlRuntimeCreationResponse struct {
37+
Data struct {
38+
Runtime model.RuntimeCreationResponse
39+
}
40+
Errors []graphqlError
41+
}
42+
43+
graphQlRuntimeCreationResponseNew struct {
3744
Data struct {
3845
RuntimeNew model.RuntimeCreationResponse
3946
}
@@ -67,10 +74,42 @@ func (r *argoRuntime) Create(ctx context.Context, opts *model.RuntimeInstallatio
6774
},
6875
}
6976

70-
res := &graphQlRuntimeCreationResponse{}
77+
res := &graphQlRuntimeCreationResponseNew{}
7178
err := r.codefresh.graphqlAPI(ctx, jsonData, res)
79+
7280
if err != nil {
73-
return nil, fmt.Errorf("failed making a graphql API call while creating runtime: %w", err)
81+
jsonDataOld := map[string]interface{}{
82+
"query": `
83+
mutation CreateRuntime(
84+
$runtimeName: String!, $cluster: String!, $runtimeVersion: String!, $ingressHost: String, $componentNames: [String]!
85+
) {
86+
runtime(runtimeName: $runtimeName, cluster: $cluster, runtimeVersion: $runtimeVersion, ingressHost: $ingressHost, componentNames: $componentNames) {
87+
name
88+
newAccessToken
89+
}
90+
}
91+
`,
92+
"variables": map[string]interface{}{
93+
"runtimeName": opts.RuntimeName,
94+
"cluster": opts.Cluster,
95+
"runtimeVersion": opts.RuntimeVersion,
96+
"ingressHost": opts.IngressHost,
97+
"componentNames": opts.ComponentNames,
98+
},
99+
}
100+
101+
resOld := &graphQlRuntimeCreationResponse{}
102+
err = r.codefresh.graphqlAPI(ctx, jsonDataOld, resOld)
103+
104+
if err != nil {
105+
return nil, fmt.Errorf("failed making a graphql API call while creating runtime: %w", err)
106+
}
107+
108+
if len(resOld.Errors) > 0 {
109+
return nil, graphqlErrorResponse{errors: res.Errors}
110+
}
111+
112+
return &resOld.Data.Runtime, nil
74113
}
75114

76115
if len(res.Errors) > 0 {

0 commit comments

Comments
 (0)