Skip to content

Commit

Permalink
update use case for init
Browse files Browse the repository at this point in the history
  • Loading branch information
frapposelli committed Jul 26, 2019
1 parent 36e18b2 commit c63660a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
16 changes: 10 additions & 6 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import (

"github.com/spf13/cobra"

"k8s.io/klog"

"github.com/timothysc/clusteradm/pkg/client"
)

Expand All @@ -36,7 +34,9 @@ var initCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(initCmd)
initCmd.Flags().StringSlice("providers", nil, "providers to initialize")
initCmd.Flags().String("bootstrap", "", "provider used to bootstrap")
initCmd.MarkFlagRequired("providers")
initCmd.Flags().Lookup("bootstrap").NoOptDefVal = "kind"
// TODO - determine bootstrap/pivot scenario
}

Expand All @@ -46,10 +46,14 @@ func runInit(cmd *cobra.Command, args []string) {
// if not, print long help thing.
// 1. If it's already running exit with note on the version running.
fmt.Println("performing init...")

config := client.ClusteradmCfg{}

bootstrap, _ := cmd.Flags().GetString("bootstrap")
config.Bootstrap = bootstrap

cc, _ := client.NewClusteradmClient()
providers, _ := cmd.Flags().GetStringSlice("providers")
for _, p := range providers {
klog.V(2).Infof("calling interface ClusteradmClient.Init() with provider: %s\n", p)
}
cc.Init()
config.Providers = providers
cc.Init(config)
}
19 changes: 18 additions & 1 deletion pkg/client/init.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
package client

func (c *ClusteradmClient) Init() error {
import (
"k8s.io/klog"
)

func (c *ClusteradmClient) Init(cfg ClusteradmCfg) error {
if cfg.Bootstrap != "" {
klog.V(2).Infof("bootstrapping the cluster with: %s", cfg.Bootstrap)
// do the bootstrap and fetch kubeconfig
}

// get kubeconfig for bootstrap cluster

for _, p := range cfg.Providers {
klog.V(2).Infof("calling interface ClusteradmClient.Init() with provider: %s\n", p)
}

// do the init

return nil
}
2 changes: 1 addition & 1 deletion pkg/client/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func NewClusteradmClient() (*ClusteradmClient, error) {
var _ Interface = &ClusteradmClient{}

type Interface interface {
Init() error
Init(ClusteradmCfg) error
GenerateConfig() error
Upgrade() error
Reset() error
Expand Down
10 changes: 10 additions & 0 deletions pkg/client/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// TODO: this shouldn't be here

package client

// ClusteradmCfg is just a placeholder
// TODO: this is just a placeholder
type ClusteradmCfg struct {
Bootstrap string
Providers []string
}

0 comments on commit c63660a

Please sign in to comment.