(client *httpc.Client)
| 220 | } |
| 221 | |
| 222 | func (c *ServerConfig) GetHasuraInternalServerConfig(client *httpc.Client) error { |
| 223 | var op errors.Op = "cli.ServerConfig.GetHasuraInternalServerConfig" |
| 224 | // Determine from where assets should be served |
| 225 | url := c.getConfigEndpoint() |
| 226 | ctx, cancelFunc := context.WithTimeout(context.Background(), 30*time.Second) |
| 227 | defer cancelFunc() |
| 228 | req, err := client.NewRequest("GET", url, nil) |
| 229 | if err != nil { |
| 230 | return errors.E(op, fmt.Errorf("error fetching config from server: %w", err)) |
| 231 | } |
| 232 | r, err := client.Do(ctx, req, &c.HasuraServerInternalConfig) |
| 233 | if err != nil { |
| 234 | return errors.E(op, errors.KindNetwork, err) |
| 235 | } |
| 236 | defer r.Body.Close() |
| 237 | |
| 238 | if r.StatusCode != http.StatusOK { |
| 239 | var horror hasuradb.HasuraError |
| 240 | err := json.NewDecoder(r.Body).Decode(&horror) |
| 241 | if err != nil { |
| 242 | return errors.E(op, errors.KindHasuraAPI, fmt.Errorf("error unmarshalling fetching server config")) |
| 243 | } |
| 244 | return errors.E(op, errors.KindHasuraAPI, fmt.Errorf("error fetching server config: %v", horror.Error())) |
| 245 | } |
| 246 | return nil |
| 247 | } |
| 248 | |
| 249 | // HasuraServerConfig is the type returned by the v1alpha1/config API |
| 250 | // TODO: Move this type to a client implementation for hasura |
no test coverage detected