@@ -114,17 +114,17 @@ func configSSH() *cobra.Command {
114
114
}
115
115
116
116
// Keep track of changes we are making.
117
- var actions []string
117
+ var changes []string
118
118
119
119
// Check for presence of old config format and
120
120
// remove if present.
121
121
configModified , ok := stripOldConfigBlock (configRaw )
122
122
if ok {
123
- actions = append (actions , fmt .Sprintf ("Remove old config block (START-CODER/END-CODER) from %s" , sshConfigFileOrig ))
123
+ changes = append (changes , fmt .Sprintf ("Remove old config block (START-CODER/END-CODER) from %s" , sshConfigFileOrig ))
124
124
}
125
125
126
126
if found := bytes .Index (configModified , []byte (sshConfigIncludeStatement )); found == - 1 || (found > 0 && configModified [found - 1 ] != '\n' ) {
127
- actions = append (actions , fmt .Sprintf ("Add 'Include coder' to %s" , sshConfigFileOrig ))
127
+ changes = append (changes , fmt .Sprintf ("Add 'Include coder' to %s" , sshConfigFileOrig ))
128
128
// Separate Include statement from user content with an empty newline.
129
129
configModified = bytes .TrimRight (configModified , "\n " )
130
130
sep := "\n \n "
@@ -234,19 +234,20 @@ func configSSH() *cobra.Command {
234
234
modifyCoderConfig := ! bytes .Equal (coderConfigRaw , buf .Bytes ())
235
235
if modifyCoderConfig {
236
236
if len (coderConfigRaw ) == 0 {
237
- actions = append (actions , fmt .Sprintf ("Write auto-generated coder config file to %s" , coderConfigFileOrig ))
237
+ changes = append (changes , fmt .Sprintf ("Write auto-generated coder config file to %s" , coderConfigFileOrig ))
238
238
} else {
239
- actions = append (actions , fmt .Sprintf ("Update auto-generated coder config file in %s" , coderConfigFileOrig ))
239
+ changes = append (changes , fmt .Sprintf ("Update auto-generated coder config file in %s" , coderConfigFileOrig ))
240
240
}
241
241
}
242
242
243
243
if showDiff {
244
- if len (actions ) > 0 {
244
+ if len (changes ) > 0 {
245
245
// Write to stderr to avoid dirtying the diff output.
246
246
_ , _ = fmt .Fprint (cmd .ErrOrStderr (), "Changes:\n \n " )
247
- for _ , action := range actions {
248
- _ , _ = fmt .Fprintf (cmd .ErrOrStderr (), "* %s\n " , action )
247
+ for _ , change := range changes {
248
+ _ , _ = fmt .Fprintf (cmd .ErrOrStderr (), "* %s\n " , change )
249
249
}
250
+ } else {
250
251
}
251
252
252
253
for _ , diffFn := range []func () ([]byte , error ){
@@ -266,9 +267,9 @@ func configSSH() *cobra.Command {
266
267
return nil
267
268
}
268
269
269
- if len (actions ) > 0 {
270
+ if len (changes ) > 0 {
270
271
_ , err = cliui .Prompt (cmd , cliui.PromptOptions {
271
- Text : fmt .Sprintf ("The following changes will be made to your SSH configuration (use --diff to see changes):\n \n * %s\n \n Continue?" , strings .Join (actions , "\n * " )),
272
+ Text : fmt .Sprintf ("The following changes will be made to your SSH configuration (use --diff to see changes):\n \n * %s\n \n Continue?" , strings .Join (changes , "\n * " )),
272
273
IsConfirm : true ,
273
274
})
274
275
if err != nil {
0 commit comments