Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ rtk oc get services # OpenShift service list
rtk oc logs <pod> # Deduplicated logs
```

### Infrastructure as Code
```bash
rtk pulumi preview # Strip header/URL/duration noise
rtk pulumi up # Compact apply output
rtk pulumi destroy # Compact destroy output
rtk pulumi refresh # Drift summary
rtk pulumi stack # Stack metadata (strips owner/timestamps)
```

### Data & Analytics
```bash
rtk json config.json # Structure without values
Expand Down
15 changes: 10 additions & 5 deletions src/core/toml_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,11 @@ match_command = "^make\\b"
"poetry-install",
"pre-commit",
"ps",
"pulumi-destroy",
"pulumi-preview",
"pulumi-refresh",
"pulumi-stack",
"pulumi-up",
"quarto-render",
"rsync",
"shellcheck",
Expand Down Expand Up @@ -1622,8 +1627,8 @@ match_command = "^make\\b"
let filters = make_filters(BUILTIN_TOML);
assert_eq!(
filters.len(),
58,
"Expected exactly 58 built-in filters, got {}. \
63,
"Expected exactly 63 built-in filters, got {}. \
Update this count when adding/removing filters in src/filters/.",
filters.len()
);
Expand Down Expand Up @@ -1680,11 +1685,11 @@ expected = "output line 1\noutput line 2"
let combined = format!("{}\n\n{}", BUILTIN_TOML, new_filter);
let filters = make_filters(&combined);

// All 58 existing filters still present + 1 new = 59
// All 63 existing filters still present + 1 new = 64
assert_eq!(
filters.len(),
59,
"Expected 59 filters after concat (58 built-in + 1 new)"
64,
"Expected 64 filters after concat (63 built-in + 1 new)"
);

// New filter is discoverable
Expand Down
15 changes: 15 additions & 0 deletions src/discover/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,21 @@ pub const RULES: &[RtkRule] = &[
subcmd_savings: &[],
subcmd_status: &[],
},
RtkRule {
pattern: r"^pulumi\s+(preview|up|destroy|refresh|stack)(\s|$)",
rtk_cmd: "rtk pulumi",
rewrite_prefixes: &["pulumi"],
category: "Infra",
savings_pct: 45.0,
subcmd_savings: &[
("up", 66.0),
("destroy", 72.0),
("refresh", 35.0),
("preview", 25.0),
("stack", 29.0),
],
subcmd_status: &[],
},
RtkRule {
pattern: r"^quarto\s+render",
rtk_cmd: "rtk quarto",
Expand Down
60 changes: 60 additions & 0 deletions src/filters/pulumi-destroy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[filters.pulumi-destroy]
description = "Compact Pulumi destroy output"
match_command = "^pulumi\\s+destroy(\\s|$)"
strip_ansi = true
strip_lines_matching = [
"^\\s*$",
"^Destroying \\(",
"^Previewing (update|destroy)",
"^View in Browser",
"^View Live:",
"^Duration:",
"^Permalink:",
"^\\s*Type\\s+Name\\s+",
"^Loading policy packs",
"^@ (Previewing (update|destroy)|Destroying)",
"^More information at:",
"^Use `pulumi ",
"^The resources in the stack have been deleted",
"^If you want to remove the stack completely",
"^\\s+-\\s+.*\\bdeleting\\s+\\(",
"^\\s{4,}at\\s+\\S+\\s*\\(",
"^\\s{4,}at\\s+/",
"^\\s+at\\s+processTicksAndRejections",
"^\\s+promise:\\s+Promise",
"^\\s+\\[Circular",
"^\\s*<ref\\s+\\*\\d",
]
on_empty = "pulumi destroy: nothing to destroy"

[[tests.pulumi-destroy]]
name = "strips destroy header and url banner"
input = """
Destroying (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/org/my-proj/dev/updates/43

Type Name Status
- pulumi:pulumi:Stack my-proj-dev deleted
- └─ aws:s3:Bucket my-bucket deleted

Resources:
- 2 deleted

Duration: 7s
"""
expected = """ - pulumi:pulumi:Stack my-proj-dev deleted
- └─ aws:s3:Bucket my-bucket deleted
Resources:
- 2 deleted"""

[[tests.pulumi-destroy]]
name = "on_empty when nothing to destroy"
input = """
Destroying (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/org/my-proj/dev/updates/43

Duration: 1s
"""
expected = "pulumi destroy: nothing to destroy"
59 changes: 59 additions & 0 deletions src/filters/pulumi-preview.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[filters.pulumi-preview]
description = "Compact Pulumi preview output"
match_command = "^pulumi\\s+preview(\\s|$)"
strip_ansi = true
strip_lines_matching = [
"^\\s*$",
"^Previewing update",
"^View in Browser",
"^View Live:",
"^Duration:",
"^Permalink:",
"^\\s*Type\\s+Name\\s+",
"^Loading policy packs",
"^@ Previewing update",
"^More information at:",
"^Use `pulumi ",
"^\\s{4,}at\\s+\\S+\\s*\\(",
"^\\s{4,}at\\s+/",
"^\\s+at\\s+processTicksAndRejections",
"^\\s+promise:\\s+Promise",
"^\\s+\\[Circular",
"^\\s*<ref\\s+\\*\\d",
"^\\s+pulumi:pulumi:Stack\\s+\\S+\\s+running\\s*$",
"^\\s+\\S+\\s+\\S+\\s+\\d+\\s+errors?\\s*$",
"^\\s+\\S+\\s+\\S+(?:\\s+\\S+)?\\s+\\d+\\s+errors?\\s*$",
]
on_empty = "pulumi preview: no changes"

[[tests.pulumi-preview]]
name = "strips header, url and duration noise"
input = """
Previewing update (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/org/my-proj/dev/previews/abc123

Type Name Plan
+ pulumi:pulumi:Stack my-proj-dev create
+ └─ aws:s3:Bucket my-bucket create

Resources:
+ 2 to create

Duration: 3s
"""
expected = """ + pulumi:pulumi:Stack my-proj-dev create
+ └─ aws:s3:Bucket my-bucket create
Resources:
+ 2 to create"""

[[tests.pulumi-preview]]
name = "on_empty when only noise lines present"
input = """
Previewing update (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/org/my-proj/dev/previews/abc123

Duration: 1s
"""
expected = "pulumi preview: no changes"
57 changes: 57 additions & 0 deletions src/filters/pulumi-refresh.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[filters.pulumi-refresh]
description = "Compact Pulumi refresh (state reconciliation) output"
match_command = "^pulumi\\s+refresh(\\s|$)"
strip_ansi = true
strip_lines_matching = [
"^\\s*$",
"^Refreshing \\(",
"^Previewing (refresh|update)",
"^View in Browser",
"^View Live:",
"^Duration:",
"^Permalink:",
"^\\s*Type\\s+Name\\s+",
"^Loading policy packs",
"^@ (Previewing refresh|Refreshing)",
"^More information at:",
"^Use `pulumi ",
"^\\s+.*\\brefreshing\\s+\\(",
"^\\s+[~+\\-]\\s+[^ ]+\\s+\\S+\\s+refreshing\\s*$",
"^\\s{4,}at\\s+\\S+\\s*\\(",
"^\\s{4,}at\\s+/",
"^\\s+at\\s+processTicksAndRejections",
"^\\s+promise:\\s+Promise",
"^\\s+\\[Circular",
"^\\s*<ref\\s+\\*\\d",
]
on_empty = "pulumi refresh: no drift"

[[tests.pulumi-refresh]]
name = "strips refresh header and passes drift rows"
input = """
Refreshing (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/org/my-proj/dev/updates/44

Type Name Status
~ aws:s3:Bucket my-bucket refreshed

Resources:
~ 1 updated

Duration: 4s
"""
expected = """ ~ aws:s3:Bucket my-bucket refreshed
Resources:
~ 1 updated"""

[[tests.pulumi-refresh]]
name = "on_empty when no drift detected"
input = """
Refreshing (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/org/my-proj/dev/updates/44

Duration: 2s
"""
expected = "pulumi refresh: no drift"
48 changes: 48 additions & 0 deletions src/filters/pulumi-stack.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[filters.pulumi-stack]
description = "Compact Pulumi stack (ls/output) output"
match_command = "^pulumi\\s+stack(\\s+(ls|output|history|select|init|rm|rename|tag|unselect|change-secrets-provider)\\b|\\s*$)"
strip_ansi = true
match_output = [
{ pattern = "No stacks found", message = "pulumi stack: empty" },
]
strip_lines_matching = [
"^\\s*$",
"^Please choose a stack",
"^More information at:",
"^Use `pulumi ",
"^Current stack outputs \\(0\\):",
"^\\s+No output values currently",
]
on_empty = "pulumi stack: ok"

[[tests.pulumi-stack]]
name = "no stacks short-circuits"
input = "No stacks found in the current workspace.\n"
expected = "pulumi stack: empty"

[[tests.pulumi-stack]]
name = "keeps stack identity, strips prompt noise"
input = """
Please choose a stack, or create a new one:
Current stack is dev:
Managed by my-user
Owner: my-org
Last updated: 2 hours ago
Pulumi version used: v3.120.0

Current stack resources (3):
TYPE NAME
pulumi:pulumi:Stack my-proj-dev
aws:s3:Bucket my-bucket
aws:iam:Role my-role
"""
expected = """Current stack is dev:
Managed by my-user
Owner: my-org
Last updated: 2 hours ago
Pulumi version used: v3.120.0
Current stack resources (3):
TYPE NAME
pulumi:pulumi:Stack my-proj-dev
aws:s3:Bucket my-bucket
aws:iam:Role my-role"""
64 changes: 64 additions & 0 deletions src/filters/pulumi-up.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[filters.pulumi-up]
description = "Compact Pulumi up (apply) output"
match_command = "^pulumi\\s+up(\\s|$)"
strip_ansi = true
strip_lines_matching = [
"^\\s*$",
"^Updating \\(",
"^Previewing update",
"^View in Browser",
"^View Live:",
"^Duration:",
"^Permalink:",
"^\\s*Type\\s+Name\\s+",
"^Loading policy packs",
"^@ (Previewing update|Updating)",
"^More information at:",
"^Use `pulumi ",
"^\\s+\\+\\s+.*\\bcreating\\s+\\(",
"^\\s+~\\s+.*\\bupdating\\s+\\(",
"^\\s{4,}at\\s+\\S+\\s*\\(",
"^\\s{4,}at\\s+/",
"^\\s+at\\s+processTicksAndRejections",
"^\\s+promise:\\s+Promise",
"^\\s+\\[Circular",
"^\\s*<ref\\s+\\*\\d",
]
on_empty = "pulumi up: no changes"

[[tests.pulumi-up]]
name = "strips update header and url banner"
input = """
Updating (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/org/my-proj/dev/updates/42
Type Name Status
+ pulumi:pulumi:Stack my-proj-dev created
+ └─ aws:s3:Bucket my-bucket created
Outputs:
bucket_name: "my-bucket-abc123"
Resources:
+ 2 created
Duration: 15s
"""
expected = """ + pulumi:pulumi:Stack my-proj-dev created
+ └─ aws:s3:Bucket my-bucket created
Outputs:
bucket_name: \"my-bucket-abc123\"
Resources:
+ 2 created"""

[[tests.pulumi-up]]
name = "on_empty when all noise stripped"
input = """
Updating (dev)
View in Browser (Ctrl+O): https://app.pulumi.com/org/my-proj/dev/updates/42
Duration: 2s
"""
expected = "pulumi up: no changes"
Loading