diff --git a/internal/namespaces/k8s/v1/custom_cluster.go b/internal/namespaces/k8s/v1/custom_cluster.go index 4efff8d2e6..66d651f744 100644 --- a/internal/namespaces/k8s/v1/custom_cluster.go +++ b/internal/namespaces/k8s/v1/custom_cluster.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "net/http" + "reflect" "time" "github.com/fatih/color" @@ -55,6 +56,29 @@ func clusterAvailableVersionsListBuilder(c *core.Command) *core.Command { } func clusterCreateBuilder(c *core.Command) *core.Command { + type customCreateClusterRequest struct { + *k8s.CreateClusterRequest + Pools []*struct { + *k8s.CreateClusterRequestPoolConfig + Size *uint32 + } + } + + c.ArgsType = reflect.TypeOf(customCreateClusterRequest{}) + + c.AddInterceptors(func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (i interface{}, err error) { + args := argsI.(*customCreateClusterRequest) + + request := args.CreateClusterRequest + for i, pool := range args.Pools { + poolReq := pool.CreateClusterRequestPoolConfig + poolReq.Size = *pool.Size + request.Pools = append(request.Pools, poolReq) + } + + return runner(ctx, request) + }) + c.WaitFunc = waitForClusterFunc(clusterActionCreate) return c } diff --git a/internal/namespaces/k8s/v1/custom_pool.go b/internal/namespaces/k8s/v1/custom_pool.go index e029ea0dcb..837fdb2255 100644 --- a/internal/namespaces/k8s/v1/custom_pool.go +++ b/internal/namespaces/k8s/v1/custom_pool.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "net/http" + "reflect" "time" "github.com/fatih/color" @@ -42,6 +43,22 @@ const ( func poolCreateBuilder(c *core.Command) *core.Command { c.WaitFunc = waitForPoolFunc(poolActionCreate) + type customCreatePoolRequest struct { + *k8s.CreatePoolRequest + Size *uint32 + } + + c.ArgsType = reflect.TypeOf(customCreatePoolRequest{}) + + c.AddInterceptors(func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (i interface{}, err error) { + args := argsI.(*customCreatePoolRequest) + + request := args.CreatePoolRequest + request.Size = *args.Size + + return runner(ctx, request) + }) + return c }