enrichClientError tries to add Hint messages to errors from managed client. It will also do an inferred-registry check on the failed client (which is one more than the last one on the list) and add the registry hint if needed.
(clientsList managedplugin.Clients, inferredList []bool, err error)
| 135 | // enrichClientError tries to add Hint messages to errors from managed client. |
| 136 | // It will also do an inferred-registry check on the failed client (which is one more than the last one on the list) and add the registry hint if needed. |
| 137 | func enrichClientError(clientsList managedplugin.Clients, inferredList []bool, err error) error { |
| 138 | if err == nil { |
| 139 | return nil |
| 140 | } |
| 141 | if errors.Is(err, managedplugin.ErrLoginRequired) { |
| 142 | return fmt.Errorf("%w. Hint: You must be logged in via `cloudquery login` or you must use a valid API Key which can be generated at `cloud.cloudquery.io`", err) |
| 143 | } |
| 144 | if errors.Is(err, managedplugin.ErrTeamRequired) { |
| 145 | return fmt.Errorf("%w. Hint: use `cloudquery switch` to set a team", err) |
| 146 | } |
| 147 | |
| 148 | if !strings.Contains(strings.ToLower(err.Error()), "not found") { |
| 149 | return err |
| 150 | } |
| 151 | l := len(clientsList) |
| 152 | il := len(inferredList) |
| 153 | if l > il { |
| 154 | return err // shouldn't happen |
| 155 | } |
| 156 | if !inferredList[l] { |
| 157 | return err |
| 158 | } |
| 159 | |
| 160 | return fmt.Errorf("%w. Hint: make sure to use the latest plugin version from www.cloudquery.io/hub or to keep using an outdated version add `registry: github` to your configuration", err) |
| 161 | } |
no test coverage detected