mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
feat: Allow unsetting ssh config options from deployment (#6847)
This allows deleting ssh config options
This commit is contained in:
@ -62,7 +62,7 @@ func (o *sshConfigOptions) addOptions(options ...string) error {
|
||||
}
|
||||
|
||||
func (o *sshConfigOptions) addOption(option string) error {
|
||||
key, _, err := codersdk.ParseSSHConfigOption(option)
|
||||
key, value, err := codersdk.ParseSSHConfigOption(option)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -77,11 +77,20 @@ func (o *sshConfigOptions) addOption(option string) error {
|
||||
continue
|
||||
}
|
||||
if strings.EqualFold(existingKey, key) {
|
||||
o.sshOptions[i] = option
|
||||
if value == "" {
|
||||
// Delete existing option.
|
||||
o.sshOptions = append(o.sshOptions[:i], o.sshOptions[i+1:]...)
|
||||
} else {
|
||||
// Override existing option.
|
||||
o.sshOptions[i] = option
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
o.sshOptions = append(o.sshOptions, option)
|
||||
// Only append the option if it is not empty.
|
||||
if value != "" {
|
||||
o.sshOptions = append(o.sshOptions, option)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user