feat: add command to add or remove auth configurations
This commit is contained in:
1 parent
0cb47f1c54
commit
3bd61d8c7f
4 files changed
+38
-1
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
SUBCOMMANDS = subcommands/annotations:set subcommands/cluster-add subcommands/cluster-list subcommands/cluster-remove subcommands/initialize subcommands/labels:set subcommands/report subcommands/set subcommands/show-kubeconfig subcommands/uninstall
|
SUBCOMMANDS = subcommands/annotations:set subcommands/autoscaling-auth:set subcommands/cluster-add subcommands/cluster-list subcommands/cluster-remove subcommands/initialize subcommands/labels:set subcommands/report subcommands/set subcommands/show-kubeconfig subcommands/uninstall
|
||||||
TRIGGERS = triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/report triggers/scheduler-deploy triggers/scheduler-enter triggers/scheduler-logs triggers/scheduler-post-delete triggers/scheduler-run triggers/scheduler-run-list triggers/scheduler-stop
|
TRIGGERS = triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/report triggers/scheduler-deploy triggers/scheduler-enter triggers/scheduler-logs triggers/scheduler-post-delete triggers/scheduler-run triggers/scheduler-run-list triggers/scheduler-stop
|
||||||
BUILD = commands subcommands triggers
|
BUILD = commands subcommands triggers
|
||||||
PLUGIN_NAME = scheduler-k3s
|
PLUGIN_NAME = scheduler-k3s
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ Manage scheduler-k3s settings for an app
|
|||||||
Additional commands:`
|
Additional commands:`
|
||||||
|
|
||||||
helpContent = `
|
helpContent = `
|
||||||
|
scheduler-k3s:autoscaling-auth:set <app|--global> <trigger> [<--metadata key=value>...], Set or clear a scheduler-k3s autoscaling keda trigger authentication object for an app
|
||||||
scheduler-k3s:annotations:set <app|--global> <property> (<value>) [--process-type PROCESS_TYPE] <--resource-type RESOURCE_TYPE>, Set or clear an annotation for a given app/process-type/resource-type combination
|
scheduler-k3s:annotations:set <app|--global> <property> (<value>) [--process-type PROCESS_TYPE] <--resource-type RESOURCE_TYPE>, Set or clear an annotation for a given app/process-type/resource-type combination
|
||||||
scheduler-k3s:cluster-add [--insecure-allow-unknown-hosts] [--server-ip SERVER_IP] [--taint-scheduling] <ssh://user@host:port>, Adds a server node to a Dokku-managed cluster
|
scheduler-k3s:cluster-add [--insecure-allow-unknown-hosts] [--server-ip SERVER_IP] [--taint-scheduling] <ssh://user@host:port>, Adds a server node to a Dokku-managed cluster
|
||||||
scheduler-k3s:cluster-list [--format json|stdout], Lists all nodes in a Dokku-managed cluster
|
scheduler-k3s:cluster-list [--format json|stdout], Lists all nodes in a Dokku-managed cluster
|
||||||
|
|||||||
@@ -34,6 +34,14 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = scheduler_k3s.CommandAnnotationsSet(appName, *processType, *resourceType, property, value)
|
err = scheduler_k3s.CommandAnnotationsSet(appName, *processType, *resourceType, property, value)
|
||||||
|
case "autoscaling-auth:set":
|
||||||
|
args := flag.NewFlagSet("scheduler-k3s:autoscaling-auth:set", flag.ExitOnError)
|
||||||
|
global := args.Bool("global", false, "--global: set a global property")
|
||||||
|
metadata := args.StringToString("metadata", map[string]string{}, "--metadata: a key=value map of parameter metadata")
|
||||||
|
args.Parse(os.Args[2:])
|
||||||
|
appName := args.Arg(0)
|
||||||
|
trigger := args.Arg(1)
|
||||||
|
err = scheduler_k3s.CommandAutoscalingAuthSet(appName, trigger, *metadata, *global)
|
||||||
case "cluster-add":
|
case "cluster-add":
|
||||||
args := flag.NewFlagSet("scheduler-k3s:cluster-add", flag.ExitOnError)
|
args := flag.NewFlagSet("scheduler-k3s:cluster-add", flag.ExitOnError)
|
||||||
allowUknownHosts := args.Bool("insecure-allow-unknown-hosts", false, "insecure-allow-unknown-hosts: allow unknown hosts")
|
allowUknownHosts := args.Bool("insecure-allow-unknown-hosts", false, "insecure-allow-unknown-hosts: allow unknown hosts")
|
||||||
|
|||||||
@@ -58,6 +58,34 @@ func CommandAnnotationsSet(appName string, processType string, resourceType stri
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CommandAutoscalingAuthSet set or clear a scheduler-k3s autoscaling keda trigger authentication object for an app
|
||||||
|
func CommandAutoscalingAuthSet(appName string, trigger string, metadata map[string]string, global bool) error {
|
||||||
|
if global {
|
||||||
|
appName = "--global"
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(metadata) == 0 {
|
||||||
|
properties, err := common.PropertyGetAllByPrefix("scheduler-k3s", appName, fmt.Sprintf("trigger-auth.%s.", trigger))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Unable to get property list: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for key := range properties {
|
||||||
|
if err := common.PropertyDelete("scheduler-k3s", appName, key); err != nil {
|
||||||
|
return fmt.Errorf("Unable to delete property: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value := range metadata {
|
||||||
|
if err := common.PropertyWrite("scheduler-k3s", appName, fmt.Sprintf("trigger-auth.%s.%s", trigger, key), value); err != nil {
|
||||||
|
return fmt.Errorf("Unable to set property: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// CommandInitialize initializes a k3s cluster on the local server
|
// CommandInitialize initializes a k3s cluster on the local server
|
||||||
func CommandInitialize(ingressClass string, serverIP string, taintScheduling bool) error {
|
func CommandInitialize(ingressClass string, serverIP string, taintScheduling bool) error {
|
||||||
if ingressClass != "nginx" && ingressClass != "traefik" {
|
if ingressClass != "nginx" && ingressClass != "traefik" {
|
||||||
|
|||||||
Reference in new issue
Block a user