setConfigField sets a config field by name
(cfg *HostConfig, key, value string)
| 167 | |
| 168 | // setConfigField sets a config field by name |
| 169 | func setConfigField(cfg *HostConfig, key, value string) error { |
| 170 | value = strings.TrimSpace(value) |
| 171 | |
| 172 | switch key { |
| 173 | case "ServerAliveInterval": |
| 174 | cfg.ServerAliveInterval = value |
| 175 | case "ServerAliveCountMax": |
| 176 | cfg.ServerAliveCountMax = value |
| 177 | case "ForwardAgent": |
| 178 | cfg.ForwardAgent = value |
| 179 | case "IdentityAgent": |
| 180 | cfg.IdentityAgent = value |
| 181 | case "AddKeysToAgent": |
| 182 | cfg.AddKeysToAgent = value |
| 183 | case "UseKeychain": |
| 184 | cfg.UseKeychain = value |
| 185 | case "PubkeyAcceptedAlgorithms": |
| 186 | cfg.PubkeyAcceptedAlgorithms = value |
| 187 | case "StrictHostKeyChecking": |
| 188 | cfg.StrictHostKeyChecking = value |
| 189 | case "UserKnownHostsFile": |
| 190 | cfg.UserKnownHostsFile = value |
| 191 | case "Compression": |
| 192 | cfg.Compression = value |
| 193 | case "TCPKeepAlive": |
| 194 | cfg.TCPKeepAlive = value |
| 195 | default: |
| 196 | return fmt.Errorf("unsupported option: %s", key) |
| 197 | } |
| 198 | |
| 199 | return ValidateHostConfig(cfg) |
| 200 | } |
| 201 | |
| 202 | // getConfigField retrieves a config field value by name |
| 203 | func getConfigField(cfg *HostConfig, key string) string { |
no test coverage detected