Skip to content

Commit 73a197b

Browse files
authored
Merge pull request #54 from Roming22/feat/verbose-integration
feat(integration): add verbose flag to NewIntegration command
2 parents 6bbd344 + 526e9ce commit 73a197b

14 files changed

Lines changed: 82 additions & 40 deletions

File tree

docs/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ graph LR
6060
| `internal/chartfs/` | Filesystem abstraction for charts | No | `ChartFS`, `OverlayFS`, `BufferedFiles` |
6161
| `internal/installer/` | Orchestrates chart installation and MCP Jobs | No | `Installer`, `Job` |
6262
| `internal/k8s/` | Kubernetes client utilities | No | `Interface`, `Kube` |
63-
| `internal/flags/` | Global CLI flag definitions | No | `Flags` (Debug, DryRun, KubeConfigPath, LogLevel, Timeout) |
63+
| `internal/flags/` | Global CLI flag definitions | No | `Flags` (DryRun, KubeConfigPath, LogLevel, Timeout, Verbose) |
6464
| `internal/subcmd/` | Standard CLI subcommand implementations | No | deploy, config, topology, integration, mcp-server, template, installer |
6565
| `internal/mcptools/` | MCP tool definitions for AI assistants | No | `Interface`, `MCPToolsBuilder` |
6666
| `internal/annotations/` | Helm chart annotation constants | No | `helmet.redhat-appstudio.github.com/*` |

docs/cli-reference.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ These flags are available for every command:
2626

2727
| Flag | Type | Default | Description |
2828
|------|------|---------|-------------|
29-
| `--debug` | bool | `false` | Enable debug mode (verbose logging) |
3029
| `--dry-run` | bool | `false` | Enable dry-run mode (no cluster mutations) |
3130
| `--kube-config` | string | `$KUBECONFIG` or `~/.kube/config` | Path to kubeconfig file |
3231
| `--log-level` | string | `warn` | Log verbosity level (`debug`, `info`, `warn`, `error`) |
3332
| `--timeout` | duration | `15m` | Helm client timeout duration |
33+
| `--verbose` / `-v` | bool | `false` | Verbose output |
3434
| `--version` | bool | `false` | Show application version and commit ID |
3535

3636
Flags use Cobra's persistent flag mechanism, inheriting from the root command to all subcommands.
@@ -110,8 +110,8 @@ helmet-ex deploy
110110
# Deploy single chart
111111
helmet-ex deploy charts/helmet-product-a
112112

113-
# Dry-run with debug output
114-
helmet-ex deploy --dry-run --debug
113+
# Dry-run with verbose output
114+
helmet-ex deploy --dry-run --verbose
115115

116116
# Use custom values template
117117
helmet-ex deploy --values-template /path/to/values.yaml.tpl
@@ -235,8 +235,8 @@ helmet-ex template --show-values=false charts/helmet-product-a
235235
# Show both values and manifests
236236
helmet-ex template charts/helmet-product-a
237237

238-
# Debug mode shows raw values before template rendering
239-
helmet-ex template --debug charts/helmet-product-a
238+
# Verbose mode shows raw values before template rendering
239+
helmet-ex template --verbose charts/helmet-product-a
240240
```
241241

242242
### `installer`

docs/mcp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ When `deploy` is invoked, the MCP server — authenticated via the user's kubeco
7575
2. **`ClusterRoleBinding`** named `{appName}`, binding the `ServiceAccount` to the `cluster-admin` `ClusterRole` (via server-side apply)
7676
3. **`Job`** named `{appName}-deploy-job` (via `Create` — only one Job is allowed; use `force: true` to replace an existing one) with:
7777
- Container image: the consumer's installer application image (from `WithMCPImage()` or `--image`)
78-
- Args: `["deploy"]` (with optional `--debug`, `--dry-run`)
78+
- Args: `["deploy"]` (with optional `--verbose`, `--dry-run`)
7979
- Env: `KUBECONFIG=""` (forces [in-cluster authentication](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#service-account-tokens))
8080
- RestartPolicy: `Never`, BackoffLimit: `0`
8181
- Labels: `type=installer-job.helmet.redhat-appstudio.github.com`
@@ -171,7 +171,7 @@ All tools are prefixed with `<app-name>_` (e.g., `helmet-ex_config_get`).
171171

172172
| Tool | Arguments | Description |
173173
|------|-----------|-------------|
174-
| `deploy` | `dry_run` (bool, default true), `force` (bool), `debug` (bool) | Creates deployment Job |
174+
| `deploy` | `dry-run` (bool, default true), `force` (bool), `verbose` (bool) | Creates deployment Job |
175175
| `status` | None | Reports current phase and suggested next action |
176176

177177
### Topology and Notes

framework/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (a *App) setupRootCmd() error {
8585

8686
// Register standard subcommands.
8787
a.rootCmd.AddCommand(subcmd.NewIntegration(
88-
a.AppCtx, runCtx, a.integrationManager,
88+
a.AppCtx, runCtx, a.integrationManager, a.flags,
8989
))
9090

9191
// Use default builder if none provided.

internal/deployer/helm.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ var ErrUpgradeFailed = errors.New("upgrade failed")
4444

4545
// printRelease prints the Helm release information.
4646
func (h *Helm) printRelease(rel *release.Release) {
47-
// In debug mode, print the configuration values using key-value pairs.
48-
if !h.flags.DryRun && h.flags.Debug {
47+
// In verbose mode, print the configuration values using key-value pairs.
48+
if !h.flags.DryRun && h.flags.Verbose {
4949
printer.ValuesPrinter("Config", rel.Config)
5050
}
5151
printer.HelmReleasePrinter(rel)
52-
// Print extended release information only in dry-run or debug mode. This
52+
// Print extended release information only in dry-run or verbose mode. This
5353
// allows rendering chart templates (dry-run) while inspecting the release
5454
// manifests.
55-
if h.flags.DryRun || h.flags.Debug {
55+
if h.flags.DryRun || h.flags.Verbose {
5656
printer.HelmExtendedReleasePrinter(rel)
5757
}
5858
printer.HelmReleaseNotesPrinter(rel)

internal/flags/flags.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515

1616
// Flags represents the global flags for the application.
1717
type Flags struct {
18-
Debug bool // debug mode
1918
DryRun bool // dry-run mode
19+
Verbose bool // verbose output
2020
KubeConfigPath string // path to the kubeconfig file
2121
LogLevel *slog.Level // log verbosity level
2222
Timeout time.Duration // helm client timeout
@@ -25,9 +25,15 @@ type Flags struct {
2525

2626
// PersistentFlags sets up the global flags.
2727
func (f *Flags) PersistentFlags(p *pflag.FlagSet) {
28-
p.BoolVar(&f.Debug, "debug", f.Debug, "enable debug mode")
2928
p.BoolVar(&f.DryRun, "dry-run", f.DryRun, "enable dry-run mode")
3029
p.BoolVar(&f.Version, "version", f.Version, "show the application version")
30+
p.BoolVarP(
31+
&f.Verbose,
32+
"verbose",
33+
"v",
34+
f.Verbose,
35+
"Enable verbose output",
36+
)
3137
p.StringVar(
3238
&f.KubeConfigPath,
3339
"kube-config",
@@ -60,7 +66,7 @@ func (f *Flags) GetLogger(out io.Writer) *slog.Logger {
6066

6167
// LoggerWith returns a logger with contextual information.
6268
func (f *Flags) LoggerWith(l *slog.Logger) *slog.Logger {
63-
return l.With("debug", f.Debug, "dry-run", f.DryRun, "timeout", f.Timeout)
69+
return l.With("dry-run", f.DryRun, "timeout", f.Timeout, "verbose", f.Verbose)
6470
}
6571

6672
// ShowVersion shows the application version.
@@ -83,11 +89,11 @@ func NewFlags() *Flags {
8389
kubeConfigPath = path.Join(usr.HomeDir, ".kube", "config")
8490
}
8591
return &Flags{
86-
Debug: false,
8792
DryRun: false,
8893
KubeConfigPath: kubeConfigPath,
8994
LogLevel: &defaultLogLevel,
9095
Timeout: 15 * time.Minute,
96+
Verbose: false,
9197
Version: false,
9298
}
9399
}

internal/flags/flags_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package flags
2+
3+
import (
4+
"testing"
5+
6+
"github.com/spf13/pflag"
7+
)
8+
9+
func TestPersistentFlags_VerboseRegistered(t *testing.T) {
10+
f := NewFlags()
11+
fs := pflag.NewFlagSet("test", pflag.ContinueOnError)
12+
f.PersistentFlags(fs)
13+
14+
flag := fs.Lookup("verbose")
15+
if flag == nil {
16+
t.Fatal(`expected persistent flag "verbose"`)
17+
}
18+
if flag.Shorthand != "v" {
19+
t.Errorf("shorthand: got %q, want %q", flag.Shorthand, "v")
20+
}
21+
if flag.DefValue != "false" {
22+
t.Errorf("DefValue: got %q, want %q", flag.DefValue, "false")
23+
}
24+
}

internal/installer/job.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (j *Job) applyClusterRoleBinding(
191191
// in-cluster.
192192
func (j *Job) createJob(
193193
ctx context.Context,
194-
debug, dryRun bool,
194+
verbose, dryRun bool,
195195
namespace, image string,
196196
) error {
197197
bc, err := j.kube.BatchV1ClientSet("")
@@ -201,8 +201,8 @@ func (j *Job) createJob(
201201

202202
// Setting up the list of arguments for the deployment job.
203203
args := []string{"deploy"}
204-
if debug {
205-
args = append(args, "--debug")
204+
if verbose {
205+
args = append(args, "--verbose")
206206
args = append(args, "--log-level=debug")
207207
}
208208
if dryRun {
@@ -273,7 +273,7 @@ func (j *Job) GetJobLogFollowCmd(namespace string) string {
273273
// creates the job.
274274
func (j *Job) Run(
275275
ctx context.Context,
276-
debug, dryRun, force bool,
276+
verbose, dryRun, force bool,
277277
namespace, image string,
278278
) error {
279279
state, err := j.GetState(ctx)
@@ -301,7 +301,7 @@ func (j *Job) Run(
301301
return fmt.Errorf("unable to apply the cluster role binding: %w", err)
302302
}
303303
// Creating the job itself.
304-
return j.createJob(ctx, debug, dryRun, namespace, image)
304+
return j.createJob(ctx, verbose, dryRun, namespace, image)
305305
}
306306

307307
// NewJob instantiates a new Job object.

internal/mcptools/deploytools.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const (
2929
// deploySuffix deploy tool name suffix.
3030
deploySuffix = "_deploy"
3131

32-
// DebugArg enables debug mode for the deployment job.
33-
DebugArg = "debug"
32+
// VerboseArg enables verbose mode for the deployment job.
33+
VerboseArg = "verbose"
3434
// DryRunArg runs the deployment job on dry-run.
3535
DryRunArg = "dry-run"
3636
// ForceArg forces the recreation of the deployment job.
@@ -61,10 +61,10 @@ place. Inspect the error message below to assess the issue.`,
6161
}
6262

6363
// Deployment job flags.
64-
var debug, dryRun, force bool
64+
var verbose, dryRun, force bool
6565

66-
if v, ok := ctr.GetArguments()[DebugArg].(bool); ok {
67-
debug = v
66+
if v, ok := ctr.GetArguments()[VerboseArg].(bool); ok {
67+
verbose = v
6868
}
6969
if v, ok := ctr.GetArguments()[DryRunArg].(bool); ok {
7070
dryRun = v
@@ -77,7 +77,7 @@ place. Inspect the error message below to assess the issue.`,
7777
logsCmd := d.job.GetJobLogFollowCmd(cfg.Namespace())
7878

7979
// Issue the deployment job using the informed flags.
80-
err = d.job.Run(ctx, debug, dryRun, force, cfg.Namespace(), d.image)
80+
err = d.job.Run(ctx, verbose, dryRun, force, cfg.Namespace(), d.image)
8181
if err != nil {
8282
return mcp.NewToolResultError(fmt.Sprintf(`
8383
Unable to issue the deployment Job, it returned the following error:
@@ -101,14 +101,14 @@ deployment status; this can take a few minutes depending on cluster performance.
101101
Use the tool periodically to verify that the deployment is proceeding as expected.
102102
103103
Informed flags:
104-
- debug: %v
104+
- verbose: %v
105105
- dry-run: %v
106106
- force: %v
107107
108108
You can follow the Kubernetes Job logs by running:
109109
110110
%s`,
111-
d.appName+statusSuffix, debug, dryRun, force, logsCmd,
111+
d.appName+statusSuffix, verbose, dryRun, force, logsCmd,
112112
)), nil
113113
}
114114

@@ -143,9 +143,9 @@ Job and create a new one regardless of its state.`,
143143
mcp.DefaultBool(false),
144144
),
145145
mcp.WithBoolean(
146-
DebugArg,
146+
VerboseArg,
147147
mcp.Description(`
148-
Sets the debug mode for the deployment job. This will enable verbose logging and
148+
Sets verbose mode for the deployment job. This enables debug logging and
149149
additional platform deployment information.`,
150150
),
151151
mcp.DefaultBool(false),

internal/subcmd/deploy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ subcommand to configure them. For example:
134134
if err != nil {
135135
return err
136136
}
137-
if d.flags.Debug {
137+
if d.flags.Verbose {
138138
i.PrintRawValues()
139139
}
140140

141141
if err := i.RenderValues(); err != nil {
142142
return err
143143
}
144-
if d.flags.Debug {
144+
if d.flags.Verbose {
145145
i.PrintValues()
146146
}
147147

0 commit comments

Comments
 (0)