DecryptConfigSensitiveFields decrypts sensitive fields in the entire Config. This includes both profile-based and legacy fields.
(cfg *Config)
| 289 | // DecryptConfigSensitiveFields decrypts sensitive fields in the entire Config. |
| 290 | // This includes both profile-based and legacy fields. |
| 291 | func DecryptConfigSensitiveFields(cfg *Config) error { |
| 292 | // Decrypt profile fields |
| 293 | for name, profile := range cfg.Profiles { |
| 294 | if err := DecryptSensitiveFields(&profile); err != nil { |
| 295 | return fmt.Errorf("decrypt profile %s: %w", name, err) |
| 296 | } |
| 297 | cfg.Profiles[name] = profile |
| 298 | } |
| 299 | |
| 300 | // Decrypt legacy fields |
| 301 | if cfg.Password != "" { |
| 302 | var err error |
| 303 | cfg.Password, err = DecryptField(cfg.Password) |
| 304 | if err != nil { |
| 305 | return fmt.Errorf("decrypt legacy password: %w", err) |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | if cfg.TokenSecret != "" { |
| 310 | var err error |
| 311 | cfg.TokenSecret, err = DecryptField(cfg.TokenSecret) |
| 312 | if err != nil { |
| 313 | return fmt.Errorf("decrypt legacy token_secret: %w", err) |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | if cfg.Plugins.Ansible.DefaultPassword != "" { |
| 318 | var err error |
| 319 | cfg.Plugins.Ansible.DefaultPassword, err = DecryptField(cfg.Plugins.Ansible.DefaultPassword) |
| 320 | if err != nil { |
| 321 | return fmt.Errorf("decrypt ansible default_password: %w", err) |
| 322 | } |
| 323 | } |
| 324 | if cfg.Plugins.Ansible.Bootstrap.Password != "" { |
| 325 | var err error |
| 326 | cfg.Plugins.Ansible.Bootstrap.Password, err = DecryptField(cfg.Plugins.Ansible.Bootstrap.Password) |
| 327 | if err != nil { |
| 328 | return fmt.Errorf("decrypt ansible bootstrap password: %w", err) |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | return nil |
| 333 | } |
no test coverage detected