Skip to content

Commit 48b4069

Browse files
committed
chore: release v0.7.2
1 parent 47600e4 commit 48b4069

5 files changed

Lines changed: 80 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.7.2] - 2025-11-01
11+
12+
### Added
13+
- **`comet output` now supports filtering to a specific output key** - Added optional third argument to get individual output values
14+
- Usage: `comet output <stack> <component> <key>`
15+
- Outputs only the value (without `key = value` format) for easier use in scripts
16+
- Example: `ENDPOINT=$(comet output production gke cluster_endpoint)`
17+
- Returns clear error if key doesn't exist
18+
1019
## [0.7.1] - 2025-10-29
1120

1221
### Added

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.6.0
1+
VERSION=v0.7.2
22

33
.PHONY: build
44
build:

cmd/output.go

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ import (
1212

1313
var (
1414
outputCmd = &cobra.Command{
15-
Use: "output <stack> [component]",
15+
Use: "output <stack> [component] [key]",
1616
Short: "Show output values from components",
17-
Run: output,
18-
Args: cobra.RangeArgs(1, 2),
17+
Long: `Show output values from components.
18+
19+
If only stack is provided, shows outputs from all components.
20+
If stack and component are provided, shows outputs from that component.
21+
If stack, component, and key are provided, shows only that specific output value.`,
22+
Run: output,
23+
Args: cobra.RangeArgs(1, 3),
1924
}
2025
)
2126

@@ -24,12 +29,44 @@ func init() {
2429
}
2530

2631
func output(cmd *cobra.Command, args []string) {
32+
// Extract the key filter if provided (3rd argument)
33+
var keyFilter string
34+
if len(args) == 3 {
35+
keyFilter = args[2]
36+
// Temporarily reduce args to pass correct stack/component to run()
37+
args = args[:2]
38+
}
39+
2740
run(args, false, func(component *schema.Component, executor schema.Executor) {
2841
out, err := executor.Output(component)
2942
if err != nil {
3043
log.Fatal(err)
3144
}
3245

46+
// If a specific key is requested, only show that
47+
if keyFilter != "" {
48+
if v, ok := out[keyFilter]; ok {
49+
var rawValue interface{}
50+
if err := json.Unmarshal(v.Value, &rawValue); err == nil {
51+
switch val := rawValue.(type) {
52+
case string:
53+
fmt.Printf("\"%s\"\n", val)
54+
case []interface{}, map[string]interface{}:
55+
jsonBytes, _ := json.Marshal(val)
56+
fmt.Printf("%s\n", string(jsonBytes))
57+
default:
58+
fmt.Printf("%v\n", val)
59+
}
60+
} else {
61+
fmt.Printf("\"%s\"\n", v.String())
62+
}
63+
} else {
64+
log.Fatal(fmt.Errorf("output key '%s' not found in component '%s'", keyFilter, component.Name))
65+
}
66+
return
67+
}
68+
69+
// Show all outputs
3370
for k, v := range out {
3471
// Try to unmarshal to detect the actual type
3572
var rawValue interface{}

website/docs/guides/cli-reference.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,31 @@ comet output production gke
237237
```
238238

239239
**Example Output:**
240-
```json
241-
{
242-
"cluster_endpoint": "https://35.123.45.67",
243-
"cluster_ca_certificate": "LS0tLS1CRU...",
244-
"cluster_name": "prod-gke-cluster"
245-
}
240+
```
241+
cluster_endpoint = "https://35.123.45.67"
242+
cluster_ca_certificate = "LS0tLS1CRU..."
243+
cluster_name = "prod-gke-cluster"
244+
```
245+
246+
### Show a Specific Output Key
247+
248+
```bash
249+
comet output <stack> <component> <key>
250+
```
251+
252+
**Example:**
253+
```bash
254+
comet output production gke cluster_endpoint
255+
```
256+
257+
**Example Output:**
258+
```
259+
"https://35.123.45.67"
260+
```
261+
262+
This is useful for scripting and automation:
263+
```bash
264+
ENDPOINT=$(comet output production gke cluster_endpoint)
246265
```
247266

248267
### Show All Outputs from All Components

website/docs/guides/components.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ Example:
121121
comet output dev vpc
122122
```
123123

124+
To get a specific output value:
125+
```bash
126+
comet output dev vpc vpc_id
127+
```
128+
124129
### Destroy Infrastructure
125130

126131
Remove infrastructure:

0 commit comments

Comments
 (0)