MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / getPolicyTypes

Function getPolicyTypes

pkg/policies/policies.go:973–986  ·  view source on GitHub ↗
(p *v1.Policy)

Source from the content-addressed store, hash-verified

971}
972
973func getPolicyTypes(p *v1.Policy) []v1.CraftingSchema_Material_MaterialType {
974 policyTypes := make([]v1.CraftingSchema_Material_MaterialType, 0)
975 v1Type := p.GetSpec().GetType()
976 if v1Type != v1.CraftingSchema_Material_MATERIAL_TYPE_UNSPECIFIED {
977 policyTypes = append(policyTypes, v1Type)
978 } else {
979 for _, branch := range p.GetSpec().GetPolicies() {
980 if branch.GetKind() != v1.CraftingSchema_Material_MATERIAL_TYPE_UNSPECIFIED {
981 policyTypes = append(policyTypes, branch.GetKind())
982 }
983 }
984 }
985 return policyTypes
986}
987
988// LoadPolicyScriptsFromSpec loads all policy script that matches a given material type. It matches if:
989// * the policy kind is unspecified, meaning that it was forced by name selector

Callers 2

shouldApplyPolicyMethod · 0.85
shouldApplyPolicyMethod · 0.85

Calls 4

GetTypeMethod · 0.45
GetSpecMethod · 0.45
GetPoliciesMethod · 0.45
GetKindMethod · 0.45

Tested by

no test coverage detected