Skip to content

Commit ce8f2b4

Browse files
authored
fix: re-add validations for policy groups (#1600)
Signed-off-by: Jose I. Paris <[email protected]>
1 parent 8bb6e6a commit ce8f2b4

File tree

4 files changed

+4
-14
lines changed

4 files changed

+4
-14
lines changed

app/cli/internal/action/attestation_init.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,7 @@ func enrichContractMaterials(ctx context.Context, schema *v1.CraftingSchema, cli
218218
Logger: logger,
219219
})
220220
if err != nil {
221-
// Temporarily skip if policy groups still use old schema
222-
// TODO: remove this check in next release
223-
logger.Warn().Msgf("policy group '%s' skipped since it's not found or it might use an old schema version", pgAtt.GetRef())
224-
return nil
221+
return fmt.Errorf("failed to load policy group: %w", err)
225222
}
226223
logger.Debug().Msgf("adding materials from policy group '%s'", group.GetMetadata().GetName())
227224

app/cli/internal/action/attestation_init_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ func TestEnrichMaterials(t *testing.T) {
6767
name: "wrong policy group",
6868
materials: []*v1.CraftingSchema_Material{},
6969
policyGroup: "file://testdata/idontexist.yaml",
70-
// TODO: Fix this condition in next release
71-
expectErr: false,
70+
expectErr: true,
7271
},
7372
{
7473
name: "name-less materials are not added",

app/controlplane/pkg/biz/workflowcontract.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,7 @@ func (uc *WorkflowContractUseCase) findPolicyGroup(att *schemav1.PolicyGroupAtta
366366
pr := loader.ProviderParts(att.GetRef())
367367
remoteGroup, err := uc.GetPolicyGroup(pr.Provider, pr.Name, pr.OrgName, token)
368368
if err != nil {
369-
// Temporarily skip if policy groups still use old schema
370-
// TODO: remove this check in next release
371-
uc.logger.Warnf("policy group '%s' skipped since it's not found or it might use an old schema version", att.GetRef())
372-
return nil, nil
369+
return nil, NewErrValidation(fmt.Errorf("failed to get policy group: %w", err))
373370
}
374371
if remoteGroup.PolicyGroup != nil {
375372
// validate group arguments

pkg/policies/policy_groups.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ func (pgv *PolicyGroupVerifier) VerifyMaterial(ctx context.Context, material *ap
5858
Logger: pgv.logger,
5959
})
6060
if err != nil {
61-
// Temporarily skip if policy groups still use old schema
62-
// TODO: remove this check in next release
63-
pgv.logger.Warn().Msgf("policy group '%s' skipped since it's not found or it might use an old schema version", groupAtt.GetRef())
64-
return result, nil
61+
return nil, NewPolicyError(err)
6562
}
6663

6764
// matches group arguments against spec and apply defaults

0 commit comments

Comments
 (0)