Skip to content

Commit a33793a

Browse files
committed
Make things more uniform
1 parent 8783bd3 commit a33793a

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

lib/stack-functions

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ stack-create() {
9999
# type: action
100100
# create a new stack
101101
local inputs=$(__bma_read_inputs $@)
102-
local stack=$(_stack_name_arg $inputs)
102+
local stack=$(_stack_name_arg $(__bma_read_resources ${inputs}))
103103
[[ -z ${stack} ]] && __bma_usage "stack [template-file] [parameters-file]" && return 1
104104

105105
local template=$(_stack_template_arg $inputs)
@@ -120,7 +120,7 @@ stack-update() {
120120
# type: action
121121
# update an existing stack
122122
local inputs=$(__bma_read_inputs $@)
123-
local stack=$(_stack_name_arg $inputs)
123+
local stack=$(_stack_name_arg $(__bma_read_resources ${inputs}))
124124
[[ -z ${stack} ]] && __bma_usage "stack [template-file] [parameters-file]" && return 1
125125

126126
local template=$(_stack_template_arg $inputs)
@@ -141,8 +141,7 @@ stack-delete() {
141141
# type: action
142142
# delete an existing stack
143143
local inputs=$(__bma_read_inputs $@)
144-
local first_resource=$(__bma_read_resources ${inputs} | head -1)
145-
local stack=$(_stack_name_arg $first_resource)
144+
local stack=$(_stack_name_arg $(__bma_read_resources ${inputs}))
146145
[[ -z "${stack}" ]] && __bma_usage "stack" && return 1
147146

148147
if aws cloudformation delete-stack --stack-name $stack; then
@@ -155,8 +154,7 @@ stack-failure() {
155154
# return the reason a stack failed to update/create/delete
156155
# FIXME: only grab the latest failure
157156
local inputs=$(__bma_read_inputs $@)
158-
local first_resource=$(__bma_read_resources ${inputs} | head -1)
159-
local stack=$(_stack_name_arg $first_resource)
157+
local stack=$(_stack_name_arg $(__bma_read_resources ${inputs}))
160158
[[ -z "${stack}" ]] && __bma_usage "stack" && return 1
161159

162160
local query='
@@ -178,8 +176,7 @@ stack-events() {
178176
# type: detail
179177
# return the events a stack has experienced
180178
local inputs=$(__bma_read_inputs $@)
181-
local first_resource=$(__bma_read_resources ${inputs} | head -1)
182-
local stack=$(_stack_name_arg $first_resource)
179+
local stack=$(_stack_name_arg $(__bma_read_resources ${inputs}))
183180
[[ -z ${stack} ]] && __bma_usage "stack" && return 1
184181

185182
local query='
@@ -206,7 +203,7 @@ stack-resources() {
206203
# type: detail
207204
# return the resources managed by a stack
208205
local inputs=$(__bma_read_inputs $@)
209-
local stack=$(__bma_read_resources ${inputs} | head -1)
206+
local stack=$(_stack_name_arg $(__bma_read_resources ${inputs}))
210207
[[ -z ${stack} ]] && __bma_usage "stack" && return 1
211208

212209
local query='StackResources[].[ PhysicalResourceId, ResourceType ]'
@@ -242,7 +239,7 @@ stack-parameters() {
242239
# type: detail
243240
# return the parameters applied to a stack
244241
local inputs=$(__bma_read_inputs $@)
245-
local stack=$(__bma_read_resources ${inputs} | head -1)
242+
local stack=$(_stack_name_arg $(__bma_read_resources ${inputs}))
246243
[[ -z ${stack} ]] && __bma_usage "stack" && return 1
247244

248245
local query='sort_by(Stacks[].Parameters[], &ParameterKey)'
@@ -274,8 +271,10 @@ stack-status() {
274271
stack-tail() {
275272
# type: detail
276273
# follow the events occuring for a stack
277-
local stack=$(__bma_read_inputs $@ | cut -f1)
274+
local inputs=$(__bma_read_inputs $@)
275+
local stack=$(_stack_name_arg $(__bma_read_resources ${inputs}))
278276
[[ -z ${stack} ]] && __bma_usage "stack" && return 1
277+
279278
local current
280279
local final_line
281280
local output
@@ -316,7 +315,7 @@ stack-outputs() {
316315
# type: detail
317316
# return the outputs of a stack
318317
local inputs=$(__bma_read_inputs $@)
319-
local stack=$(__bma_read_resources ${inputs} | awk '{print $1}')
318+
local stack=$(_stack_name_arg $(__bma_read_resources ${inputs}))
320319
[[ -z ${stack} ]] && __bma_usage "stack" && return 1
321320

322321
local query='

0 commit comments

Comments
 (0)