Make the ISO url configurable for testing new ISO builds.
Also delete the old flag, since it's unused.pull/75/head
parent
d4516f7665
commit
cac6d07a5d
|
@ -38,7 +38,7 @@ assumes you already have Virtualbox installed.`,
|
|||
}
|
||||
|
||||
var (
|
||||
localkubeURL string
|
||||
minikubeISO string
|
||||
)
|
||||
|
||||
func runStart(cmd *cobra.Command, args []string) {
|
||||
|
@ -46,22 +46,23 @@ func runStart(cmd *cobra.Command, args []string) {
|
|||
fmt.Println("Starting local Kubernetes cluster...")
|
||||
api := libmachine.NewClient(constants.Minipath, constants.MakeMiniPath("certs"))
|
||||
defer api.Close()
|
||||
host, err := cluster.StartHost(api)
|
||||
|
||||
config := cluster.MachineConfig{
|
||||
MinikubeISO: minikubeISO,
|
||||
}
|
||||
|
||||
host, err := cluster.StartHost(api, config)
|
||||
if err != nil {
|
||||
log.Println("Error starting host: ", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
config := cluster.KubernetesConfig{
|
||||
LocalkubeURL: localkubeURL,
|
||||
}
|
||||
|
||||
if err := cluster.UpdateCluster(host.Driver); err != nil {
|
||||
log.Println("Error updating cluster: ", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := cluster.StartCluster(host, config); err != nil {
|
||||
if err := cluster.StartCluster(host); err != nil {
|
||||
log.Println("Error starting cluster: ", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@ -86,7 +87,7 @@ func runStart(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
func init() {
|
||||
startCmd.Flags().StringVarP(&localkubeURL, "localkube-url", "", "https://storage.googleapis.com/tinykube/localkube", "Location of the localkube binary")
|
||||
startCmd.Flags().MarkHidden("localkube-url")
|
||||
startCmd.Flags().StringVarP(&minikubeISO, "iso-url", "", "https://storage.googleapis.com/tinykube/minikube.iso", "Location of the minikube iso")
|
||||
startCmd.Flags().MarkHidden("iso-url")
|
||||
RootCmd.AddCommand(startCmd)
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ var (
|
|||
)
|
||||
|
||||
// StartHost starts a host VM.
|
||||
func StartHost(api libmachine.API) (*host.Host, error) {
|
||||
func StartHost(api libmachine.API, config KubernetesConfig) (*host.Host, error) {
|
||||
if exists, err := api.Exists(constants.MachineName); err != nil {
|
||||
return nil, fmt.Errorf("Error checking if host exists: %s", err)
|
||||
} else if exists {
|
||||
|
@ -63,7 +63,7 @@ func StartHost(api libmachine.API) (*host.Host, error) {
|
|||
}
|
||||
return h, nil
|
||||
} else {
|
||||
return createHost(api)
|
||||
return createHost(api, config)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,13 +140,13 @@ type sshAble interface {
|
|||
RunSSHCommand(string) (string, error)
|
||||
}
|
||||
|
||||
// KubernetesConfig contains the parameters used to start a cluster.
|
||||
type KubernetesConfig struct {
|
||||
LocalkubeURL string
|
||||
// MachineConfig contains the parameters used to start a cluster.
|
||||
type MachineConfig struct {
|
||||
MinikubeISO string
|
||||
}
|
||||
|
||||
// StartCluster starts a k8s cluster on the specified Host.
|
||||
func StartCluster(h sshAble, config KubernetesConfig) error {
|
||||
func StartCluster(h sshAble) error {
|
||||
output, err := h.RunSSHCommand(getStartCommand())
|
||||
log.Println(output)
|
||||
if err != nil {
|
||||
|
@ -192,9 +192,9 @@ func GetCreds(h sshAble) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func createHost(api libmachine.API) (*host.Host, error) {
|
||||
func createHost(api libmachine.API, config MachineConfig) (*host.Host, error) {
|
||||
driver := virtualbox.NewDriver(constants.MachineName, constants.Minipath)
|
||||
driver.Boot2DockerURL = "https://storage.googleapis.com/tinykube/boot2docker.iso"
|
||||
driver.Boot2DockerURL = config.MinikubeISO
|
||||
data, err := json.Marshal(driver)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue