feat: implement scheduler-k3s:show-config
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user