()
| 593 | } |
| 594 | |
| 595 | func readCLIConfig() (cliconfig.CLIConfig, error) { |
| 596 | if !files.IsFile(_cliConfigPath) { |
| 597 | cliConfig := cliconfig.CLIConfig{} |
| 598 | |
| 599 | if err := cliConfig.Validate(); err != nil { |
| 600 | return cliconfig.CLIConfig{}, err // unexpected |
| 601 | } |
| 602 | |
| 603 | // create file so that the file created by the manager container maintains current user permissions |
| 604 | if err := writeCLIConfig(cliConfig); err != nil { |
| 605 | return cliconfig.CLIConfig{}, errors.Wrap(err, "unable to save CLI configuration file") |
| 606 | } |
| 607 | |
| 608 | return cliConfig, nil |
| 609 | } |
| 610 | |
| 611 | cliConfig := cliconfig.CLIConfig{} |
| 612 | errs := cr.ParseYAMLFile(&cliConfig, _cliConfigValidation, _cliConfigPath) |
| 613 | if errors.HasError(errs) { |
| 614 | return cliconfig.CLIConfig{}, errors.FirstError(errs...) |
| 615 | } |
| 616 | |
| 617 | if err := cliConfig.Validate(); err != nil { |
| 618 | return cliconfig.CLIConfig{}, errors.Wrap(err, _cliConfigPath) |
| 619 | } |
| 620 | |
| 621 | return cliConfig, nil |
| 622 | } |
| 623 | |
| 624 | func writeCLIConfig(cliConfig cliconfig.CLIConfig) error { |
| 625 | if err := cliConfig.Validate(); err != nil { |
no test coverage detected