Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI for the installer library #175

Merged
merged 6 commits into from
Nov 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Allow bypass detecting OS
ratanasovvmw committed Oct 29, 2021
commit 14c45ed019ca038f003e12d383efd43b9354ec00
32 changes: 22 additions & 10 deletions agent/installer/cli.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ var (
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("k8s", "1.22.1", "Kubernetes version")
osFlag = flag.String("os", "", "OS")
osFlag = flag.String("os", "", "OS. If used with install/uninstall, skip os detection")
previewOSChangesFlag = flag.Bool("previewOSChanges", false, "Preview the install and uninstall changes for the specified OS")
)

@@ -83,23 +83,35 @@ func detectOS() {
}

func runInstaller(install bool) {
klog.InitFlags(nil)
klogger := klogr.New()

if *bundleRepoFlag == "" {
bd := bundleDownloader{"", "."}
fmt.Printf("Bundle repo not specified. Provide bundle contents in %s\n", bd.GetBundleDirPath(*k8sFlag))
}

klog.InitFlags(nil)
klogr.New()
var i *installer
var err error
if *osFlag != "" {
// Override current OS detection
i, err = newUnchecked(*osFlag, *bundleRepoFlag, ".", klogger, &logPrinter{klogger})
if err != nil {
fmt.Println(err)
return
}
} else {
i, err = New("norepo", ".", klogger)
if err != nil {
fmt.Println(err)
return
}

i, err := New("norepo", ".", klogr.New())
if err != nil {
fmt.Println(err)
// Override preview mode
i.downloadPath = "."
i.repoAddr = *bundleRepoFlag
}

// Override preview mode
i.downloadPath = "."
i.repoAddr = *bundleRepoFlag

if install {
err = i.Install(*k8sFlag)
} else {