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

Method GetPolicy

internal/policy/source/source.go:241–261  ·  view source on GitHub ↗
(ctx context.Context, workDir string, showMsg bool)

Source from the content-addressed store, hash-verified

239}
240
241func (s inlineData) GetPolicy(ctx context.Context, workDir string, showMsg bool) (string, error) {
242 dl := func(source string, dest string) (metadata.Metadata, error) {
243 fs := utils.FS(ctx)
244
245 if err := fs.MkdirAll(dest, 0o755); err != nil {
246 return nil, err
247 }
248
249 f := path.Join(dest, "rule_data.json")
250 m := &fileMetadata.FSMetadata{
251 URI: source,
252 Path: dest,
253 Size: int64(len(dest)),
254 }
255
256 return m, afero.WriteFile(fs, f, s.source, 0o400)
257 }
258
259 dest, _, err := getPolicyThroughCache(ctx, s, workDir, dl)
260 return dest, err
261}
262
263func (s inlineData) PolicyUrl() string {
264 return "data:application/json;base64," + base64.StdEncoding.EncodeToString(s.source)

Callers

nothing calls this directly

Calls 2

FSFunction · 0.92
getPolicyThroughCacheFunction · 0.85

Tested by

no test coverage detected