Skip to content

Commit 605a343

Browse files
authored
chore(cli): limit pipeline delete to prompt about deleting secret only when secret exists (#1880)
Now that there are non-GitHub source options, there will be pipeline sources without secrets. `pipeline delete` should prompt "Are you sure you want to delete the source secret...?" only when there is a secret. Fixes #1827. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 2e6df56 commit 605a343

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

internal/pkg/cli/pipeline_delete.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ func (o *deletePipelineOpts) readPipelineManifest() error {
153153
}
154154

155155
func (o *deletePipelineOpts) deleteSecret() error {
156+
if o.PipelineSecret == "" {
157+
return nil
158+
}
156159
if !o.shouldDeleteSecret {
157160
confirmDeletion, err := o.prompt.Confirm(
158161
fmt.Sprintf(pipelineSecretDeleteConfirmPrompt, o.PipelineSecret, o.PipelineName),

internal/pkg/cli/pipeline_delete_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,20 @@ func TestDeletePipelineOpts_Execute(t *testing.T) {
191191

192192
wantedError error
193193
}{
194+
"skips delete secret confirmation (and deletion attempt) if there is no secret": {
195+
inAppName: testAppName,
196+
inPipelineName: testPipelineName,
197+
setupMocks: func(mocks deletePipelineMocks) {
198+
gomock.InOrder(
199+
mocks.secretsmanager.EXPECT().DeleteSecret(gomock.Any()).Times(0),
200+
mocks.prog.EXPECT().Start(fmt.Sprintf(fmtDeletePipelineStart, testPipelineName, testAppName)),
201+
mocks.deployer.EXPECT().DeletePipeline(testPipelineName).Return(nil),
202+
mocks.prog.EXPECT().Stop(log.Ssuccessf(fmtDeletePipelineComplete, testPipelineName, testAppName)),
203+
)
204+
},
205+
wantedError: nil,
206+
},
207+
194208
"skips delete secret confirmation when flag is specified": {
195209
deleteSecret: true,
196210
inAppName: testAppName,

0 commit comments

Comments
 (0)