| 47 | } |
| 48 | |
| 49 | func GoGetterDownload(ctx context.Context, tmpDir, src string) (string, error) { |
| 50 | // Download the config from a url |
| 51 | c := PolicyUrl{ |
| 52 | Url: src, |
| 53 | Kind: ConfigKind, |
| 54 | } |
| 55 | configDir, err := c.GetPolicy(ctx, tmpDir, false) |
| 56 | if err != nil { |
| 57 | log.Debugf("Failed to download policy config from %s", c.Url) |
| 58 | return "", err |
| 59 | } |
| 60 | log.Debugf("Downloaded policy config from %s to %s", c.Url, configDir) |
| 61 | |
| 62 | // Look for a suitable file to use for the config |
| 63 | configFile, err := choosePolicyFile(ctx, configDir) |
| 64 | if err != nil { |
| 65 | // A more useful error message: |
| 66 | return "", fmt.Errorf("no suitable config file found at %s", c.Url) |
| 67 | } |
| 68 | log.Debugf("Chose file %s to use for the policy config", configFile) |
| 69 | return configFile, nil |
| 70 | } |