Skip to content

Commit d613b58

Browse files
committed
Only operate on first stack
We already awk in __bma_read_inputs()
1 parent 3cc323c commit d613b58

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/stack-functions

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ stack-update() {
134134

135135
stack-delete() {
136136
local inputs=$(__bma_read_inputs $@)
137-
local first_resource=$(__bma_read_resources ${inputs} | awk '{print $1}')
137+
local first_resource=$(__bma_read_resources ${inputs} | head -1)
138138
local stack=$(_stack_name_arg $first_resource)
139-
[[ -z ${stack} ]]; __bma_usage "stack" && return 1
139+
[[ -z "${stack}" ]] && __bma_usage "stack" && return 1
140140

141141
if aws cloudformation delete-stack --stack-name $stack; then
142142
stack-tail $stack
@@ -146,10 +146,9 @@ stack-delete() {
146146
stack-failure() {
147147
# FIXME: only grab the latest failure
148148
local inputs=$(__bma_read_inputs $@)
149-
local first_resource=$(__bma_read_resources ${inputs} | awk '{print $1}')
149+
local first_resource=$(__bma_read_resources ${inputs} | head -1)
150150
local stack=$(_stack_name_arg $first_resource)
151-
152-
if [[ -z ${stack} ]]; then __bma_error "Usage: $FUNCNAME stack" || return 1; fi
151+
[[ -z "${stack}" ]] && __bma_usage "stack" && return 1
153152

154153
local query='
155154
StackEvents[?contains(ResourceStatus,`FAILED`)].[
@@ -168,7 +167,7 @@ stack-failure() {
168167

169168
stack-events() {
170169
local inputs=$(__bma_read_inputs $@)
171-
local first_resource=$(__bma_read_resources ${inputs} | awk '{print $1}')
170+
local first_resource=$(__bma_read_resources ${inputs} | head -1)
172171
local stack=$(_stack_name_arg $first_resource)
173172
[[ -z ${stack} ]] && __bma_usage "stack" && return 1
174173

@@ -194,7 +193,7 @@ stack-events() {
194193

195194
stack-resources() {
196195
local inputs=$(__bma_read_inputs $@)
197-
local stack=$(__bma_read_resources ${inputs} | awk '{print $1}')
196+
local stack=$(__bma_read_resources ${inputs} | head -1)
198197
[[ -z ${stack} ]] && __bma_usage "stack" && return 1
199198

200199
local query='StackResources[].[ PhysicalResourceId, ResourceType ]'
@@ -222,7 +221,7 @@ stack-instances() {
222221

223222
stack-parameters() {
224223
local inputs=$(__bma_read_inputs $@)
225-
local stack=$(__bma_read_resources ${inputs} | awk '{print $1}')
224+
local stack=$(__bma_read_resources ${inputs} | head -1)
226225
[[ -z ${stack} ]] && __bma_usage "stack" && return 1
227226

228227
local query='

0 commit comments

Comments
 (0)