feat: implement scheduler-k3s:show-config

This commit is contained in:
Jose Diaz-Gonzalez
2024-01-18 01:08:02 -05:00
parent a2504fadd2
commit 6b85374857
3 changed files with 21 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
SUBCOMMANDS = subcommands/initialize subcommands/report subcommands/set
SUBCOMMANDS = subcommands/initialize subcommands/report subcommands/set subcommands/show-kubeconfig
TRIGGERS = triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/post-registry-login triggers/report triggers/scheduler-deploy triggers/scheduler-enter triggers/scheduler-logs triggers/scheduler-stop
BUILD = commands subcommands triggers
PLUGIN_NAME = scheduler-k3s

View File

@@ -44,6 +44,10 @@ func main() {
value = args.Arg(1)
}
err = scheduler_k3s.CommandSet(appName, property, value)
case "show-kubeconfig":
args := flag.NewFlagSet("scheduler-k3s:show-kubeconfig", flag.ExitOnError)
args.Parse(os.Args[2:])
err = scheduler_k3s.CommandShowKubeconfig()
default:
err = fmt.Errorf("Invalid plugin subcommand call: %s", subcommand)
}

View File

@@ -116,3 +116,19 @@ func CommandSet(appName string, property string, value string) error {
common.CommandPropertySet("scheduler-k3s", appName, property, value, DefaultProperties, GlobalProperties)
return nil
}
// CommandShowKubeconfig displays the kubeconfig file contents
func CommandShowKubeconfig() error {
if !common.FileExists(KubeConfigPath) {
return fmt.Errorf("Kubeconfig file does not exist: %s", KubeConfigPath)
}
b, err := os.ReadFile(KubeConfigPath)
if err != nil {
return fmt.Errorf("Unable to read kubeconfig file: %w", err)
}
fmt.Println(string(b))
return nil
}