diff --git a/internal/status/cmd/status.go b/internal/status/cmd/status.go index 2813ea1fa..4362067a8 100644 --- a/internal/status/cmd/status.go +++ b/internal/status/cmd/status.go @@ -38,6 +38,7 @@ import ( deckhousesettings "github.com/deckhouse/deckhouse-cli/internal/status/objects/settings" "github.com/deckhouse/deckhouse-cli/internal/status/tools/statusresult" "github.com/deckhouse/deckhouse-cli/internal/utilk8s" + "github.com/deckhouse/deckhouse-cli/internal/version" ) var statusLong = templates.LongDesc(` @@ -68,7 +69,9 @@ func runStatus(cmd *cobra.Command, _ []string) error { return fmt.Errorf("failed to setup Kubernetes client: %w", err) } - color.Cyan("\n┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓") + fmt.Println() + fmt.Println(cliBanner(version.Version)) + color.Cyan("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓") color.Cyan("┃ Cluster Status Report ┃") color.Cyan("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n") @@ -80,6 +83,13 @@ func runStatus(cmd *cobra.Command, _ []string) error { return nil } +// cliBanner returns the byline shown above the report header, +// marking which d8 CLI version generated the report. +func cliBanner(v string) string { + faint := color.New(color.Faint).SprintFunc() + return fmt.Sprintf("%s %s", faint("Generated by Deckhouse CLI"), v) +} + func executeAll(ctx context.Context, restConfig *rest.Config, kubeCl kubernetes.Interface) []statusresult.StatusResult { dynamicClient, err := dynamic.NewForConfig(restConfig) if err != nil { diff --git a/internal/status/cmd/status_test.go b/internal/status/cmd/status_test.go new file mode 100644 index 000000000..0afccca4a --- /dev/null +++ b/internal/status/cmd/status_test.go @@ -0,0 +1,32 @@ +/* +Copyright 2026 Flant JSC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package status + +import ( + "strings" + "testing" +) + +func TestCLIBanner(t *testing.T) { + output := cliBanner("v9.9.9-test") + + for _, want := range []string{"Generated by Deckhouse CLI", "v9.9.9-test"} { + if !strings.Contains(output, want) { + t.Errorf("cliBanner output missing %q:\n%s", want, output) + } + } +}