MCPcopy Create free account
hub / github.com/conforma/cli / GoGetterDownload

Function GoGetterDownload

internal/policy/source/git_config.go:49–70  ·  view source on GitHub ↗
(ctx context.Context, tmpDir, src string)

Source from the content-addressed store, hash-verified

47}
48
49func 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}

Callers 2

GetPolicyConfigFunction · 0.92
TestGoGetterDownloadFunction · 0.85

Calls 3

GetPolicyMethod · 0.95
choosePolicyFileFunction · 0.85
ErrorfMethod · 0.65

Tested by 1

TestGoGetterDownloadFunction · 0.68