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

Function PolicySourcesFrom

internal/policy/source/source.go:276–295  ·  view source on GitHub ↗

PolicySourcesFrom returns an array of policy sources

(s ecc.Source)

Source from the content-addressed store, hash-verified

274
275// PolicySourcesFrom returns an array of policy sources
276func PolicySourcesFrom(s ecc.Source) []PolicySource {
277 policySources := make([]PolicySource, 0, len(s.Policy)+len(s.Data))
278
279 for _, policySourceUrl := range s.Policy {
280 url := PolicyUrl{Url: policySourceUrl, Kind: PolicyKind}
281 policySources = append(policySources, &url)
282 }
283
284 for _, dataSourceUrl := range s.Data {
285 url := PolicyUrl{Url: dataSourceUrl, Kind: DataKind}
286 policySources = append(policySources, &url)
287 }
288
289 if s.RuleData != nil {
290 data := append(append([]byte(`{"rule_data__configuration__":`), s.RuleData.Raw...), '}')
291 policySources = append(policySources, InlineData(data))
292 }
293
294 return policySources
295}

Callers 5

NewInputFunction · 0.92
validateImageCmdFunction · 0.92
PreProcessPolicyFunction · 0.85
TestPolicySourcesFromFunction · 0.85

Calls 1

InlineDataFunction · 0.85

Tested by 1

TestPolicySourcesFromFunction · 0.68