Skip to content

Commit b610907

Browse files
authored
feat(controlplane): filter workflow runs by status (#547)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 3d2620a commit b610907

16 files changed

+810
-457
lines changed

app/cli/cmd/auth_login.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ func interactiveAuth() error {
8585

8686
// Run server in background
8787
http.HandleFunc(callbackURL.Path, a.handleCallback)
88-
if err != nil {
89-
return fmt.Errorf("parse listen address: %w", err)
90-
}
9188
go func() {
9289
logger.Info().Msg("waiting for the authentication to be completed, please check your browser")
9390

app/cli/cmd/workflow_workflow_run_describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func encodeAttestationOutput(run *action.WorkflowRunItemFull) error {
198198
}
199199

200200
// It could not be encoded but for a reason that's not because it was a custom format
201-
if err == nil && !errors.Is(err, ErrOutputFormatNotImplemented) {
201+
if !errors.Is(err, ErrOutputFormatNotImplemented) {
202202
return err
203203
}
204204

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

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

app/controlplane/api/controlplane/v1/response_messages.pb.validate.go

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

app/controlplane/api/controlplane/v1/response_messages.proto

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ message WorkflowRunItem {
4646
string id = 1;
4747
google.protobuf.Timestamp created_at = 2;
4848
google.protobuf.Timestamp finished_at = 3;
49-
string state = 4;
49+
// TODO: use runStatus enum below
50+
// deprecated field, use status instead
51+
string state = 4 [deprecated = true];
52+
RunStatus status = 12;
5053
string reason = 5;
5154
WorkflowItem workflow = 6;
5255
string job_url = 7;
@@ -60,6 +63,15 @@ message WorkflowRunItem {
6063
int32 contract_revision_latest = 11;
6164
}
6265

66+
enum RunStatus {
67+
RUN_STATUS_UNSPECIFIED = 0;
68+
RUN_STATUS_INITIALIZED = 1;
69+
RUN_STATUS_SUCCEEDED = 2;
70+
RUN_STATUS_FAILED = 3;
71+
RUN_STATUS_EXPIRED = 4;
72+
RUN_STATUS_CANCELLED = 5;
73+
}
74+
6375
message AttestationItem {
6476
// encoded DSEE envelope
6577
bytes envelope = 3;

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

Lines changed: 174 additions & 158 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_run.pb.validate.go

Lines changed: 2 additions & 0 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_run.proto

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 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.
@@ -17,28 +17,28 @@ syntax = "proto3";
1717

1818
package controlplane.v1;
1919

20-
option go_package = "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1;v1";
21-
22-
import "validate/validate.proto";
23-
import "controlplane/v1/response_messages.proto";
2420
import "controlplane/v1/pagination.proto";
21+
import "controlplane/v1/response_messages.proto";
22+
import "validate/validate.proto";
2523
import "workflowcontract/v1/crafting_schema.proto";
2624

25+
option go_package = "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1;v1";
26+
2727
// This service is used by the CLI to generate attestation
2828
service AttestationService {
29-
rpc GetContract (AttestationServiceGetContractRequest) returns (AttestationServiceGetContractResponse);
30-
rpc Init (AttestationServiceInitRequest) returns (AttestationServiceInitResponse);
31-
rpc Store (AttestationServiceStoreRequest) returns (AttestationServiceStoreResponse);
29+
rpc GetContract(AttestationServiceGetContractRequest) returns (AttestationServiceGetContractResponse);
30+
rpc Init(AttestationServiceInitRequest) returns (AttestationServiceInitResponse);
31+
rpc Store(AttestationServiceStoreRequest) returns (AttestationServiceStoreResponse);
3232
// There is another endpoint to get credentials via casCredentialsService.Get
3333
// This one is kept since it leverages robot-accounts in the context of a workflow
34-
rpc GetUploadCreds (AttestationServiceGetUploadCredsRequest) returns (AttestationServiceGetUploadCredsResponse);
35-
rpc Cancel (AttestationServiceCancelRequest) returns (AttestationServiceCancelResponse);
34+
rpc GetUploadCreds(AttestationServiceGetUploadCredsRequest) returns (AttestationServiceGetUploadCredsResponse);
35+
rpc Cancel(AttestationServiceCancelRequest) returns (AttestationServiceCancelResponse);
3636
}
3737

3838
// Administrative service for the operator
3939
service WorkflowRunService {
40-
rpc List (WorkflowRunServiceListRequest) returns (WorkflowRunServiceListResponse);
41-
rpc View (WorkflowRunServiceViewRequest) returns (WorkflowRunServiceViewResponse);
40+
rpc List(WorkflowRunServiceListRequest) returns (WorkflowRunServiceListResponse);
41+
rpc View(WorkflowRunServiceViewRequest) returns (WorkflowRunServiceViewResponse);
4242
}
4343

4444
message AttestationServiceGetContractRequest {
@@ -47,7 +47,7 @@ message AttestationServiceGetContractRequest {
4747

4848
message AttestationServiceGetContractResponse {
4949
Result result = 1;
50-
50+
5151
message Result {
5252
WorkflowItem workflow = 1;
5353
WorkflowContractVersionItem contract = 2;
@@ -62,7 +62,7 @@ message AttestationServiceInitRequest {
6262

6363
message AttestationServiceInitResponse {
6464
Result result = 1;
65-
65+
6666
message Result {
6767
WorkflowRunItem workflow_run = 2;
6868
}
@@ -76,7 +76,7 @@ message AttestationServiceStoreRequest {
7676

7777
message AttestationServiceStoreResponse {
7878
Result result = 1;
79-
79+
8080
message Result {
8181
// attestation digest
8282
string digest = 2;
@@ -85,21 +85,27 @@ message AttestationServiceStoreResponse {
8585

8686
message AttestationServiceCancelRequest {
8787
string workflow_run_id = 1 [(validate.rules).string = {min_len: 1}];
88-
TriggerType trigger = 2 [(validate.rules).enum = {not_in: [0]}];
88+
TriggerType trigger = 2 [(validate.rules).enum = {
89+
not_in: [0]
90+
}];
8991
string reason = 3;
9092

9193
enum TriggerType {
92-
TRIGGER_TYPE_UNSPECIFIED = 0;
93-
TRIGGER_TYPE_FAILURE = 1;
94-
TRIGGER_TYPE_CANCELLATION = 2;
95-
}
94+
TRIGGER_TYPE_UNSPECIFIED = 0;
95+
TRIGGER_TYPE_FAILURE = 1;
96+
TRIGGER_TYPE_CANCELLATION = 2;
97+
}
9698
}
9799

98100
message AttestationServiceCancelResponse {}
99101

100102
message WorkflowRunServiceListRequest {
101-
// Filter by workflow
103+
// Filters
104+
// by workflow
102105
string workflow_id = 1;
106+
// by run status
107+
RunStatus status = 3;
108+
// pagination options
103109
PaginationRequest pagination = 2;
104110
}
105111

@@ -112,7 +118,7 @@ message WorkflowRunServiceViewRequest {
112118
// It can search by either ID or digest
113119
oneof ref {
114120
option (validate.required) = true;
115-
121+
116122
string id = 1 [(validate.rules).string.uuid = true];
117123
string digest = 2 [(validate.rules).string = {min_len: 1}];
118124
}
@@ -127,16 +133,15 @@ message WorkflowRunServiceViewResponse {
127133
}
128134
}
129135

130-
131136
message AttestationServiceGetUploadCredsRequest {
132-
string workflow_run_id = 1;
137+
string workflow_run_id = 1;
133138
}
134139

135140
message AttestationServiceGetUploadCredsResponse {
136141
Result result = 1;
137-
142+
138143
message Result {
139144
string token = 2;
140-
CASBackendItem backend = 3;
145+
CASBackendItem backend = 3;
141146
}
142147
}

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 78 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)