Skip to content

Commit 015e041

Browse files
committed
feat(controlplane): add dry-run and status/revision reporting to contract apply
Bring the WorkflowContract Apply API to parity with the compliance resources: report created/updated/unchanged status along with the current revision, and support a dry run that validates and computes the outcome without persisting any change. - proto: add dry_run to the Apply request; add an ApplyStatus enum and current_revision to the Apply response, keeping the existing changed bool for backward compatibility - biz: add RevisionWouldChange, reusing the data-layer change-detection rule to determine whether a revision would change without persisting - service: report status and current_revision and support dry run for the create, update and unchanged cases Assisted-by: Claude Code Signed-off-by: Javier Rodriguez <javier@chainloop.dev> Chainloop-Trace-Sessions: 5b64444b-4b32-4948-a7ff-82aba22b407d
1 parent a05305a commit 015e041

11 files changed

Lines changed: 684 additions & 60 deletions

app/controlplane/api/controlplane/v1/workflow_contract.pb.go

Lines changed: 150 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/controlplane/v1/workflow_contract.proto

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2024-2025 The Chainloop Authors.
2+
// Copyright 2024-2026 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -119,6 +119,8 @@ message WorkflowContractServiceDeleteResponse {}
119119
message WorkflowContractServiceApplyRequest {
120120
// Raw representation of the contract in json, yaml or cue
121121
bytes raw_schema = 1;
122+
// When true, validate and compute the result without persisting any change
123+
bool dry_run = 2;
122124
}
123125

124126
message WorkflowContractServiceApplyResponse {
@@ -127,4 +129,22 @@ message WorkflowContractServiceApplyResponse {
127129
bool unchanged = 2 [deprecated = true];
128130
// Whether the resource was changed
129131
bool changed = 3;
132+
// Detailed outcome of the apply operation
133+
ApplyStatus status = 4;
134+
// Current revision of the contract after the apply.
135+
// For a newly created contract this is the first revision; for an
136+
// unchanged contract it stays at the existing revision; for dry runs it
137+
// reflects the existing revision (0 when the contract does not exist yet).
138+
int32 current_revision = 5;
139+
140+
// ApplyStatus describes how the applied resource changed
141+
enum ApplyStatus {
142+
APPLY_STATUS_UNSPECIFIED = 0;
143+
// The resource did not exist and was created
144+
APPLY_STATUS_CREATED = 1;
145+
// The resource existed and its content changed
146+
APPLY_STATUS_UPDATED = 2;
147+
// The resource existed and its content was identical
148+
APPLY_STATUS_UNCHANGED = 3;
149+
}
130150
}

app/controlplane/api/gen/frontend/controlplane/v1/workflow_contract.ts

Lines changed: 109 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowContractServiceApplyRequest.jsonschema.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowContractServiceApplyRequest.schema.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowContractServiceApplyResponse.jsonschema.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/gen/jsonschema/controlplane.v1.WorkflowContractServiceApplyResponse.schema.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)