Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions app/controlplane/api/controlplane/v1/workflow_contract.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions app/controlplane/api/controlplane/v1/workflow_contract.proto
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ message WorkflowContractServiceApplyRequest {
bytes raw_schema = 1;
// When true, validate and compute the result without persisting any change
bool dry_run = 2;
// Names of policies created/updated in the same batch apply. References to these are
// treated as known instead of being resolved against the registry (they may not be
// persisted yet, e.g. during dry-run). Remote references are still validated.
repeated string batch_policy_names = 3;
// Same as batch_policy_names, for policy groups created/updated in the same batch.
repeated string batch_policy_group_names = 4;
}

message WorkflowContractServiceApplyResponse {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/controlplane/internal/service/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ func (s *AttestationService) FindOrCreateWorkflow(ctx context.Context, req *cpAP

// contract validation
if req.GetContractBytes() != nil {
if err = s.workflowContractUseCase.ValidateContractPolicies(ctx, req.GetContractBytes(), token); err != nil {
if err = s.workflowContractUseCase.ValidateContractPolicies(ctx, req.GetContractBytes(), token, nil, nil); err != nil {
return nil, handleUseCaseErr(err, s.log)
}
}
Expand Down
15 changes: 12 additions & 3 deletions app/controlplane/internal/service/workflowcontract.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (s *WorkflowContractService) Create(ctx context.Context, req *pb.WorkflowCo
}

if len(req.RawContract) != 0 {
if err = s.contractUseCase.ValidateContractPolicies(ctx, req.RawContract, token); err != nil {
if err = s.contractUseCase.ValidateContractPolicies(ctx, req.RawContract, token, nil, nil); err != nil {
return nil, handleUseCaseErr(err, s.log)
}
}
Expand Down Expand Up @@ -212,7 +212,7 @@ func (s *WorkflowContractService) Update(ctx context.Context, req *pb.WorkflowCo

// Validate the contract policies if the raw contract is provided
if len(req.RawContract) != 0 {
if err = s.contractUseCase.ValidateContractPolicies(ctx, req.RawContract, token); err != nil {
if err = s.contractUseCase.ValidateContractPolicies(ctx, req.RawContract, token, nil, nil); err != nil {
return nil, handleUseCaseErr(err, s.log)
}
}
Expand Down Expand Up @@ -253,7 +253,16 @@ func (s *WorkflowContractService) Apply(ctx context.Context, req *pb.WorkflowCon
return nil, err
}

if err = s.contractUseCase.ValidateContractPolicies(ctx, req.RawSchema, token); err != nil {
// Batch-local references are only exempted from registry resolution on a dry-run, where
// the resources may not be persisted yet. A real apply persists batch resources before the
// contract, so it must always validate fully and never trust the client-supplied batch lists.
var batchPolicyNames, batchPolicyGroupNames []string
if dryRun {
batchPolicyNames = req.GetBatchPolicyNames()
batchPolicyGroupNames = req.GetBatchPolicyGroupNames()
}

if err = s.contractUseCase.ValidateContractPolicies(ctx, req.RawSchema, token, batchPolicyNames, batchPolicyGroupNames); err != nil {
return nil, handleUseCaseErr(err, s.log)
}

Expand Down
Loading
Loading