-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77a0407
commit 6c4188b
Showing
2 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright 2021 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package installer | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"k8s.io/klog" | ||
"k8s.io/klog/klogr" | ||
) | ||
|
||
var ( | ||
listFlag = flag.Bool("list", false, "List all supported OS and Kubernetes versions") | ||
listBundlesFlag = flag.Bool("listbundles", false, "List the BYOH Bundle names for all supported OS and Kubernetes versions") | ||
detectOSFlag = flag.Bool("detect", false, "Detects the current operating system") | ||
installFlag = flag.Bool("install", false, "Install a BYOH Bundle") | ||
uninstallFlag = flag.Bool("uninstall", false, "Unnstall a BYOH Bundle") | ||
bundleRepoFlag = flag.String("bundleRepo", "https://projects.registry.vmware.com", "BYOH Bundle Repository. If not set, will look for bundles locally") | ||
k8sFlag = flag.String("k8sVer", "1.22.1", "Kubernetes version to install") | ||
) | ||
|
||
const ( | ||
doInstall = true | ||
doUninstall = false | ||
) | ||
|
||
func Main() { | ||
flag.Parse() | ||
|
||
if *listFlag { | ||
list() | ||
} | ||
|
||
if *listBundlesFlag { | ||
listBundles() | ||
} | ||
|
||
if *detectOSFlag { | ||
detectOS() | ||
} | ||
|
||
if *installFlag { | ||
runInstaller(doInstall) | ||
} | ||
|
||
if *uninstallFlag { | ||
runInstaller(doUninstall) | ||
} | ||
} | ||
|
||
func list() { | ||
for _, os := range ListSupportedOS() { | ||
for _, k8s := range ListSupportedK8s(os) { | ||
fmt.Printf("%s %s\n", os, k8s) | ||
} | ||
} | ||
} | ||
|
||
func listBundles() { | ||
for _, os := range ListSupportedOS() { | ||
for _, k8s := range ListSupportedK8s(os) { | ||
fmt.Println(GetBundleName(os, k8s)) | ||
} | ||
} | ||
} | ||
|
||
func detectOS() { | ||
osd := osDetector{} | ||
os, err := osd.Detect() | ||
if err != nil { | ||
fmt.Printf("Error detecting OS %s", err) | ||
return | ||
} | ||
|
||
fmt.Printf("Detected OS as: %s", os) | ||
} | ||
|
||
func runInstaller(install bool) { | ||
if *bundleRepoFlag == "" { | ||
bd := bundleDownloader{"", "."} | ||
fmt.Printf("Bundle repo not specified. Provide bundle contents in %s\n", bd.GetBundleDirPath(*k8sFlag)) | ||
} | ||
|
||
klog.InitFlags(nil) | ||
klogr.New() | ||
|
||
i, err := New("norepo", ".", klogr.New()) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
if install { | ||
err = i.Install(*k8sFlag) | ||
} else { | ||
err = i.Uninstall(*k8sFlag) | ||
} | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright 2021 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/vmware-tanzu/cluster-api-provider-byoh/agent/installer" | ||
) | ||
|
||
func main() { | ||
installer.Main() | ||
} |