Skip to content

Commit 733087f

Browse files
Show reason field for non-active stack states and fix UpdateStack interface
- Display reason: whenever stack state is non-ACTIVE, even if reason is empty - Update CloudControllerClient and Actor interfaces for 3-arg UpdateStack - Regenerate fakes for updated interfaces - Fix duplicate Execute call in update-stack reason test Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent f0bc9fa commit 733087f

File tree

9 files changed

+50
-45
lines changed

9 files changed

+50
-45
lines changed

actor/v7action/cloud_controller_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ type CloudControllerClient interface {
138138
GetAppFeature(appGUID string, featureName string) (resources.ApplicationFeature, ccv3.Warnings, error)
139139
GetStacks(query ...ccv3.Query) ([]resources.Stack, ccv3.Warnings, error)
140140
GetStagingSecurityGroups(spaceGUID string, queries ...ccv3.Query) ([]resources.SecurityGroup, ccv3.Warnings, error)
141-
UpdateStack(stackGUID string, state string) (resources.Stack, ccv3.Warnings, error)
141+
UpdateStack(stackGUID string, state string, reason string) (resources.Stack, ccv3.Warnings, error)
142142
GetTask(guid string) (resources.Task, ccv3.Warnings, error)
143143
GetUser(userGUID string) (resources.User, ccv3.Warnings, error)
144144
GetUsers(query ...ccv3.Query) ([]resources.User, ccv3.Warnings, error)

actor/v7action/stack_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ var _ = Describe("Stack", func() {
238238
var (
239239
stackGUID string
240240
state string
241+
reason string
241242
stack resources.Stack
242243
warnings Warnings
243244
executeErr error
@@ -246,10 +247,11 @@ var _ = Describe("Stack", func() {
246247
BeforeEach(func() {
247248
stackGUID = "some-stack-guid"
248249
state = "DEPRECATED"
250+
reason = ""
249251
})
250252

251253
JustBeforeEach(func() {
252-
stack, warnings, executeErr = actor.UpdateStack(stackGUID, state)
254+
stack, warnings, executeErr = actor.UpdateStack(stackGUID, state, reason)
253255
})
254256

255257
When("the cloud controller request is successful", func() {
@@ -277,9 +279,10 @@ var _ = Describe("Stack", func() {
277279
}))
278280

279281
Expect(fakeCloudControllerClient.UpdateStackCallCount()).To(Equal(1))
280-
actualGUID, actualState := fakeCloudControllerClient.UpdateStackArgsForCall(0)
282+
actualGUID, actualState, actualReason := fakeCloudControllerClient.UpdateStackArgsForCall(0)
281283
Expect(actualGUID).To(Equal(stackGUID))
282284
Expect(actualState).To(Equal(state))
285+
Expect(actualReason).To(Equal(reason))
283286
})
284287
})
285288

actor/v7action/v7actionfakes/fake_cloud_controller_client.go

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

command/v7/actor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ type Actor interface {
179179
GetStackByName(stackName string) (resources.Stack, v7action.Warnings, error)
180180
GetStackLabels(stackName string) (map[string]types.NullString, v7action.Warnings, error)
181181
GetStacks(string) ([]resources.Stack, v7action.Warnings, error)
182-
UpdateStack(stackGUID string, state string) (resources.Stack, v7action.Warnings, error)
182+
UpdateStack(stackGUID string, state string, reason string) (resources.Stack, v7action.Warnings, error)
183183
GetStreamingLogsForApplicationByNameAndSpace(appName string, spaceGUID string, client sharedaction.LogCacheClient) (<-chan sharedaction.LogMessage, <-chan error, context.CancelFunc, v7action.Warnings, error)
184184
GetTaskBySequenceIDAndApplication(sequenceID int, appGUID string) (resources.Task, v7action.Warnings, error)
185185
GetUAAAPIVersion() (string, error)

command/v7/stack_command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func (cmd *StackCommand) displayStackInfo() error {
7070
if stack.State != "" {
7171
displayTable = append(displayTable, []string{cmd.UI.TranslateText("state:"), stack.State})
7272

73-
// Add reason only if state is not ACTIVE and reason is present
74-
if stack.State != resources.StackStateActive && stack.StateReason != "" {
73+
// Add reason whenever state is not ACTIVE
74+
if stack.State != resources.StackStateActive {
7575
displayTable = append(displayTable, []string{cmd.UI.TranslateText("reason:"), stack.StateReason})
7676
}
7777
}

command/v7/stack_command_test.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -196,29 +196,29 @@ var _ = Describe("Stack Command", func() {
196196
})
197197
})
198198

199-
Context("When the state is not ACTIVE but has no reason", func() {
200-
BeforeEach(func() {
201-
stack := resources.Stack{
202-
Name: "some-stack-name",
203-
GUID: "some-stack-guid",
204-
Description: "some-stack-desc",
205-
State: "RESTRICTED",
206-
}
207-
fakeActor.GetStackByNameReturns(stack, v7action.Warnings{}, nil)
208-
})
199+
Context("When the state is not ACTIVE but has no reason", func() {
200+
BeforeEach(func() {
201+
stack := resources.Stack{
202+
Name: "some-stack-name",
203+
GUID: "some-stack-guid",
204+
Description: "some-stack-desc",
205+
State: "RESTRICTED",
206+
}
207+
fakeActor.GetStackByNameReturns(stack, v7action.Warnings{}, nil)
208+
})
209209

210-
It("Displays the stack information with state but no reason", func() {
211-
Expect(executeErr).ToNot(HaveOccurred())
212-
Expect(fakeActor.GetStackByNameArgsForCall(0)).To(Equal("some-stack-name"))
213-
Expect(fakeActor.GetStackByNameCallCount()).To(Equal(1))
210+
It("Displays the stack information with state and empty reason", func() {
211+
Expect(executeErr).ToNot(HaveOccurred())
212+
Expect(fakeActor.GetStackByNameArgsForCall(0)).To(Equal("some-stack-name"))
213+
Expect(fakeActor.GetStackByNameCallCount()).To(Equal(1))
214214

215-
Expect(testUI.Out).To(Say("name:\\s+some-stack-name"))
216-
Expect(testUI.Out).To(Say("description:\\s+some-stack-desc"))
217-
Expect(testUI.Out).To(Say("state:\\s+RESTRICTED"))
218-
Expect(testUI.Out).NotTo(Say("reason:"))
219-
})
215+
Expect(testUI.Out).To(Say("name:\\s+some-stack-name"))
216+
Expect(testUI.Out).To(Say("description:\\s+some-stack-desc"))
217+
Expect(testUI.Out).To(Say("state:\\s+RESTRICTED"))
218+
Expect(testUI.Out).To(Say("reason:"))
220219
})
221220
})
221+
})
222222

223223
When("The Stack does not Exist", func() {
224224
expectedError := actionerror.StackNotFoundError{Name: "some-stack-name"}

command/v7/update_stack_command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ func (cmd UpdateStackCommand) Execute(args []string) error {
7373
{cmd.UI.TranslateText("state:"), updatedStack.State},
7474
}
7575

76-
// Add reason if it's present
77-
if updatedStack.StateReason != "" {
76+
// Add reason whenever state is not ACTIVE
77+
if updatedStack.State != resources.StackStateActive {
7878
displayTable = append(displayTable, []string{cmd.UI.TranslateText("reason:"), updatedStack.StateReason})
7979
}
8080

command/v7/update_stack_command_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ var _ = Describe("update-stack Command", func() {
210210
})
211211

212212
It("passes the reason to the actor and displays it", func() {
213-
executeErr = cmd.Execute(args)
214-
215213
Expect(executeErr).ToNot(HaveOccurred())
216214

217215
Expect(fakeActor.UpdateStackCallCount()).To(Equal(1))

command/v7/v7fakes/fake_actor.go

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)