PolicySourcesFrom returns an array of policy sources
(s ecc.Source)
| 274 | |
| 275 | // PolicySourcesFrom returns an array of policy sources |
| 276 | func 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 | } |