|
9 | 9 |
|
10 | 10 | type ( |
11 | 11 | IRuntimeAPI interface { |
| 12 | + Create(ctx context.Context, opts *model.RuntimeInstallationArgs) (*model.RuntimeCreationResponse, error) |
12 | 13 | Get(ctx context.Context, name string) (*model.Runtime, error) |
13 | 14 | List(ctx context.Context) ([]model.Runtime, error) |
14 | | - Create(ctx context.Context, runtimeName, cluster, runtimeVersion, ingressHost string, componentNames []string) (*model.RuntimeCreationResponse, error) |
15 | 15 | Delete(ctx context.Context, runtimeName string) (int, error) |
16 | 16 | } |
17 | 17 |
|
@@ -52,6 +52,34 @@ func newArgoRuntimeAPI(codefresh *codefresh) IRuntimeAPI { |
52 | 52 | return &argoRuntime{codefresh: codefresh} |
53 | 53 | } |
54 | 54 |
|
| 55 | +func (r *argoRuntime) Create(ctx context.Context, opts *model.RuntimeInstallationArgs) (*model.RuntimeCreationResponse, error) { |
| 56 | + jsonData := map[string]interface{}{ |
| 57 | + "query": ` |
| 58 | + mutation CreateRuntime($installationArgs: RuntimeInstallationArgs!) { |
| 59 | + runtime(installationArgs: $installationArgs) { |
| 60 | + name |
| 61 | + newAccessToken |
| 62 | + } |
| 63 | + } |
| 64 | + `, |
| 65 | + "variables": map[string]interface{}{ |
| 66 | + "installationArgs": opts, |
| 67 | + }, |
| 68 | + } |
| 69 | + |
| 70 | + res := &graphQlRuntimeCreationResponse{} |
| 71 | + err := r.codefresh.graphqlAPI(ctx, jsonData, res) |
| 72 | + if err != nil { |
| 73 | + return nil, fmt.Errorf("failed making a graphql API call while creating runtime: %w", err) |
| 74 | + } |
| 75 | + |
| 76 | + if len(res.Errors) > 0 { |
| 77 | + return nil, graphqlErrorResponse{errors: res.Errors} |
| 78 | + } |
| 79 | + |
| 80 | + return &res.Data.Runtime, nil |
| 81 | +} |
| 82 | + |
55 | 83 | func (r *argoRuntime) Get(ctx context.Context, name string) (*model.Runtime, error) { |
56 | 84 | jsonData := map[string]interface{}{ |
57 | 85 | "query": ` |
@@ -146,40 +174,6 @@ func (r *argoRuntime) List(ctx context.Context) ([]model.Runtime, error) { |
146 | 174 | return runtimes, nil |
147 | 175 | } |
148 | 176 |
|
149 | | -func (r *argoRuntime) Create(ctx context.Context, runtimeName, cluster, runtimeVersion, ingressHost string, componentNames []string) (*model.RuntimeCreationResponse, error) { |
150 | | - jsonData := map[string]interface{}{ |
151 | | - "query": ` |
152 | | - mutation CreateRuntime( |
153 | | - $runtimeName: String!, $cluster: String!, $runtimeVersion: String!, $ingressHost: String, $componentNames: [String]! |
154 | | - ) { |
155 | | - runtime(runtimeName: $runtimeName, cluster: $cluster, runtimeVersion: $runtimeVersion, ingressHost: $ingressHost, componentNames: $componentNames) { |
156 | | - name |
157 | | - newAccessToken |
158 | | - } |
159 | | - } |
160 | | - `, |
161 | | - "variables": map[string]interface{}{ |
162 | | - "runtimeName": runtimeName, |
163 | | - "cluster": cluster, |
164 | | - "runtimeVersion": runtimeVersion, |
165 | | - "ingressHost": ingressHost, |
166 | | - "componentNames": componentNames, |
167 | | - }, |
168 | | - } |
169 | | - |
170 | | - res := &graphQlRuntimeCreationResponse{} |
171 | | - err := r.codefresh.graphqlAPI(ctx, jsonData, res) |
172 | | - if err != nil { |
173 | | - return nil, fmt.Errorf("failed making a graphql API call while creating runtime: %w", err) |
174 | | - } |
175 | | - |
176 | | - if len(res.Errors) > 0 { |
177 | | - return nil, graphqlErrorResponse{errors: res.Errors} |
178 | | - } |
179 | | - |
180 | | - return &res.Data.Runtime, nil |
181 | | -} |
182 | | - |
183 | 177 | func (r *argoRuntime) Delete(ctx context.Context, runtimeName string) (int, error) { |
184 | 178 | jsonData := map[string]interface{}{ |
185 | 179 | "query": ` |
|
0 commit comments