diff --git a/docs/deployment/schedulers/k3s.md b/docs/deployment/schedulers/k3s.md index ca317779f..c146d3a45 100644 --- a/docs/deployment/schedulers/k3s.md +++ b/docs/deployment/schedulers/k3s.md @@ -17,7 +17,7 @@ scheduler-k3s:ensure-charts # Ensures the k3s charts are scheduler-k3s:initialize # Initializes a cluster scheduler-k3s:labels:set () [--process-type PROCESS_TYPE] <--resource-type RESOURCE_TYPE> # Set or clear a label for a given app/process-type/resource-type combination scheduler-k3s:labels:report [|--global] [--format stdout|json] [--process-type PROCESS_TYPE] [--resource-type RESOURCE_TYPE] # Displays a scheduler-k3s labels report for one or more apps -scheduler-k3s:preview [--show-secrets] [--show-secrets-decoded] # Displays a diff between the current and next deployment for an app +scheduler-k3s:preview [--context N] [--show-secrets] [--show-secrets-decoded] # Displays a diff between the current and next deployment for an app scheduler-k3s:profiles:add [--role ROLE] [--insecure-allow-unknown-hosts] [--taint-scheduling] [--kubelet-args KUBELET_ARGS] Adds a node profile to the k3s cluster scheduler-k3s:profiles:list [--format json|stdout] # Lists all node profiles in the k3s cluster scheduler-k3s:profiles:remove # Removes a node profile from the k3s cluster @@ -247,6 +247,13 @@ dokku scheduler-k3s:preview node-js-app A clean redeploy with no property changes produces no output. After modifying a property that affects the main app chart (for example `dokku resource:limit --memory 256m node-js-app`), the command shows the unified diff for each changed resource. For an app that has never been deployed, the entire proposed manifest is rendered as added lines. +By default each change is shown with 3 lines of surrounding context, git-diff style. The `--context` flag overrides this; pass `-1` to render the full resource around every change: + +```shell +dokku scheduler-k3s:preview node-js-app --context 0 +dokku scheduler-k3s:preview node-js-app --context -1 +``` + By default any `kind: Secret` resources have their `data` values redacted so secret bytes never appear in terminal scrollback or CI logs. Two flags adjust this behavior: ```shell diff --git a/plugins/scheduler-k3s/preview.go b/plugins/scheduler-k3s/preview.go index c7adb927d..988ab20aa 100644 --- a/plugins/scheduler-k3s/preview.go +++ b/plugins/scheduler-k3s/preview.go @@ -21,7 +21,10 @@ import ( // in the live Helm release for an app and the manifests that the next deploy // would roll out. Only the main app helm release is compared; the auxiliary // config-secret, image-pull-secret, and TLS-secret releases are out of scope. -func CommandPreview(appName string, showSecrets bool, showSecretsDecoded bool) error { +// +// diffContext controls the number of unchanged lines shown around each change; +// pass -1 to print the full resource. +func CommandPreview(appName string, diffContext int, showSecrets bool, showSecretsDecoded bool) error { if err := common.VerifyAppName(appName); err != nil { return err } @@ -80,7 +83,7 @@ func CommandPreview(appName string, showSecrets bool, showSecretsDecoded bool) e options := &helmdiff.Options{ OutputFormat: "diff", - OutputContext: 3, + OutputContext: diffContext, ShowSecrets: showSecrets, ShowSecretsDecoded: showSecretsDecoded, } diff --git a/plugins/scheduler-k3s/src/commands/commands.go b/plugins/scheduler-k3s/src/commands/commands.go index fa34a37e2..02afdb4e6 100644 --- a/plugins/scheduler-k3s/src/commands/commands.go +++ b/plugins/scheduler-k3s/src/commands/commands.go @@ -29,7 +29,7 @@ Additional commands:` scheduler-k3s:initialize [--server-ip SERVER_IP] [--taint-scheduling], Initializes a cluster scheduler-k3s:labels:set () [--process-type PROCESS_TYPE] <--resource-type RESOURCE_TYPE>, Set or clear a label for a given app/process-type/resource-type combination scheduler-k3s:labels:report [|--global] [--format stdout|json] [--process-type PROCESS_TYPE] [--resource-type RESOURCE_TYPE], Displays a scheduler-k3s labels report for one or more apps - scheduler-k3s:preview [--show-secrets] [--show-secrets-decoded], Displays a diff between the current and next deployment for an app + scheduler-k3s:preview [--context N] [--show-secrets] [--show-secrets-decoded], Displays a diff between the current and next deployment for an app scheduler-k3s:profiles:add [--role ROLE] [--insecure-allow-unknown-hosts] [--taint-scheduling] [--kubelet-args KUBELET_ARGS], Adds a node profile to the k3s cluster scheduler-k3s:profiles:list [--format json|stdout], Lists all node profiles in the k3s cluster scheduler-k3s:profiles:remove , Removes a node profile from the k3s cluster diff --git a/plugins/scheduler-k3s/src/subcommands/subcommands.go b/plugins/scheduler-k3s/src/subcommands/subcommands.go index ba3ca56ff..418d4f677 100644 --- a/plugins/scheduler-k3s/src/subcommands/subcommands.go +++ b/plugins/scheduler-k3s/src/subcommands/subcommands.go @@ -160,11 +160,12 @@ func main() { err = scheduler_k3s.CommandLabelsReport(appName, *format, *processType, *resourceType, infoFlag) case "preview": args := flag.NewFlagSet("scheduler-k3s:preview", flag.ExitOnError) + context := args.Int("context", 3, "--context: number of unchanged lines of context around each change (-1 for full output)") showSecrets := args.Bool("show-secrets", false, "--show-secrets: do not redact secret values in the output") showSecretsDecoded := args.Bool("show-secrets-decoded", false, "--show-secrets-decoded: render secret values base64-decoded") args.Parse(os.Args[2:]) appName := args.Arg(0) - err = scheduler_k3s.CommandPreview(appName, *showSecrets, *showSecretsDecoded) + err = scheduler_k3s.CommandPreview(appName, *context, *showSecrets, *showSecretsDecoded) case "profiles:add": args := flag.NewFlagSet("scheduler-k3s:profiles:add", flag.ExitOnError) role := args.String("role", "worker", "role: [ server | worker ]")