@@ -3,13 +3,12 @@ package codefresh
3
3
import (
4
4
"context"
5
5
"fmt"
6
-
7
6
"github.com/codefresh-io/go-sdk/pkg/codefresh/model"
8
7
)
9
8
10
9
type (
11
10
IRuntimeAPI interface {
12
- Create (ctx context.Context , runtimeName , cluster , runtimeVersion , ingressHost string , componentNames [] string ) (* model.RuntimeCreationResponse , error )
11
+ Create (ctx context.Context , opts * model. RuntimeInstallationArgs ) (* model.RuntimeCreationResponse , error )
13
12
Get (ctx context.Context , name string ) (* model.Runtime , error )
14
13
List (ctx context.Context ) ([]model.Runtime , error )
15
14
Delete (ctx context.Context , runtimeName string ) (int , error )
35
34
36
35
graphQlRuntimeCreationResponse struct {
37
36
Data struct {
38
- Runtime model.RuntimeCreationResponse
37
+ CreateRuntime model.RuntimeCreationResponse
39
38
}
40
39
Errors []graphqlError
41
40
}
@@ -52,29 +51,24 @@ func newArgoRuntimeAPI(codefresh *codefresh) IRuntimeAPI {
52
51
return & argoRuntime {codefresh : codefresh }
53
52
}
54
53
55
- func (r * argoRuntime ) Create (ctx context.Context , runtimeName , cluster , runtimeVersion , ingressHost string , componentNames [] string ) (* model.RuntimeCreationResponse , error ) {
54
+ func (r * argoRuntime ) Create (ctx context.Context , opts * model. RuntimeInstallationArgs ) (* model.RuntimeCreationResponse , error ) {
56
55
jsonData := map [string ]interface {}{
57
56
"query" : `
58
- mutation CreateRuntime(
59
- $runtimeName: String!, $cluster: String!, $runtimeVersion: String!, $ingressHost: String, $componentNames: [String]!
60
- ) {
61
- runtime(runtimeName: $runtimeName, cluster: $cluster, runtimeVersion: $runtimeVersion, ingressHost: $ingressHost, componentNames: $componentNames) {
57
+ mutation CreateRuntime($installationArgs: RuntimeInstallationArgs!) {
58
+ createRuntime(installationArgs: $installationArgs) {
62
59
name
63
60
newAccessToken
64
61
}
65
62
}
66
63
` ,
67
64
"variables" : map [string ]interface {}{
68
- "runtimeName" : runtimeName ,
69
- "cluster" : cluster ,
70
- "runtimeVersion" : runtimeVersion ,
71
- "ingressHost" : ingressHost ,
72
- "componentNames" : componentNames ,
65
+ "installationArgs" : opts ,
73
66
},
74
67
}
75
68
76
69
res := & graphQlRuntimeCreationResponse {}
77
70
err := r .codefresh .graphqlAPI (ctx , jsonData , res )
71
+
78
72
if err != nil {
79
73
return nil , fmt .Errorf ("failed making a graphql API call while creating runtime: %w" , err )
80
74
}
@@ -83,7 +77,7 @@ func (r *argoRuntime) Create(ctx context.Context, runtimeName, cluster, runtimeV
83
77
return nil , graphqlErrorResponse {errors : res .Errors }
84
78
}
85
79
86
- return & res .Data .Runtime , nil
80
+ return & res .Data .CreateRuntime , nil
87
81
}
88
82
89
83
func (r * argoRuntime ) Get (ctx context.Context , name string ) (* model.Runtime , error ) {
0 commit comments