validateUserConfig validates the presence of required user config values
(cfg *viper.Viper)
| 66 | |
| 67 | // validateUserConfig validates the presence of required user config values |
| 68 | func validateUserConfig(cfg *viper.Viper) error { |
| 69 | if cfg.GetString("token") == "" { |
| 70 | return fmt.Errorf( |
| 71 | msgWelcomePleaseConfigure, |
| 72 | config.TokenURL(cfg.GetString("apibaseurl")), |
| 73 | BinaryName, |
| 74 | ) |
| 75 | } |
| 76 | if cfg.GetString("workspace") == "" || cfg.GetString("apibaseurl") == "" { |
| 77 | return fmt.Errorf(msgRerunConfigure, BinaryName) |
| 78 | } |
| 79 | return nil |
| 80 | } |
| 81 | |
| 82 | // decodedAPIError decodes and returns the error message from the API response. |
| 83 | // If the message is blank, it returns a fallback message with the status code. |
no test coverage detected