Skip to content

Commit

Permalink
Rename existing bootstrapper (#700)
Browse files Browse the repository at this point in the history
Signed-off-by: Vince Prignano <vincepri@vmware.com>
  • Loading branch information
vincepri authored and k8s-ci-robot committed Jan 20, 2019
1 parent 2cd5299 commit 2aa8825
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cmd/clusterctl/clusterdeployer/bootstrap/existing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = ["existingcluster.go"],
srcs = ["cluster.go"],
importpath = "sigs.k8s.io/cluster-api/cmd/clusterctl/clusterdeployer/bootstrap/existing",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/pkg/errors:go_default_library"],
)

go_test(
name = "go_default_test",
srcs = ["existingcluster_test.go"],
srcs = ["cluster_test.go"],
embed = [":go_default_library"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,36 @@ import (

// Represents an existing cluster being used for bootstrapping, should not be able to
// actually delete or create, but can point to actual kubeconfig file.
type ExistingCluster struct {
type Cluster struct {
kubeconfigPath string
kubeconfigFile string
}

// NewExistingCluster creates a new existing k8s bootstrap cluster object
// New creates a new existing k8s bootstrap cluster object
// We should clean up any lingering resources when clusterctl is complete.
// TODO https://github.com/kubernetes-sigs/cluster-api/issues/448
func NewExistingCluster(kubeconfigPath string) (*ExistingCluster, error) {
func New(kubeconfigPath string) (*Cluster, error) {
if _, err := os.Stat(kubeconfigPath); os.IsNotExist(err) {
return nil, errors.Errorf("file at %s does not exist", kubeconfigPath)
}

return &ExistingCluster{kubeconfigPath: kubeconfigPath}, nil
return &Cluster{kubeconfigPath: kubeconfigPath}, nil
}

// Create implements clusterdeployer.ClusterProvisioner interface
func (e *ExistingCluster) Create() error {
func (e *Cluster) Create() error {
// noop
return nil
}

// Delete implements clusterdeployer.ClusterProvisioner interface
func (e *ExistingCluster) Delete() error {
func (e *Cluster) Delete() error {
// noop
return nil
}

// GetKubeconfig implements clusterdeployer.ClusterProvisioner interface
func (e *ExistingCluster) GetKubeconfig() (string, error) {
func (e *Cluster) GetKubeconfig() (string, error) {

if e.kubeconfigFile == "" {
b, err := ioutil.ReadFile(e.kubeconfigPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ func TestGetKubeconfig(t *testing.T) {
defer os.Remove(f)

t.Run("invalid path given", func(t *testing.T) {
_, err = NewExistingCluster("")
_, err = New("")
if err == nil {
t.Fatal("Should not be able create External Cluster Provisioner.")
}
})

t.Run("file exists", func(t *testing.T) {

ec, err := NewExistingCluster(f)
ec, err := New(f)
if err != nil {
t.Fatal("Should be able create External Cluster Provisioner.")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/clusterdeployer/bootstrap/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func Get(o Options) (ClusterProvisioner, error) {
return minikube.WithOptions(o.ExtraFlags), nil
default:
if o.KubeConfig != "" {
return existing.NewExistingCluster(o.KubeConfig)
return existing.New(o.KubeConfig)
}

return nil, errors.New("no bootstrap provisioner specified, you can specify `--bootstrap-cluster-kubeconfig` to use an existing Kubernetes cluster or `--bootstrap-type` to use a built-in ephemeral cluster.")
Expand Down

0 comments on commit 2aa8825

Please sign in to comment.