Skip to content

Commit

Permalink
fix(k8s): allow pool with size 0
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Cyvoct <[email protected]>
  • Loading branch information
Sh4d1 committed Apr 18, 2020
1 parent 5d3c3ad commit 1765fb2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
26 changes: 26 additions & 0 deletions internal/namespaces/k8s/v1/custom_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"context"
"errors"
"fmt"
"log"
"net/http"
"reflect"
"time"

"github.com/fatih/color"
Expand Down Expand Up @@ -55,6 +57,30 @@ 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 {
log.Printf("%+v", *args.Pools[i])
poolReq := pool.CreateClusterRequestPoolConfig
poolReq.Size = *pool.Size
request.Pools = append(request.Pools, poolReq)
}

return runner(ctx, request)
})

c.WaitFunc = waitForClusterFunc(clusterActionCreate)
return c
}
Expand Down
17 changes: 17 additions & 0 deletions internal/namespaces/k8s/v1/custom_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/http"
"reflect"
"time"

"github.com/fatih/color"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 1765fb2

Please sign in to comment.