Skip to content

Commit

Permalink
[clusterctl] Rename external to bootstrap and internal to target
Browse files Browse the repository at this point in the history
- Rename references to "external" cluster to "bootstrap"
- Rename references to "internal" cluster to "target"
- Rename ExternalBootstrapCluster to ExistingCluster
  • Loading branch information
detiber committed Aug 22, 2018
1 parent e1903be commit 3530b8c
Show file tree
Hide file tree
Showing 13 changed files with 223 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = ["externalbootstrapcluster.go"],
importpath = "sigs.k8s.io/cluster-api/clusterctl/clusterdeployer/externalclusterprovisioner",
srcs = ["exisingcluster.go"],
importpath = "sigs.k8s.io/cluster-api/clusterctl/clusterdeployer/bootstrap/existing",
visibility = ["//visibility:public"],
)

go_test(
name = "go_default_test",
srcs = ["externalbootstrapcluster_test.go"],
srcs = ["existingcluster_test.go"],
embed = [":go_default_library"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,46 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package externalclusterprovisioner
package existing

import (
"fmt"
"io/ioutil"
"os"
"fmt"
)

// Represents an actual external cluster being used for bootstrapping, should not be able to
// 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 ExternalBootstrapCluster struct {
type ExistingCluster struct {
kubeconfigPath string
kubeconfigFile string
}

// NewExternalCluster creates a new external k8s bootstrap cluster object
// NewExistingCluster 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 NewExternalCluster(kubeconfigPath string) (*ExternalBootstrapCluster, error) {
func NewExistingCluster(kubeconfigPath string) (*ExistingCluster, error) {
if _, err := os.Stat(kubeconfigPath); os.IsNotExist(err) {
return nil, fmt.Errorf("file at %s does not exist", kubeconfigPath)
}

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

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

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

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

if e.kubeconfigFile == "" {
b, err := ioutil.ReadFile(e.kubeconfigPath)
Expand All @@ -63,6 +64,5 @@ func (e *ExternalBootstrapCluster) GetKubeconfig() (string, error) {
e.kubeconfigFile = string(b)
}


return e.kubeconfigFile, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package externalclusterprovisioner
package existing

import (
"testing"
"os"
"io/ioutil"
"os"
"testing"
)

func TestGetKubeconfig(t *testing.T) {
Expand All @@ -30,16 +30,16 @@ func TestGetKubeconfig(t *testing.T) {
}
defer os.Remove(f)

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

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

ec, err := NewExternalCluster(f)
ec, err := NewExistingCluster(f)
if err != nil {
t.Fatal("Should be able create External Cluster Provisioner.")
}
Expand All @@ -63,4 +63,4 @@ func createTempFile(contents string) (string, error) {
defer f.Close()
f.WriteString(contents)
return f.Name(), nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = ["minikube.go"],
importpath = "sigs.k8s.io/cluster-api/clusterctl/clusterdeployer/minikube",
importpath = "sigs.k8s.io/cluster-api/clusterctl/clusterdeployer/bootstrap/minikube",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/golang/glog:go_default_library"],
)
Expand Down
Loading

0 comments on commit 3530b8c

Please sign in to comment.