@@ -3,13 +3,12 @@ package codefresh
33import (
44 "context"
55 "fmt"
6-
76 "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
87)
98
109type (
1110 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 )
1312 Get (ctx context.Context , name string ) (* model.Runtime , error )
1413 List (ctx context.Context ) ([]model.Runtime , error )
1514 Delete (ctx context.Context , runtimeName string ) (int , error )
3534
3635 graphQlRuntimeCreationResponse struct {
3736 Data struct {
38- Runtime model.RuntimeCreationResponse
37+ CreateRuntime model.RuntimeCreationResponse
3938 }
4039 Errors []graphqlError
4140 }
@@ -52,29 +51,24 @@ func newArgoRuntimeAPI(codefresh *codefresh) IRuntimeAPI {
5251 return & argoRuntime {codefresh : codefresh }
5352}
5453
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 ) {
5655 jsonData := map [string ]interface {}{
5756 "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) {
6259 name
6360 newAccessToken
6461 }
6562 }
6663 ` ,
6764 "variables" : map [string ]interface {}{
68- "runtimeName" : runtimeName ,
69- "cluster" : cluster ,
70- "runtimeVersion" : runtimeVersion ,
71- "ingressHost" : ingressHost ,
72- "componentNames" : componentNames ,
65+ "installationArgs" : opts ,
7366 },
7467 }
7568
7669 res := & graphQlRuntimeCreationResponse {}
7770 err := r .codefresh .graphqlAPI (ctx , jsonData , res )
71+
7872 if err != nil {
7973 return nil , fmt .Errorf ("failed making a graphql API call while creating runtime: %w" , err )
8074 }
@@ -83,7 +77,7 @@ func (r *argoRuntime) Create(ctx context.Context, runtimeName, cluster, runtimeV
8377 return nil , graphqlErrorResponse {errors : res .Errors }
8478 }
8579
86- return & res .Data .Runtime , nil
80+ return & res .Data .CreateRuntime , nil
8781}
8882
8983func (r * argoRuntime ) Get (ctx context.Context , name string ) (* model.Runtime , error ) {
0 commit comments