From d40ca25b5c9ed23720bb38e119573502b1b20bed Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Tue, 14 Nov 2023 14:14:45 +0100 Subject: [PATCH 1/4] Update workflow API Signed-off-by: Miguel Martinez Trivino --- .../api/controlplane/v1/workflow.pb.go | 388 +++++++------ .../controlplane/v1/workflow.pb.validate.go | 534 +++++++++--------- .../api/controlplane/v1/workflow.proto | 29 +- .../api/controlplane/v1/workflow_grpc.pb.go | 74 +-- .../gen/frontend/controlplane/v1/workflow.ts | 389 +++++++------ .../biz/casmapping_integration_test.go | 4 +- .../internal/biz/integration_test.go | 2 +- .../biz/organization_integration_test.go | 2 +- app/controlplane/internal/biz/workflow.go | 63 ++- .../internal/biz/workflow_integration_test.go | 2 +- .../biz/workflowrun_integration_test.go | 6 +- app/controlplane/internal/data/workflow.go | 33 +- .../internal/dispatcher/dispatcher_test.go | 4 +- app/controlplane/internal/service/workflow.go | 44 +- 14 files changed, 840 insertions(+), 734 deletions(-) diff --git a/app/controlplane/api/controlplane/v1/workflow.pb.go b/app/controlplane/api/controlplane/v1/workflow.pb.go index 3fca4baaf..823cc763c 100644 --- a/app/controlplane/api/controlplane/v1/workflow.pb.go +++ b/app/controlplane/api/controlplane/v1/workflow.pb.go @@ -108,16 +108,22 @@ func (x *WorkflowServiceCreateRequest) GetTeam() string { return "" } -type WorkflowServiceCreateResponse struct { +type WorkflowServiceUpdateRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Result *WorkflowItem `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // "optional" allow us to detect if the value is explicitly set + // and not just the default balue + Name *string `protobuf:"bytes,2,opt,name=name,proto3,oneof" json:"name,omitempty"` + Project *string `protobuf:"bytes,3,opt,name=project,proto3,oneof" json:"project,omitempty"` + Team *string `protobuf:"bytes,4,opt,name=team,proto3,oneof" json:"team,omitempty"` + Public *bool `protobuf:"varint,5,opt,name=public,proto3,oneof" json:"public,omitempty"` } -func (x *WorkflowServiceCreateResponse) Reset() { - *x = WorkflowServiceCreateResponse{} +func (x *WorkflowServiceUpdateRequest) Reset() { + *x = WorkflowServiceUpdateRequest{} if protoimpl.UnsafeEnabled { mi := &file_controlplane_v1_workflow_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -125,13 +131,13 @@ func (x *WorkflowServiceCreateResponse) Reset() { } } -func (x *WorkflowServiceCreateResponse) String() string { +func (x *WorkflowServiceUpdateRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*WorkflowServiceCreateResponse) ProtoMessage() {} +func (*WorkflowServiceUpdateRequest) ProtoMessage() {} -func (x *WorkflowServiceCreateResponse) ProtoReflect() protoreflect.Message { +func (x *WorkflowServiceUpdateRequest) ProtoReflect() protoreflect.Message { mi := &file_controlplane_v1_workflow_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -143,28 +149,56 @@ func (x *WorkflowServiceCreateResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use WorkflowServiceCreateResponse.ProtoReflect.Descriptor instead. -func (*WorkflowServiceCreateResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use WorkflowServiceUpdateRequest.ProtoReflect.Descriptor instead. +func (*WorkflowServiceUpdateRequest) Descriptor() ([]byte, []int) { return file_controlplane_v1_workflow_proto_rawDescGZIP(), []int{1} } -func (x *WorkflowServiceCreateResponse) GetResult() *WorkflowItem { +func (x *WorkflowServiceUpdateRequest) GetId() string { if x != nil { - return x.Result + return x.Id } - return nil + return "" } -type WorkflowServiceDeleteRequest struct { +func (x *WorkflowServiceUpdateRequest) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *WorkflowServiceUpdateRequest) GetProject() string { + if x != nil && x.Project != nil { + return *x.Project + } + return "" +} + +func (x *WorkflowServiceUpdateRequest) GetTeam() string { + if x != nil && x.Team != nil { + return *x.Team + } + return "" +} + +func (x *WorkflowServiceUpdateRequest) GetPublic() bool { + if x != nil && x.Public != nil { + return *x.Public + } + return false +} + +type WorkflowServiceUpdateResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Result *WorkflowItem `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` } -func (x *WorkflowServiceDeleteRequest) Reset() { - *x = WorkflowServiceDeleteRequest{} +func (x *WorkflowServiceUpdateResponse) Reset() { + *x = WorkflowServiceUpdateResponse{} if protoimpl.UnsafeEnabled { mi := &file_controlplane_v1_workflow_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -172,13 +206,13 @@ func (x *WorkflowServiceDeleteRequest) Reset() { } } -func (x *WorkflowServiceDeleteRequest) String() string { +func (x *WorkflowServiceUpdateResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*WorkflowServiceDeleteRequest) ProtoMessage() {} +func (*WorkflowServiceUpdateResponse) ProtoMessage() {} -func (x *WorkflowServiceDeleteRequest) ProtoReflect() protoreflect.Message { +func (x *WorkflowServiceUpdateResponse) ProtoReflect() protoreflect.Message { mi := &file_controlplane_v1_workflow_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -190,26 +224,28 @@ func (x *WorkflowServiceDeleteRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use WorkflowServiceDeleteRequest.ProtoReflect.Descriptor instead. -func (*WorkflowServiceDeleteRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use WorkflowServiceUpdateResponse.ProtoReflect.Descriptor instead. +func (*WorkflowServiceUpdateResponse) Descriptor() ([]byte, []int) { return file_controlplane_v1_workflow_proto_rawDescGZIP(), []int{2} } -func (x *WorkflowServiceDeleteRequest) GetId() string { +func (x *WorkflowServiceUpdateResponse) GetResult() *WorkflowItem { if x != nil { - return x.Id + return x.Result } - return "" + return nil } -type WorkflowServiceDeleteResponse struct { +type WorkflowServiceCreateResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Result *WorkflowItem `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` } -func (x *WorkflowServiceDeleteResponse) Reset() { - *x = WorkflowServiceDeleteResponse{} +func (x *WorkflowServiceCreateResponse) Reset() { + *x = WorkflowServiceCreateResponse{} if protoimpl.UnsafeEnabled { mi := &file_controlplane_v1_workflow_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -217,13 +253,13 @@ func (x *WorkflowServiceDeleteResponse) Reset() { } } -func (x *WorkflowServiceDeleteResponse) String() string { +func (x *WorkflowServiceCreateResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*WorkflowServiceDeleteResponse) ProtoMessage() {} +func (*WorkflowServiceCreateResponse) ProtoMessage() {} -func (x *WorkflowServiceDeleteResponse) ProtoReflect() protoreflect.Message { +func (x *WorkflowServiceCreateResponse) ProtoReflect() protoreflect.Message { mi := &file_controlplane_v1_workflow_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -235,19 +271,28 @@ func (x *WorkflowServiceDeleteResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use WorkflowServiceDeleteResponse.ProtoReflect.Descriptor instead. -func (*WorkflowServiceDeleteResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use WorkflowServiceCreateResponse.ProtoReflect.Descriptor instead. +func (*WorkflowServiceCreateResponse) Descriptor() ([]byte, []int) { return file_controlplane_v1_workflow_proto_rawDescGZIP(), []int{3} } -type WorkflowServiceListRequest struct { +func (x *WorkflowServiceCreateResponse) GetResult() *WorkflowItem { + if x != nil { + return x.Result + } + return nil +} + +type WorkflowServiceDeleteRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` } -func (x *WorkflowServiceListRequest) Reset() { - *x = WorkflowServiceListRequest{} +func (x *WorkflowServiceDeleteRequest) Reset() { + *x = WorkflowServiceDeleteRequest{} if protoimpl.UnsafeEnabled { mi := &file_controlplane_v1_workflow_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -255,13 +300,13 @@ func (x *WorkflowServiceListRequest) Reset() { } } -func (x *WorkflowServiceListRequest) String() string { +func (x *WorkflowServiceDeleteRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*WorkflowServiceListRequest) ProtoMessage() {} +func (*WorkflowServiceDeleteRequest) ProtoMessage() {} -func (x *WorkflowServiceListRequest) ProtoReflect() protoreflect.Message { +func (x *WorkflowServiceDeleteRequest) ProtoReflect() protoreflect.Message { mi := &file_controlplane_v1_workflow_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -273,21 +318,26 @@ func (x *WorkflowServiceListRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use WorkflowServiceListRequest.ProtoReflect.Descriptor instead. -func (*WorkflowServiceListRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use WorkflowServiceDeleteRequest.ProtoReflect.Descriptor instead. +func (*WorkflowServiceDeleteRequest) Descriptor() ([]byte, []int) { return file_controlplane_v1_workflow_proto_rawDescGZIP(), []int{4} } -type WorkflowServiceListResponse struct { +func (x *WorkflowServiceDeleteRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type WorkflowServiceDeleteResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - Result []*WorkflowItem `protobuf:"bytes,1,rep,name=result,proto3" json:"result,omitempty"` } -func (x *WorkflowServiceListResponse) Reset() { - *x = WorkflowServiceListResponse{} +func (x *WorkflowServiceDeleteResponse) Reset() { + *x = WorkflowServiceDeleteResponse{} if protoimpl.UnsafeEnabled { mi := &file_controlplane_v1_workflow_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -295,13 +345,13 @@ func (x *WorkflowServiceListResponse) Reset() { } } -func (x *WorkflowServiceListResponse) String() string { +func (x *WorkflowServiceDeleteResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*WorkflowServiceListResponse) ProtoMessage() {} +func (*WorkflowServiceDeleteResponse) ProtoMessage() {} -func (x *WorkflowServiceListResponse) ProtoReflect() protoreflect.Message { +func (x *WorkflowServiceDeleteResponse) ProtoReflect() protoreflect.Message { mi := &file_controlplane_v1_workflow_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -313,32 +363,19 @@ func (x *WorkflowServiceListResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use WorkflowServiceListResponse.ProtoReflect.Descriptor instead. -func (*WorkflowServiceListResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use WorkflowServiceDeleteResponse.ProtoReflect.Descriptor instead. +func (*WorkflowServiceDeleteResponse) Descriptor() ([]byte, []int) { return file_controlplane_v1_workflow_proto_rawDescGZIP(), []int{5} } -func (x *WorkflowServiceListResponse) GetResult() []*WorkflowItem { - if x != nil { - return x.Result - } - return nil -} - -type WorkflowServiceChangeVisibilityRequest struct { +type WorkflowServiceListRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // A public workflow means that any user can - // - access to all its workflow runs - // - their attestation and materials - Public bool `protobuf:"varint,2,opt,name=public,proto3" json:"public,omitempty"` } -func (x *WorkflowServiceChangeVisibilityRequest) Reset() { - *x = WorkflowServiceChangeVisibilityRequest{} +func (x *WorkflowServiceListRequest) Reset() { + *x = WorkflowServiceListRequest{} if protoimpl.UnsafeEnabled { mi := &file_controlplane_v1_workflow_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -346,13 +383,13 @@ func (x *WorkflowServiceChangeVisibilityRequest) Reset() { } } -func (x *WorkflowServiceChangeVisibilityRequest) String() string { +func (x *WorkflowServiceListRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*WorkflowServiceChangeVisibilityRequest) ProtoMessage() {} +func (*WorkflowServiceListRequest) ProtoMessage() {} -func (x *WorkflowServiceChangeVisibilityRequest) ProtoReflect() protoreflect.Message { +func (x *WorkflowServiceListRequest) ProtoReflect() protoreflect.Message { mi := &file_controlplane_v1_workflow_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -364,35 +401,21 @@ func (x *WorkflowServiceChangeVisibilityRequest) ProtoReflect() protoreflect.Mes return mi.MessageOf(x) } -// Deprecated: Use WorkflowServiceChangeVisibilityRequest.ProtoReflect.Descriptor instead. -func (*WorkflowServiceChangeVisibilityRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use WorkflowServiceListRequest.ProtoReflect.Descriptor instead. +func (*WorkflowServiceListRequest) Descriptor() ([]byte, []int) { return file_controlplane_v1_workflow_proto_rawDescGZIP(), []int{6} } -func (x *WorkflowServiceChangeVisibilityRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *WorkflowServiceChangeVisibilityRequest) GetPublic() bool { - if x != nil { - return x.Public - } - return false -} - -type WorkflowServiceChangeVisibilityResponse struct { +type WorkflowServiceListResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Result *WorkflowItem `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` + Result []*WorkflowItem `protobuf:"bytes,1,rep,name=result,proto3" json:"result,omitempty"` } -func (x *WorkflowServiceChangeVisibilityResponse) Reset() { - *x = WorkflowServiceChangeVisibilityResponse{} +func (x *WorkflowServiceListResponse) Reset() { + *x = WorkflowServiceListResponse{} if protoimpl.UnsafeEnabled { mi := &file_controlplane_v1_workflow_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -400,13 +423,13 @@ func (x *WorkflowServiceChangeVisibilityResponse) Reset() { } } -func (x *WorkflowServiceChangeVisibilityResponse) String() string { +func (x *WorkflowServiceListResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*WorkflowServiceChangeVisibilityResponse) ProtoMessage() {} +func (*WorkflowServiceListResponse) ProtoMessage() {} -func (x *WorkflowServiceChangeVisibilityResponse) ProtoReflect() protoreflect.Message { +func (x *WorkflowServiceListResponse) ProtoReflect() protoreflect.Message { mi := &file_controlplane_v1_workflow_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -418,12 +441,12 @@ func (x *WorkflowServiceChangeVisibilityResponse) ProtoReflect() protoreflect.Me return mi.MessageOf(x) } -// Deprecated: Use WorkflowServiceChangeVisibilityResponse.ProtoReflect.Descriptor instead. -func (*WorkflowServiceChangeVisibilityResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use WorkflowServiceListResponse.ProtoReflect.Descriptor instead. +func (*WorkflowServiceListResponse) Descriptor() ([]byte, []int) { return file_controlplane_v1_workflow_proto_rawDescGZIP(), []int{7} } -func (x *WorkflowServiceChangeVisibilityResponse) GetResult() *WorkflowItem { +func (x *WorkflowServiceListResponse) GetResult() []*WorkflowItem { if x != nil { return x.Result } @@ -449,72 +472,76 @@ var file_controlplane_v1_workflow_proto_rawDesc = []byte{ 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x61, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x65, 0x61, 0x6d, 0x22, 0x56, 0x0a, 0x1d, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, - 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, - 0x77, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x38, 0x0a, - 0x1c, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x72, 0x03, - 0xb0, 0x01, 0x01, 0x52, 0x02, 0x69, 0x64, 0x22, 0x1f, 0x0a, 0x1d, 0x57, 0x6f, 0x72, 0x6b, 0x66, - 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x0a, 0x1a, 0x57, 0x6f, 0x72, 0x6b, - 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x54, 0x0a, 0x1b, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, - 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, - 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, - 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x5a, 0x0a, 0x26, - 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, - 0x68, 0x61, 0x6e, 0x67, 0x65, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, + 0x04, 0x74, 0x65, 0x61, 0x6d, 0x22, 0xcf, 0x01, 0x0a, 0x1c, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, + 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x72, 0x03, 0xb0, 0x01, 0x01, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x16, 0x0a, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x22, 0x60, 0x0a, 0x27, 0x57, 0x6f, 0x72, 0x6b, - 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, - 0x65, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, - 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x49, 0x74, - 0x65, 0x6d, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, 0xce, 0x03, 0x0a, 0x0f, 0x57, - 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x67, - 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x07, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x74, 0x65, 0x61, 0x6d, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x04, 0x74, 0x65, 0x61, 0x6d, 0x88, 0x01, + 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x08, 0x48, 0x03, 0x52, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x88, 0x01, 0x01, 0x42, 0x07, + 0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x70, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x74, 0x65, 0x61, 0x6d, 0x42, 0x09, 0x0a, 0x07, + 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x22, 0x56, 0x0a, 0x1d, 0x57, 0x6f, 0x72, 0x6b, 0x66, + 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, - 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, - 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x61, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, - 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, - 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x67, 0x0a, 0x06, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, + 0x6c, 0x6f, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, + 0x56, 0x0a, 0x1d, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x35, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x52, + 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x38, 0x0a, 0x1c, 0x57, 0x6f, 0x72, 0x6b, 0x66, + 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x72, 0x03, 0xb0, 0x01, 0x01, 0x52, 0x02, 0x69, + 0x64, 0x22, 0x1f, 0x0a, 0x1d, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x1c, 0x0a, 0x1a, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x22, 0x54, 0x0a, 0x1b, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x35, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, + 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, 0xaf, 0x03, 0x0a, 0x0f, 0x57, 0x6f, 0x72, 0x6b, 0x66, + 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x67, 0x0a, 0x06, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x85, 0x01, 0x0a, 0x10, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x56, 0x69, - 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x37, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, - 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, - 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x38, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x67, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x2d, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, + 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x61, 0x0a, 0x04, + 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, + 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, - 0x69, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4c, 0x5a, 0x4a, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, - 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, - 0x70, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, - 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, - 0x61, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x67, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, + 0x66, 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, + 0x6c, 0x6f, 0x77, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, + 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, + 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, + 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -531,28 +558,28 @@ func file_controlplane_v1_workflow_proto_rawDescGZIP() []byte { var file_controlplane_v1_workflow_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_controlplane_v1_workflow_proto_goTypes = []interface{}{ - (*WorkflowServiceCreateRequest)(nil), // 0: controlplane.v1.WorkflowServiceCreateRequest - (*WorkflowServiceCreateResponse)(nil), // 1: controlplane.v1.WorkflowServiceCreateResponse - (*WorkflowServiceDeleteRequest)(nil), // 2: controlplane.v1.WorkflowServiceDeleteRequest - (*WorkflowServiceDeleteResponse)(nil), // 3: controlplane.v1.WorkflowServiceDeleteResponse - (*WorkflowServiceListRequest)(nil), // 4: controlplane.v1.WorkflowServiceListRequest - (*WorkflowServiceListResponse)(nil), // 5: controlplane.v1.WorkflowServiceListResponse - (*WorkflowServiceChangeVisibilityRequest)(nil), // 6: controlplane.v1.WorkflowServiceChangeVisibilityRequest - (*WorkflowServiceChangeVisibilityResponse)(nil), // 7: controlplane.v1.WorkflowServiceChangeVisibilityResponse - (*WorkflowItem)(nil), // 8: controlplane.v1.WorkflowItem + (*WorkflowServiceCreateRequest)(nil), // 0: controlplane.v1.WorkflowServiceCreateRequest + (*WorkflowServiceUpdateRequest)(nil), // 1: controlplane.v1.WorkflowServiceUpdateRequest + (*WorkflowServiceUpdateResponse)(nil), // 2: controlplane.v1.WorkflowServiceUpdateResponse + (*WorkflowServiceCreateResponse)(nil), // 3: controlplane.v1.WorkflowServiceCreateResponse + (*WorkflowServiceDeleteRequest)(nil), // 4: controlplane.v1.WorkflowServiceDeleteRequest + (*WorkflowServiceDeleteResponse)(nil), // 5: controlplane.v1.WorkflowServiceDeleteResponse + (*WorkflowServiceListRequest)(nil), // 6: controlplane.v1.WorkflowServiceListRequest + (*WorkflowServiceListResponse)(nil), // 7: controlplane.v1.WorkflowServiceListResponse + (*WorkflowItem)(nil), // 8: controlplane.v1.WorkflowItem } var file_controlplane_v1_workflow_proto_depIdxs = []int32{ - 8, // 0: controlplane.v1.WorkflowServiceCreateResponse.result:type_name -> controlplane.v1.WorkflowItem - 8, // 1: controlplane.v1.WorkflowServiceListResponse.result:type_name -> controlplane.v1.WorkflowItem - 8, // 2: controlplane.v1.WorkflowServiceChangeVisibilityResponse.result:type_name -> controlplane.v1.WorkflowItem + 8, // 0: controlplane.v1.WorkflowServiceUpdateResponse.result:type_name -> controlplane.v1.WorkflowItem + 8, // 1: controlplane.v1.WorkflowServiceCreateResponse.result:type_name -> controlplane.v1.WorkflowItem + 8, // 2: controlplane.v1.WorkflowServiceListResponse.result:type_name -> controlplane.v1.WorkflowItem 0, // 3: controlplane.v1.WorkflowService.Create:input_type -> controlplane.v1.WorkflowServiceCreateRequest - 4, // 4: controlplane.v1.WorkflowService.List:input_type -> controlplane.v1.WorkflowServiceListRequest - 2, // 5: controlplane.v1.WorkflowService.Delete:input_type -> controlplane.v1.WorkflowServiceDeleteRequest - 6, // 6: controlplane.v1.WorkflowService.ChangeVisibility:input_type -> controlplane.v1.WorkflowServiceChangeVisibilityRequest - 1, // 7: controlplane.v1.WorkflowService.Create:output_type -> controlplane.v1.WorkflowServiceCreateResponse - 5, // 8: controlplane.v1.WorkflowService.List:output_type -> controlplane.v1.WorkflowServiceListResponse - 3, // 9: controlplane.v1.WorkflowService.Delete:output_type -> controlplane.v1.WorkflowServiceDeleteResponse - 7, // 10: controlplane.v1.WorkflowService.ChangeVisibility:output_type -> controlplane.v1.WorkflowServiceChangeVisibilityResponse + 1, // 4: controlplane.v1.WorkflowService.Update:input_type -> controlplane.v1.WorkflowServiceUpdateRequest + 6, // 5: controlplane.v1.WorkflowService.List:input_type -> controlplane.v1.WorkflowServiceListRequest + 4, // 6: controlplane.v1.WorkflowService.Delete:input_type -> controlplane.v1.WorkflowServiceDeleteRequest + 3, // 7: controlplane.v1.WorkflowService.Create:output_type -> controlplane.v1.WorkflowServiceCreateResponse + 2, // 8: controlplane.v1.WorkflowService.Update:output_type -> controlplane.v1.WorkflowServiceUpdateResponse + 7, // 9: controlplane.v1.WorkflowService.List:output_type -> controlplane.v1.WorkflowServiceListResponse + 5, // 10: controlplane.v1.WorkflowService.Delete:output_type -> controlplane.v1.WorkflowServiceDeleteResponse 7, // [7:11] is the sub-list for method output_type 3, // [3:7] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name @@ -580,7 +607,7 @@ func file_controlplane_v1_workflow_proto_init() { } } file_controlplane_v1_workflow_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WorkflowServiceCreateResponse); i { + switch v := v.(*WorkflowServiceUpdateRequest); i { case 0: return &v.state case 1: @@ -592,7 +619,7 @@ func file_controlplane_v1_workflow_proto_init() { } } file_controlplane_v1_workflow_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WorkflowServiceDeleteRequest); i { + switch v := v.(*WorkflowServiceUpdateResponse); i { case 0: return &v.state case 1: @@ -604,7 +631,7 @@ func file_controlplane_v1_workflow_proto_init() { } } file_controlplane_v1_workflow_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WorkflowServiceDeleteResponse); i { + switch v := v.(*WorkflowServiceCreateResponse); i { case 0: return &v.state case 1: @@ -616,7 +643,7 @@ func file_controlplane_v1_workflow_proto_init() { } } file_controlplane_v1_workflow_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WorkflowServiceListRequest); i { + switch v := v.(*WorkflowServiceDeleteRequest); i { case 0: return &v.state case 1: @@ -628,7 +655,7 @@ func file_controlplane_v1_workflow_proto_init() { } } file_controlplane_v1_workflow_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WorkflowServiceListResponse); i { + switch v := v.(*WorkflowServiceDeleteResponse); i { case 0: return &v.state case 1: @@ -640,7 +667,7 @@ func file_controlplane_v1_workflow_proto_init() { } } file_controlplane_v1_workflow_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WorkflowServiceChangeVisibilityRequest); i { + switch v := v.(*WorkflowServiceListRequest); i { case 0: return &v.state case 1: @@ -652,7 +679,7 @@ func file_controlplane_v1_workflow_proto_init() { } } file_controlplane_v1_workflow_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WorkflowServiceChangeVisibilityResponse); i { + switch v := v.(*WorkflowServiceListResponse); i { case 0: return &v.state case 1: @@ -664,6 +691,7 @@ func file_controlplane_v1_workflow_proto_init() { } } } + file_controlplane_v1_workflow_proto_msgTypes[1].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/controlplane/api/controlplane/v1/workflow.pb.validate.go b/app/controlplane/api/controlplane/v1/workflow.pb.validate.go index 7d03fb693..1aad5ebaa 100644 --- a/app/controlplane/api/controlplane/v1/workflow.pb.validate.go +++ b/app/controlplane/api/controlplane/v1/workflow.pb.validate.go @@ -167,6 +167,277 @@ var _ interface { ErrorName() string } = WorkflowServiceCreateRequestValidationError{} +// Validate checks the field values on WorkflowServiceUpdateRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *WorkflowServiceUpdateRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on WorkflowServiceUpdateRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// WorkflowServiceUpdateRequestMultiError, or nil if none found. +func (m *WorkflowServiceUpdateRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *WorkflowServiceUpdateRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if err := m._validateUuid(m.GetId()); err != nil { + err = WorkflowServiceUpdateRequestValidationError{ + field: "Id", + reason: "value must be a valid UUID", + cause: err, + } + if !all { + return err + } + errors = append(errors, err) + } + + if m.Name != nil { + // no validation rules for Name + } + + if m.Project != nil { + // no validation rules for Project + } + + if m.Team != nil { + // no validation rules for Team + } + + if m.Public != nil { + // no validation rules for Public + } + + if len(errors) > 0 { + return WorkflowServiceUpdateRequestMultiError(errors) + } + + return nil +} + +func (m *WorkflowServiceUpdateRequest) _validateUuid(uuid string) error { + if matched := _workflow_uuidPattern.MatchString(uuid); !matched { + return errors.New("invalid uuid format") + } + + return nil +} + +// WorkflowServiceUpdateRequestMultiError is an error wrapping multiple +// validation errors returned by WorkflowServiceUpdateRequest.ValidateAll() if +// the designated constraints aren't met. +type WorkflowServiceUpdateRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m WorkflowServiceUpdateRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m WorkflowServiceUpdateRequestMultiError) AllErrors() []error { return m } + +// WorkflowServiceUpdateRequestValidationError is the validation error returned +// by WorkflowServiceUpdateRequest.Validate if the designated constraints +// aren't met. +type WorkflowServiceUpdateRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e WorkflowServiceUpdateRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e WorkflowServiceUpdateRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e WorkflowServiceUpdateRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e WorkflowServiceUpdateRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e WorkflowServiceUpdateRequestValidationError) ErrorName() string { + return "WorkflowServiceUpdateRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e WorkflowServiceUpdateRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sWorkflowServiceUpdateRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = WorkflowServiceUpdateRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = WorkflowServiceUpdateRequestValidationError{} + +// Validate checks the field values on WorkflowServiceUpdateResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *WorkflowServiceUpdateResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on WorkflowServiceUpdateResponse with +// the rules defined in the proto definition for this message. If any rules +// are violated, the result is a list of violation errors wrapped in +// WorkflowServiceUpdateResponseMultiError, or nil if none found. +func (m *WorkflowServiceUpdateResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *WorkflowServiceUpdateResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetResult()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, WorkflowServiceUpdateResponseValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, WorkflowServiceUpdateResponseValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResult()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return WorkflowServiceUpdateResponseValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return WorkflowServiceUpdateResponseMultiError(errors) + } + + return nil +} + +// WorkflowServiceUpdateResponseMultiError is an error wrapping multiple +// validation errors returned by WorkflowServiceUpdateResponse.ValidateAll() +// if the designated constraints aren't met. +type WorkflowServiceUpdateResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m WorkflowServiceUpdateResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m WorkflowServiceUpdateResponseMultiError) AllErrors() []error { return m } + +// WorkflowServiceUpdateResponseValidationError is the validation error +// returned by WorkflowServiceUpdateResponse.Validate if the designated +// constraints aren't met. +type WorkflowServiceUpdateResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e WorkflowServiceUpdateResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e WorkflowServiceUpdateResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e WorkflowServiceUpdateResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e WorkflowServiceUpdateResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e WorkflowServiceUpdateResponseValidationError) ErrorName() string { + return "WorkflowServiceUpdateResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e WorkflowServiceUpdateResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sWorkflowServiceUpdateResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = WorkflowServiceUpdateResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = WorkflowServiceUpdateResponseValidationError{} + // Validate checks the field values on WorkflowServiceCreateResponse with the // rules defined in the proto definition for this message. If any rules are // violated, the first error encountered is returned, or nil if there are no violations. @@ -763,266 +1034,3 @@ var _ interface { Cause() error ErrorName() string } = WorkflowServiceListResponseValidationError{} - -// Validate checks the field values on WorkflowServiceChangeVisibilityRequest -// with the rules defined in the proto definition for this message. If any -// rules are violated, the first error encountered is returned, or nil if -// there are no violations. -func (m *WorkflowServiceChangeVisibilityRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// WorkflowServiceChangeVisibilityRequest with the rules defined in the proto -// definition for this message. If any rules are violated, the result is a -// list of violation errors wrapped in -// WorkflowServiceChangeVisibilityRequestMultiError, or nil if none found. -func (m *WorkflowServiceChangeVisibilityRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *WorkflowServiceChangeVisibilityRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if err := m._validateUuid(m.GetId()); err != nil { - err = WorkflowServiceChangeVisibilityRequestValidationError{ - field: "Id", - reason: "value must be a valid UUID", - cause: err, - } - if !all { - return err - } - errors = append(errors, err) - } - - // no validation rules for Public - - if len(errors) > 0 { - return WorkflowServiceChangeVisibilityRequestMultiError(errors) - } - - return nil -} - -func (m *WorkflowServiceChangeVisibilityRequest) _validateUuid(uuid string) error { - if matched := _workflow_uuidPattern.MatchString(uuid); !matched { - return errors.New("invalid uuid format") - } - - return nil -} - -// WorkflowServiceChangeVisibilityRequestMultiError is an error wrapping -// multiple validation errors returned by -// WorkflowServiceChangeVisibilityRequest.ValidateAll() if the designated -// constraints aren't met. -type WorkflowServiceChangeVisibilityRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m WorkflowServiceChangeVisibilityRequestMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m WorkflowServiceChangeVisibilityRequestMultiError) AllErrors() []error { return m } - -// WorkflowServiceChangeVisibilityRequestValidationError is the validation -// error returned by WorkflowServiceChangeVisibilityRequest.Validate if the -// designated constraints aren't met. -type WorkflowServiceChangeVisibilityRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e WorkflowServiceChangeVisibilityRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e WorkflowServiceChangeVisibilityRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e WorkflowServiceChangeVisibilityRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e WorkflowServiceChangeVisibilityRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e WorkflowServiceChangeVisibilityRequestValidationError) ErrorName() string { - return "WorkflowServiceChangeVisibilityRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e WorkflowServiceChangeVisibilityRequestValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sWorkflowServiceChangeVisibilityRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = WorkflowServiceChangeVisibilityRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = WorkflowServiceChangeVisibilityRequestValidationError{} - -// Validate checks the field values on WorkflowServiceChangeVisibilityResponse -// with the rules defined in the proto definition for this message. If any -// rules are violated, the first error encountered is returned, or nil if -// there are no violations. -func (m *WorkflowServiceChangeVisibilityResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// WorkflowServiceChangeVisibilityResponse with the rules defined in the proto -// definition for this message. If any rules are violated, the result is a -// list of violation errors wrapped in -// WorkflowServiceChangeVisibilityResponseMultiError, or nil if none found. -func (m *WorkflowServiceChangeVisibilityResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *WorkflowServiceChangeVisibilityResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetResult()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, WorkflowServiceChangeVisibilityResponseValidationError{ - field: "Result", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, WorkflowServiceChangeVisibilityResponseValidationError{ - field: "Result", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResult()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return WorkflowServiceChangeVisibilityResponseValidationError{ - field: "Result", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return WorkflowServiceChangeVisibilityResponseMultiError(errors) - } - - return nil -} - -// WorkflowServiceChangeVisibilityResponseMultiError is an error wrapping -// multiple validation errors returned by -// WorkflowServiceChangeVisibilityResponse.ValidateAll() if the designated -// constraints aren't met. -type WorkflowServiceChangeVisibilityResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m WorkflowServiceChangeVisibilityResponseMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m WorkflowServiceChangeVisibilityResponseMultiError) AllErrors() []error { return m } - -// WorkflowServiceChangeVisibilityResponseValidationError is the validation -// error returned by WorkflowServiceChangeVisibilityResponse.Validate if the -// designated constraints aren't met. -type WorkflowServiceChangeVisibilityResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e WorkflowServiceChangeVisibilityResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e WorkflowServiceChangeVisibilityResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e WorkflowServiceChangeVisibilityResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e WorkflowServiceChangeVisibilityResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e WorkflowServiceChangeVisibilityResponseValidationError) ErrorName() string { - return "WorkflowServiceChangeVisibilityResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e WorkflowServiceChangeVisibilityResponseValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sWorkflowServiceChangeVisibilityResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = WorkflowServiceChangeVisibilityResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = WorkflowServiceChangeVisibilityResponseValidationError{} diff --git a/app/controlplane/api/controlplane/v1/workflow.proto b/app/controlplane/api/controlplane/v1/workflow.proto index 1198b70c1..5b29e501e 100644 --- a/app/controlplane/api/controlplane/v1/workflow.proto +++ b/app/controlplane/api/controlplane/v1/workflow.proto @@ -24,9 +24,9 @@ import "controlplane/v1/response_messages.proto"; service WorkflowService { rpc Create (WorkflowServiceCreateRequest) returns (WorkflowServiceCreateResponse); + rpc Update (WorkflowServiceUpdateRequest) returns (WorkflowServiceUpdateResponse); rpc List (WorkflowServiceListRequest) returns (WorkflowServiceListResponse); rpc Delete (WorkflowServiceDeleteRequest) returns (WorkflowServiceDeleteResponse); - rpc ChangeVisibility (WorkflowServiceChangeVisibilityRequest) returns (WorkflowServiceChangeVisibilityResponse); } message WorkflowServiceCreateRequest { @@ -37,6 +37,21 @@ message WorkflowServiceCreateRequest { string team = 4; } +message WorkflowServiceUpdateRequest { + string id = 1 [(validate.rules).string.uuid = true]; + // "optional" allow us to detect if the value is explicitly set + // and not just the default balue + optional string name = 2; + optional string project = 3; + optional string team = 4; + optional bool public = 5; +} + +message WorkflowServiceUpdateResponse { + WorkflowItem result = 1; +} + + message WorkflowServiceCreateResponse { WorkflowItem result = 1; } @@ -51,15 +66,3 @@ message WorkflowServiceListRequest {} message WorkflowServiceListResponse { repeated WorkflowItem result = 1; } - -message WorkflowServiceChangeVisibilityRequest { - string id = 1 [(validate.rules).string.uuid = true]; - // A public workflow means that any user can - // - access to all its workflow runs - // - their attestation and materials - bool public = 2; -} - -message WorkflowServiceChangeVisibilityResponse { - WorkflowItem result = 1; -} \ No newline at end of file diff --git a/app/controlplane/api/controlplane/v1/workflow_grpc.pb.go b/app/controlplane/api/controlplane/v1/workflow_grpc.pb.go index 8d54da4e3..8da7a3195 100644 --- a/app/controlplane/api/controlplane/v1/workflow_grpc.pb.go +++ b/app/controlplane/api/controlplane/v1/workflow_grpc.pb.go @@ -34,10 +34,10 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - WorkflowService_Create_FullMethodName = "/controlplane.v1.WorkflowService/Create" - WorkflowService_List_FullMethodName = "/controlplane.v1.WorkflowService/List" - WorkflowService_Delete_FullMethodName = "/controlplane.v1.WorkflowService/Delete" - WorkflowService_ChangeVisibility_FullMethodName = "/controlplane.v1.WorkflowService/ChangeVisibility" + WorkflowService_Create_FullMethodName = "/controlplane.v1.WorkflowService/Create" + WorkflowService_Update_FullMethodName = "/controlplane.v1.WorkflowService/Update" + WorkflowService_List_FullMethodName = "/controlplane.v1.WorkflowService/List" + WorkflowService_Delete_FullMethodName = "/controlplane.v1.WorkflowService/Delete" ) // WorkflowServiceClient is the client API for WorkflowService service. @@ -45,9 +45,9 @@ const ( // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type WorkflowServiceClient interface { Create(ctx context.Context, in *WorkflowServiceCreateRequest, opts ...grpc.CallOption) (*WorkflowServiceCreateResponse, error) + Update(ctx context.Context, in *WorkflowServiceUpdateRequest, opts ...grpc.CallOption) (*WorkflowServiceUpdateResponse, error) List(ctx context.Context, in *WorkflowServiceListRequest, opts ...grpc.CallOption) (*WorkflowServiceListResponse, error) Delete(ctx context.Context, in *WorkflowServiceDeleteRequest, opts ...grpc.CallOption) (*WorkflowServiceDeleteResponse, error) - ChangeVisibility(ctx context.Context, in *WorkflowServiceChangeVisibilityRequest, opts ...grpc.CallOption) (*WorkflowServiceChangeVisibilityResponse, error) } type workflowServiceClient struct { @@ -67,27 +67,27 @@ func (c *workflowServiceClient) Create(ctx context.Context, in *WorkflowServiceC return out, nil } -func (c *workflowServiceClient) List(ctx context.Context, in *WorkflowServiceListRequest, opts ...grpc.CallOption) (*WorkflowServiceListResponse, error) { - out := new(WorkflowServiceListResponse) - err := c.cc.Invoke(ctx, WorkflowService_List_FullMethodName, in, out, opts...) +func (c *workflowServiceClient) Update(ctx context.Context, in *WorkflowServiceUpdateRequest, opts ...grpc.CallOption) (*WorkflowServiceUpdateResponse, error) { + out := new(WorkflowServiceUpdateResponse) + err := c.cc.Invoke(ctx, WorkflowService_Update_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *workflowServiceClient) Delete(ctx context.Context, in *WorkflowServiceDeleteRequest, opts ...grpc.CallOption) (*WorkflowServiceDeleteResponse, error) { - out := new(WorkflowServiceDeleteResponse) - err := c.cc.Invoke(ctx, WorkflowService_Delete_FullMethodName, in, out, opts...) +func (c *workflowServiceClient) List(ctx context.Context, in *WorkflowServiceListRequest, opts ...grpc.CallOption) (*WorkflowServiceListResponse, error) { + out := new(WorkflowServiceListResponse) + err := c.cc.Invoke(ctx, WorkflowService_List_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *workflowServiceClient) ChangeVisibility(ctx context.Context, in *WorkflowServiceChangeVisibilityRequest, opts ...grpc.CallOption) (*WorkflowServiceChangeVisibilityResponse, error) { - out := new(WorkflowServiceChangeVisibilityResponse) - err := c.cc.Invoke(ctx, WorkflowService_ChangeVisibility_FullMethodName, in, out, opts...) +func (c *workflowServiceClient) Delete(ctx context.Context, in *WorkflowServiceDeleteRequest, opts ...grpc.CallOption) (*WorkflowServiceDeleteResponse, error) { + out := new(WorkflowServiceDeleteResponse) + err := c.cc.Invoke(ctx, WorkflowService_Delete_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -99,9 +99,9 @@ func (c *workflowServiceClient) ChangeVisibility(ctx context.Context, in *Workfl // for forward compatibility type WorkflowServiceServer interface { Create(context.Context, *WorkflowServiceCreateRequest) (*WorkflowServiceCreateResponse, error) + Update(context.Context, *WorkflowServiceUpdateRequest) (*WorkflowServiceUpdateResponse, error) List(context.Context, *WorkflowServiceListRequest) (*WorkflowServiceListResponse, error) Delete(context.Context, *WorkflowServiceDeleteRequest) (*WorkflowServiceDeleteResponse, error) - ChangeVisibility(context.Context, *WorkflowServiceChangeVisibilityRequest) (*WorkflowServiceChangeVisibilityResponse, error) mustEmbedUnimplementedWorkflowServiceServer() } @@ -112,15 +112,15 @@ type UnimplementedWorkflowServiceServer struct { func (UnimplementedWorkflowServiceServer) Create(context.Context, *WorkflowServiceCreateRequest) (*WorkflowServiceCreateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") } +func (UnimplementedWorkflowServiceServer) Update(context.Context, *WorkflowServiceUpdateRequest) (*WorkflowServiceUpdateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") +} func (UnimplementedWorkflowServiceServer) List(context.Context, *WorkflowServiceListRequest) (*WorkflowServiceListResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method List not implemented") } func (UnimplementedWorkflowServiceServer) Delete(context.Context, *WorkflowServiceDeleteRequest) (*WorkflowServiceDeleteResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") } -func (UnimplementedWorkflowServiceServer) ChangeVisibility(context.Context, *WorkflowServiceChangeVisibilityRequest) (*WorkflowServiceChangeVisibilityResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChangeVisibility not implemented") -} func (UnimplementedWorkflowServiceServer) mustEmbedUnimplementedWorkflowServiceServer() {} // UnsafeWorkflowServiceServer may be embedded to opt out of forward compatibility for this service. @@ -152,56 +152,56 @@ func _WorkflowService_Create_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } -func _WorkflowService_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(WorkflowServiceListRequest) +func _WorkflowService_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WorkflowServiceUpdateRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(WorkflowServiceServer).List(ctx, in) + return srv.(WorkflowServiceServer).Update(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: WorkflowService_List_FullMethodName, + FullMethod: WorkflowService_Update_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WorkflowServiceServer).List(ctx, req.(*WorkflowServiceListRequest)) + return srv.(WorkflowServiceServer).Update(ctx, req.(*WorkflowServiceUpdateRequest)) } return interceptor(ctx, in, info, handler) } -func _WorkflowService_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(WorkflowServiceDeleteRequest) +func _WorkflowService_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WorkflowServiceListRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(WorkflowServiceServer).Delete(ctx, in) + return srv.(WorkflowServiceServer).List(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: WorkflowService_Delete_FullMethodName, + FullMethod: WorkflowService_List_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WorkflowServiceServer).Delete(ctx, req.(*WorkflowServiceDeleteRequest)) + return srv.(WorkflowServiceServer).List(ctx, req.(*WorkflowServiceListRequest)) } return interceptor(ctx, in, info, handler) } -func _WorkflowService_ChangeVisibility_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(WorkflowServiceChangeVisibilityRequest) +func _WorkflowService_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WorkflowServiceDeleteRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(WorkflowServiceServer).ChangeVisibility(ctx, in) + return srv.(WorkflowServiceServer).Delete(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: WorkflowService_ChangeVisibility_FullMethodName, + FullMethod: WorkflowService_Delete_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WorkflowServiceServer).ChangeVisibility(ctx, req.(*WorkflowServiceChangeVisibilityRequest)) + return srv.(WorkflowServiceServer).Delete(ctx, req.(*WorkflowServiceDeleteRequest)) } return interceptor(ctx, in, info, handler) } @@ -217,6 +217,10 @@ var WorkflowService_ServiceDesc = grpc.ServiceDesc{ MethodName: "Create", Handler: _WorkflowService_Create_Handler, }, + { + MethodName: "Update", + Handler: _WorkflowService_Update_Handler, + }, { MethodName: "List", Handler: _WorkflowService_List_Handler, @@ -225,10 +229,6 @@ var WorkflowService_ServiceDesc = grpc.ServiceDesc{ MethodName: "Delete", Handler: _WorkflowService_Delete_Handler, }, - { - MethodName: "ChangeVisibility", - Handler: _WorkflowService_ChangeVisibility_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "controlplane/v1/workflow.proto", diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/workflow.ts b/app/controlplane/api/gen/frontend/controlplane/v1/workflow.ts index f27d4506f..efd351df3 100644 --- a/app/controlplane/api/gen/frontend/controlplane/v1/workflow.ts +++ b/app/controlplane/api/gen/frontend/controlplane/v1/workflow.ts @@ -14,6 +14,22 @@ export interface WorkflowServiceCreateRequest { team: string; } +export interface WorkflowServiceUpdateRequest { + id: string; + /** + * "optional" allow us to detect if the value is explicitly set + * and not just the default balue + */ + name?: string | undefined; + project?: string | undefined; + team?: string | undefined; + public?: boolean | undefined; +} + +export interface WorkflowServiceUpdateResponse { + result?: WorkflowItem; +} + export interface WorkflowServiceCreateResponse { result?: WorkflowItem; } @@ -32,20 +48,6 @@ export interface WorkflowServiceListResponse { result: WorkflowItem[]; } -export interface WorkflowServiceChangeVisibilityRequest { - id: string; - /** - * A public workflow means that any user can - * - access to all its workflow runs - * - their attestation and materials - */ - public: boolean; -} - -export interface WorkflowServiceChangeVisibilityResponse { - result?: WorkflowItem; -} - function createBaseWorkflowServiceCreateRequest(): WorkflowServiceCreateRequest { return { name: "", project: "", schemaId: "", team: "" }; } @@ -143,6 +145,176 @@ export const WorkflowServiceCreateRequest = { }, }; +function createBaseWorkflowServiceUpdateRequest(): WorkflowServiceUpdateRequest { + return { id: "", name: undefined, project: undefined, team: undefined, public: undefined }; +} + +export const WorkflowServiceUpdateRequest = { + encode(message: WorkflowServiceUpdateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.name !== undefined) { + writer.uint32(18).string(message.name); + } + if (message.project !== undefined) { + writer.uint32(26).string(message.project); + } + if (message.team !== undefined) { + writer.uint32(34).string(message.team); + } + if (message.public !== undefined) { + writer.uint32(40).bool(message.public); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): WorkflowServiceUpdateRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseWorkflowServiceUpdateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.id = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.name = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.project = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.team = reader.string(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.public = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): WorkflowServiceUpdateRequest { + return { + id: isSet(object.id) ? String(object.id) : "", + name: isSet(object.name) ? String(object.name) : undefined, + project: isSet(object.project) ? String(object.project) : undefined, + team: isSet(object.team) ? String(object.team) : undefined, + public: isSet(object.public) ? Boolean(object.public) : undefined, + }; + }, + + toJSON(message: WorkflowServiceUpdateRequest): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.name !== undefined && (obj.name = message.name); + message.project !== undefined && (obj.project = message.project); + message.team !== undefined && (obj.team = message.team); + message.public !== undefined && (obj.public = message.public); + return obj; + }, + + create, I>>(base?: I): WorkflowServiceUpdateRequest { + return WorkflowServiceUpdateRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): WorkflowServiceUpdateRequest { + const message = createBaseWorkflowServiceUpdateRequest(); + message.id = object.id ?? ""; + message.name = object.name ?? undefined; + message.project = object.project ?? undefined; + message.team = object.team ?? undefined; + message.public = object.public ?? undefined; + return message; + }, +}; + +function createBaseWorkflowServiceUpdateResponse(): WorkflowServiceUpdateResponse { + return { result: undefined }; +} + +export const WorkflowServiceUpdateResponse = { + encode(message: WorkflowServiceUpdateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.result !== undefined) { + WorkflowItem.encode(message.result, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): WorkflowServiceUpdateResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseWorkflowServiceUpdateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.result = WorkflowItem.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): WorkflowServiceUpdateResponse { + return { result: isSet(object.result) ? WorkflowItem.fromJSON(object.result) : undefined }; + }, + + toJSON(message: WorkflowServiceUpdateResponse): unknown { + const obj: any = {}; + message.result !== undefined && (obj.result = message.result ? WorkflowItem.toJSON(message.result) : undefined); + return obj; + }, + + create, I>>(base?: I): WorkflowServiceUpdateResponse { + return WorkflowServiceUpdateResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>( + object: I, + ): WorkflowServiceUpdateResponse { + const message = createBaseWorkflowServiceUpdateResponse(); + message.result = (object.result !== undefined && object.result !== null) + ? WorkflowItem.fromPartial(object.result) + : undefined; + return message; + }, +}; + function createBaseWorkflowServiceCreateResponse(): WorkflowServiceCreateResponse { return { result: undefined }; } @@ -407,148 +579,15 @@ export const WorkflowServiceListResponse = { }, }; -function createBaseWorkflowServiceChangeVisibilityRequest(): WorkflowServiceChangeVisibilityRequest { - return { id: "", public: false }; -} - -export const WorkflowServiceChangeVisibilityRequest = { - encode(message: WorkflowServiceChangeVisibilityRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== "") { - writer.uint32(10).string(message.id); - } - if (message.public === true) { - writer.uint32(16).bool(message.public); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): WorkflowServiceChangeVisibilityRequest { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseWorkflowServiceChangeVisibilityRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.id = reader.string(); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.public = reader.bool(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): WorkflowServiceChangeVisibilityRequest { - return { - id: isSet(object.id) ? String(object.id) : "", - public: isSet(object.public) ? Boolean(object.public) : false, - }; - }, - - toJSON(message: WorkflowServiceChangeVisibilityRequest): unknown { - const obj: any = {}; - message.id !== undefined && (obj.id = message.id); - message.public !== undefined && (obj.public = message.public); - return obj; - }, - - create, I>>( - base?: I, - ): WorkflowServiceChangeVisibilityRequest { - return WorkflowServiceChangeVisibilityRequest.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): WorkflowServiceChangeVisibilityRequest { - const message = createBaseWorkflowServiceChangeVisibilityRequest(); - message.id = object.id ?? ""; - message.public = object.public ?? false; - return message; - }, -}; - -function createBaseWorkflowServiceChangeVisibilityResponse(): WorkflowServiceChangeVisibilityResponse { - return { result: undefined }; -} - -export const WorkflowServiceChangeVisibilityResponse = { - encode(message: WorkflowServiceChangeVisibilityResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.result !== undefined) { - WorkflowItem.encode(message.result, writer.uint32(10).fork()).ldelim(); - } - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): WorkflowServiceChangeVisibilityResponse { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseWorkflowServiceChangeVisibilityResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.result = WorkflowItem.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(object: any): WorkflowServiceChangeVisibilityResponse { - return { result: isSet(object.result) ? WorkflowItem.fromJSON(object.result) : undefined }; - }, - - toJSON(message: WorkflowServiceChangeVisibilityResponse): unknown { - const obj: any = {}; - message.result !== undefined && (obj.result = message.result ? WorkflowItem.toJSON(message.result) : undefined); - return obj; - }, - - create, I>>( - base?: I, - ): WorkflowServiceChangeVisibilityResponse { - return WorkflowServiceChangeVisibilityResponse.fromPartial(base ?? {}); - }, - - fromPartial, I>>( - object: I, - ): WorkflowServiceChangeVisibilityResponse { - const message = createBaseWorkflowServiceChangeVisibilityResponse(); - message.result = (object.result !== undefined && object.result !== null) - ? WorkflowItem.fromPartial(object.result) - : undefined; - return message; - }, -}; - export interface WorkflowService { Create( request: DeepPartial, metadata?: grpc.Metadata, ): Promise; + Update( + request: DeepPartial, + metadata?: grpc.Metadata, + ): Promise; List( request: DeepPartial, metadata?: grpc.Metadata, @@ -557,10 +596,6 @@ export interface WorkflowService { request: DeepPartial, metadata?: grpc.Metadata, ): Promise; - ChangeVisibility( - request: DeepPartial, - metadata?: grpc.Metadata, - ): Promise; } export class WorkflowServiceClientImpl implements WorkflowService { @@ -569,9 +604,9 @@ export class WorkflowServiceClientImpl implements WorkflowService { constructor(rpc: Rpc) { this.rpc = rpc; this.Create = this.Create.bind(this); + this.Update = this.Update.bind(this); this.List = this.List.bind(this); this.Delete = this.Delete.bind(this); - this.ChangeVisibility = this.ChangeVisibility.bind(this); } Create( @@ -581,6 +616,13 @@ export class WorkflowServiceClientImpl implements WorkflowService { return this.rpc.unary(WorkflowServiceCreateDesc, WorkflowServiceCreateRequest.fromPartial(request), metadata); } + Update( + request: DeepPartial, + metadata?: grpc.Metadata, + ): Promise { + return this.rpc.unary(WorkflowServiceUpdateDesc, WorkflowServiceUpdateRequest.fromPartial(request), metadata); + } + List( request: DeepPartial, metadata?: grpc.Metadata, @@ -594,17 +636,6 @@ export class WorkflowServiceClientImpl implements WorkflowService { ): Promise { return this.rpc.unary(WorkflowServiceDeleteDesc, WorkflowServiceDeleteRequest.fromPartial(request), metadata); } - - ChangeVisibility( - request: DeepPartial, - metadata?: grpc.Metadata, - ): Promise { - return this.rpc.unary( - WorkflowServiceChangeVisibilityDesc, - WorkflowServiceChangeVisibilityRequest.fromPartial(request), - metadata, - ); - } } export const WorkflowServiceDesc = { serviceName: "controlplane.v1.WorkflowService" }; @@ -632,19 +663,19 @@ export const WorkflowServiceCreateDesc: UnaryMethodDefinitionish = { } as any, }; -export const WorkflowServiceListDesc: UnaryMethodDefinitionish = { - methodName: "List", +export const WorkflowServiceUpdateDesc: UnaryMethodDefinitionish = { + methodName: "Update", service: WorkflowServiceDesc, requestStream: false, responseStream: false, requestType: { serializeBinary() { - return WorkflowServiceListRequest.encode(this).finish(); + return WorkflowServiceUpdateRequest.encode(this).finish(); }, } as any, responseType: { deserializeBinary(data: Uint8Array) { - const value = WorkflowServiceListResponse.decode(data); + const value = WorkflowServiceUpdateResponse.decode(data); return { ...value, toObject() { @@ -655,19 +686,19 @@ export const WorkflowServiceListDesc: UnaryMethodDefinitionish = { } as any, }; -export const WorkflowServiceDeleteDesc: UnaryMethodDefinitionish = { - methodName: "Delete", +export const WorkflowServiceListDesc: UnaryMethodDefinitionish = { + methodName: "List", service: WorkflowServiceDesc, requestStream: false, responseStream: false, requestType: { serializeBinary() { - return WorkflowServiceDeleteRequest.encode(this).finish(); + return WorkflowServiceListRequest.encode(this).finish(); }, } as any, responseType: { deserializeBinary(data: Uint8Array) { - const value = WorkflowServiceDeleteResponse.decode(data); + const value = WorkflowServiceListResponse.decode(data); return { ...value, toObject() { @@ -678,19 +709,19 @@ export const WorkflowServiceDeleteDesc: UnaryMethodDefinitionish = { } as any, }; -export const WorkflowServiceChangeVisibilityDesc: UnaryMethodDefinitionish = { - methodName: "ChangeVisibility", +export const WorkflowServiceDeleteDesc: UnaryMethodDefinitionish = { + methodName: "Delete", service: WorkflowServiceDesc, requestStream: false, responseStream: false, requestType: { serializeBinary() { - return WorkflowServiceChangeVisibilityRequest.encode(this).finish(); + return WorkflowServiceDeleteRequest.encode(this).finish(); }, } as any, responseType: { deserializeBinary(data: Uint8Array) { - const value = WorkflowServiceChangeVisibilityResponse.decode(data); + const value = WorkflowServiceDeleteResponse.decode(data); return { ...value, toObject() { diff --git a/app/controlplane/internal/biz/casmapping_integration_test.go b/app/controlplane/internal/biz/casmapping_integration_test.go index 09bfda0e0..69d960b06 100644 --- a/app/controlplane/internal/biz/casmapping_integration_test.go +++ b/app/controlplane/internal/biz/casmapping_integration_test.go @@ -323,10 +323,10 @@ func (s *casMappingIntegrationSuite) SetupTest() { // Create workflowRun in the database // Workflow - workflow, err := s.Workflow.Create(ctx, &biz.CreateOpts{Name: "test workflow", OrgID: s.org1.ID}) + workflow, err := s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org1.ID}) assert.NoError(err) - publicWorkflow, err := s.Workflow.Create(ctx, &biz.CreateOpts{Name: "test workflow", OrgID: s.org1.ID}) + publicWorkflow, err := s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org1.ID}) assert.NoError(err) _, err = s.Workflow.ChangeVisibility(ctx, s.org1.ID, publicWorkflow.ID.String(), true) assert.NoError(err) diff --git a/app/controlplane/internal/biz/integration_test.go b/app/controlplane/internal/biz/integration_test.go index 234bcc4a5..f72874185 100644 --- a/app/controlplane/internal/biz/integration_test.go +++ b/app/controlplane/internal/biz/integration_test.go @@ -193,7 +193,7 @@ func (s *testSuite) SetupTest() { assert.NoError(err) // Workflow - s.workflow, err = s.Workflow.Create(ctx, &biz.CreateOpts{Name: "test workflow", OrgID: s.org.ID}) + s.workflow, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org.ID}) assert.NoError(err) // Integration configuration diff --git a/app/controlplane/internal/biz/organization_integration_test.go b/app/controlplane/internal/biz/organization_integration_test.go index fdb2c30dc..c2e129ad2 100644 --- a/app/controlplane/internal/biz/organization_integration_test.go +++ b/app/controlplane/internal/biz/organization_integration_test.go @@ -132,7 +132,7 @@ func (s *OrgIntegrationTestSuite) SetupTest() { assert.NoError(err) // Workflow + contract - _, err = s.Workflow.Create(ctx, &biz.CreateOpts{Name: "test workflow", OrgID: s.org.ID}) + _, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org.ID}) assert.NoError(err) // check integration, OCI repository and workflow and contracts are present in the db diff --git a/app/controlplane/internal/biz/workflow.go b/app/controlplane/internal/biz/workflow.go index 599994f65..2b68aa7c6 100644 --- a/app/controlplane/internal/biz/workflow.go +++ b/app/controlplane/internal/biz/workflow.go @@ -38,22 +38,28 @@ type Workflow struct { } type WorkflowRepo interface { - Create(context.Context, *CreateOpts) (*Workflow, error) + Create(ctx context.Context, opts *WorkflowCreateOpts) (*Workflow, error) + Update(ctx context.Context, id uuid.UUID, opts *WorkflowUpdateOpts) (*Workflow, error) List(ctx context.Context, orgID uuid.UUID) ([]*Workflow, error) GetOrgScoped(ctx context.Context, orgID, workflowID uuid.UUID) (*Workflow, error) IncRunsCounter(ctx context.Context, workflowID uuid.UUID) error FindByID(ctx context.Context, workflowID uuid.UUID) (*Workflow, error) SoftDelete(ctx context.Context, workflowID uuid.UUID) error - ChangeVisibility(ctx context.Context, workflowID uuid.UUID, public bool) (*Workflow, error) } -type CreateOpts struct { +// TODO: move to pointer properties to handle empty values +type WorkflowCreateOpts struct { Name, OrgID, Project, Team, ContractID string // Public means that the associated workflow runs, attestations and materials // are reachable by other users, regardless of their organization Public bool } +type WorkflowUpdateOpts struct { + Name, Project, Team *string + Public *bool +} + type WorkflowUseCase struct { wfRepo WorkflowRepo contractUC *WorkflowContractUseCase @@ -64,7 +70,7 @@ func NewWorkflowUsecase(wfr WorkflowRepo, schemaUC *WorkflowContractUseCase, log return &WorkflowUseCase{wfRepo: wfr, contractUC: schemaUC, logger: log.NewHelper(logger)} } -func (uc *WorkflowUseCase) Create(ctx context.Context, opts *CreateOpts) (*Workflow, error) { +func (uc *WorkflowUseCase) Create(ctx context.Context, opts *WorkflowCreateOpts) (*Workflow, error) { if opts.Name == "" { return nil, errors.New("workflow name is required") } @@ -79,6 +85,34 @@ func (uc *WorkflowUseCase) Create(ctx context.Context, opts *CreateOpts) (*Workf return uc.wfRepo.Create(ctx, opts) } +func (uc *WorkflowUseCase) Update(ctx context.Context, orgID, workflowID string, opts *WorkflowUpdateOpts) (*Workflow, error) { + orgUUID, err := uuid.Parse(orgID) + if err != nil { + return nil, NewErrInvalidUUID(err) + } + + workflowUUID, err := uuid.Parse(workflowID) + if err != nil { + return nil, NewErrInvalidUUID(err) + } + + // make sure that the workflow is for the provided org + if wf, err := uc.wfRepo.GetOrgScoped(ctx, orgUUID, workflowUUID); err != nil { + return nil, err + } else if wf == nil { + return nil, NewErrNotFound("workflow in organization") + } + + wf, err := uc.wfRepo.Update(ctx, workflowUUID, opts) + if err != nil { + return nil, fmt.Errorf("failed to update workflow: %w", err) + } else if wf == nil { + return nil, NewErrNotFound("workflow") + } + + return wf, err +} + func (uc *WorkflowUseCase) findOrCreateContract(ctx context.Context, orgID, contractID, project, name string) (*WorkflowContract, error) { // The contractID has been provided so we try to find it in our org if contractID != "" { @@ -108,27 +142,6 @@ func (uc *WorkflowUseCase) IncRunsCounter(ctx context.Context, workflowID string return uc.wfRepo.IncRunsCounter(ctx, workflowUUID) } -func (uc *WorkflowUseCase) ChangeVisibility(ctx context.Context, orgID, workflowID string, public bool) (*Workflow, error) { - orgUUID, err := uuid.Parse(orgID) - if err != nil { - return nil, NewErrInvalidUUID(err) - } - - workflowUUID, err := uuid.Parse(workflowID) - if err != nil { - return nil, NewErrInvalidUUID(err) - } - - // make sure that the workflow is for the provided org - if wf, err := uc.wfRepo.GetOrgScoped(ctx, orgUUID, workflowUUID); err != nil { - return nil, err - } else if wf == nil { - return nil, NewErrNotFound("workflow in organization") - } - - return uc.wfRepo.ChangeVisibility(ctx, workflowUUID, public) -} - func (uc *WorkflowUseCase) FindByID(ctx context.Context, workflowID string) (*Workflow, error) { workflowUUID, err := uuid.Parse(workflowID) if err != nil { diff --git a/app/controlplane/internal/biz/workflow_integration_test.go b/app/controlplane/internal/biz/workflow_integration_test.go index 3fb287167..ee04da268 100644 --- a/app/controlplane/internal/biz/workflow_integration_test.go +++ b/app/controlplane/internal/biz/workflow_integration_test.go @@ -107,6 +107,6 @@ func (s *workflowIntegrationTestSuite) SetupTest() { ctx := context.Background() s.org, err = s.Organization.Create(ctx, "testing org") assert.NoError(err) - s.workflow, err = s.Workflow.Create(ctx, &biz.CreateOpts{Name: "test workflow", OrgID: s.org.ID}) + s.workflow, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org.ID}) assert.NoError(err) } diff --git a/app/controlplane/internal/biz/workflowrun_integration_test.go b/app/controlplane/internal/biz/workflowrun_integration_test.go index f756a02a5..76add728b 100644 --- a/app/controlplane/internal/biz/workflowrun_integration_test.go +++ b/app/controlplane/internal/biz/workflowrun_integration_test.go @@ -232,12 +232,12 @@ func (s *workflowRunIntegrationTestSuite) SetupTest() { assert.NoError(err) // Workflow - s.workflowOrg1, err = s.Workflow.Create(ctx, &biz.CreateOpts{Name: "test workflow", OrgID: s.org.ID}) + s.workflowOrg1, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org.ID}) assert.NoError(err) - s.workflowOrg2, err = s.Workflow.Create(ctx, &biz.CreateOpts{Name: "test workflow", OrgID: s.org2.ID}) + s.workflowOrg2, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org2.ID}) assert.NoError(err) // Public workflow - s.workflowPublicOrg2, err = s.Workflow.Create(ctx, &biz.CreateOpts{Name: "test public workflow", OrgID: s.org2.ID, Public: true}) + s.workflowPublicOrg2, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test public workflow", OrgID: s.org2.ID, Public: true}) assert.NoError(err) // Robot account diff --git a/app/controlplane/internal/data/workflow.go b/app/controlplane/internal/data/workflow.go index 888e4d4cc..9e1cd573c 100644 --- a/app/controlplane/internal/data/workflow.go +++ b/app/controlplane/internal/data/workflow.go @@ -17,6 +17,7 @@ package data import ( "context" + "fmt" "time" "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz" @@ -40,7 +41,7 @@ func NewWorkflowRepo(data *Data, logger log.Logger) biz.WorkflowRepo { } } -func (r *WorkflowRepo) Create(ctx context.Context, opts *biz.CreateOpts) (*biz.Workflow, error) { +func (r *WorkflowRepo) Create(ctx context.Context, opts *biz.WorkflowCreateOpts) (*biz.Workflow, error) { orgUUID, err := uuid.Parse(opts.OrgID) if err != nil { return nil, err @@ -68,6 +69,27 @@ func (r *WorkflowRepo) Create(ctx context.Context, opts *biz.CreateOpts) (*biz.W return r.FindByID(ctx, wf.ID) } +func (r *WorkflowRepo) Update(ctx context.Context, id uuid.UUID, opts *biz.WorkflowUpdateOpts) (*biz.Workflow, error) { + req := r.data.db.Workflow.UpdateOneID(id). + SetNillableTeam(opts.Team). + SetNillableProject(opts.Project). + SetNillablePublic(opts.Public) + + // Required schema properties do not have a nillable setter + // https://github.com/ent/ent/issues/2108#issuecomment-961898661 + if opts.Name != nil && *opts.Name != "" { + req = req.SetName(*opts.Name) + } + + wf, err := req.Save(ctx) + if err != nil { + return nil, fmt.Errorf("failed to update workflow: %w", err) + } + + // Reload the object to include the relations + return r.FindByID(ctx, wf.ID) +} + func (r *WorkflowRepo) List(ctx context.Context, orgID uuid.UUID) ([]*biz.Workflow, error) { workflows, err := orgScopedQuery(r.data.db, orgID). QueryWorkflows(). @@ -140,15 +162,6 @@ func (r *WorkflowRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.Workflo return entWFToBizWF(workflow, lastRun), nil } -func (r *WorkflowRepo) ChangeVisibility(ctx context.Context, id uuid.UUID, public bool) (*biz.Workflow, error) { - workflow, err := r.data.db.Workflow.UpdateOneID(id).SetPublic(public).Save(ctx) - if err != nil { - return nil, err - } - - return r.FindByID(ctx, workflow.ID) -} - func (r *WorkflowRepo) SoftDelete(ctx context.Context, id uuid.UUID) error { tx, err := r.data.db.Tx(ctx) if err != nil { diff --git a/app/controlplane/internal/dispatcher/dispatcher_test.go b/app/controlplane/internal/dispatcher/dispatcher_test.go index 4943269a1..bddc81d46 100644 --- a/app/controlplane/internal/dispatcher/dispatcher_test.go +++ b/app/controlplane/internal/dispatcher/dispatcher_test.go @@ -221,11 +221,11 @@ func (s *dispatcherTestSuite) SetupTest() { assert.NoError(s.T(), err) // Workflow - s.workflow, err = s.Workflow.Create(ctx, &biz.CreateOpts{Name: "test workflow", OrgID: s.org.ID}) + s.workflow, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org.ID}) assert.NoError(s.T(), err) // Workflow - s.emptyWorkflow, err = s.Workflow.Create(ctx, &biz.CreateOpts{Name: "empty workflow", OrgID: s.org.ID}) + s.emptyWorkflow, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "empty workflow", OrgID: s.org.ID}) assert.NoError(s.T(), err) customImplementation := mockedSDK.NewFanOutPlugin(s.T()) diff --git a/app/controlplane/internal/service/workflow.go b/app/controlplane/internal/service/workflow.go index 9eb0acf81..364961aed 100644 --- a/app/controlplane/internal/service/workflow.go +++ b/app/controlplane/internal/service/workflow.go @@ -48,7 +48,7 @@ func (s *WorkflowService) Create(ctx context.Context, req *pb.WorkflowServiceCre return nil, err } - createOpts := &biz.CreateOpts{ + createOpts := &biz.WorkflowCreateOpts{ OrgID: currentOrg.ID, Name: req.GetName(), Project: req.GetProject(), @@ -69,6 +69,32 @@ func (s *WorkflowService) Create(ctx context.Context, req *pb.WorkflowServiceCre return &pb.WorkflowServiceCreateResponse{Result: workflow}, nil } +func (s *WorkflowService) Update(ctx context.Context, req *pb.WorkflowServiceUpdateRequest) (*pb.WorkflowServiceUpdateResponse, error) { + _, currentOrg, err := loadCurrentUserAndOrg(ctx) + if err != nil { + return nil, err + } + + updateOpts := &biz.WorkflowUpdateOpts{ + Name: req.Name, + Project: req.Project, + Team: req.Team, + Public: req.Public, + } + + p, err := s.useCase.Update(ctx, currentOrg.ID, req.Id, updateOpts) + if err != nil { + return nil, sl.LogAndMaskErr(err, s.log) + } + + workflow := bizWorkflowToPb(p) + if err := workflow.ValidateAll(); err != nil { + return nil, err + } + + return &pb.WorkflowServiceUpdateResponse{Result: workflow}, nil +} + func (s *WorkflowService) List(ctx context.Context, _ *pb.WorkflowServiceListRequest) (*pb.WorkflowServiceListResponse, error) { _, currentOrg, err := loadCurrentUserAndOrg(ctx) if err != nil { @@ -103,22 +129,6 @@ func (s *WorkflowService) Delete(ctx context.Context, req *pb.WorkflowServiceDel return &pb.WorkflowServiceDeleteResponse{}, nil } -func (s *WorkflowService) ChangeVisibility(ctx context.Context, req *pb.WorkflowServiceChangeVisibilityRequest) (*pb.WorkflowServiceChangeVisibilityResponse, error) { - _, currentOrg, err := loadCurrentUserAndOrg(ctx) - if err != nil { - return nil, err - } - - wf, err := s.useCase.ChangeVisibility(ctx, currentOrg.ID, req.Id, req.Public) - if err != nil { - return nil, handleUseCaseErr(workflowEntity, err, s.log) - } - - return &pb.WorkflowServiceChangeVisibilityResponse{ - Result: bizWorkflowToPb(wf), - }, nil -} - func bizWorkflowToPb(wf *biz.Workflow) *pb.WorkflowItem { item := &pb.WorkflowItem{ Id: wf.ID.String(), Name: wf.Name, CreatedAt: timestamppb.New(*wf.CreatedAt), From f84e62d997da370e203096763eec0d6761e358fe Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Tue, 14 Nov 2023 14:53:38 +0100 Subject: [PATCH 2/4] Update workflow API Signed-off-by: Miguel Martinez Trivino --- app/cli/cmd/workflow.go | 2 +- app/cli/cmd/workflow_update.go | 67 ++++++++++++++++++++++ app/cli/internal/action/workflow_update.go | 50 ++++++++++++++++ 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 app/cli/cmd/workflow_update.go create mode 100644 app/cli/internal/action/workflow_update.go diff --git a/app/cli/cmd/workflow.go b/app/cli/cmd/workflow.go index 1ef8b590a..960a1a447 100644 --- a/app/cli/cmd/workflow.go +++ b/app/cli/cmd/workflow.go @@ -26,6 +26,6 @@ func newWorkflowCmd() *cobra.Command { Short: "Workflow, contracts, robot-accounts and runs management in the control plane", } - cmd.AddCommand(newWorkflowListCmd(), newWorkflowCreateCmd(), newWorkflowDeleteCmd(), newWorkflowRobotAccountCmd(), newWorkflowWorkflowRunCmd(), newWorkflowContractCmd(), newAttachedIntegrationCmd()) + cmd.AddCommand(newWorkflowListCmd(), newWorkflowCreateCmd(), newWorkflowUpdateCmd(), newWorkflowDeleteCmd(), newWorkflowRobotAccountCmd(), newWorkflowWorkflowRunCmd(), newWorkflowContractCmd(), newAttachedIntegrationCmd()) return cmd } diff --git a/app/cli/cmd/workflow_update.go b/app/cli/cmd/workflow_update.go new file mode 100644 index 000000000..ffea67deb --- /dev/null +++ b/app/cli/cmd/workflow_update.go @@ -0,0 +1,67 @@ +// +// Copyright 2023 The Chainloop Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "context" + + "github.com/chainloop-dev/chainloop/app/cli/internal/action" + "github.com/spf13/cobra" +) + +func newWorkflowUpdateCmd() *cobra.Command { + var workflowID, name, project, team string + var public bool + + cmd := &cobra.Command{ + Use: "update", + Short: "Update an existing workflow", + RunE: func(cmd *cobra.Command, args []string) error { + opts := &action.NewWorkflowUpdateOpts{} + if cmd.Flags().Changed("name") { + opts.Name = &name + } + if cmd.Flags().Changed("team") { + opts.Team = &team + } + if cmd.Flags().Changed("project") { + opts.Project = &project + } + if cmd.Flags().Changed("public") { + opts.Public = &public + } + + res, err := action.NewWorkflowUpdate(actionOpts).Run(context.Background(), workflowID, opts) + if err != nil { + return err + } + + logger.Info().Msg("Workflow updated!") + return encodeOutput([]*action.WorkflowItem{res}, WorkflowListTableOutput) + }, + } + + cmd.Flags().StringVar(&workflowID, "id", "", "workflow ID") + err := cmd.MarkFlagRequired("id") + cobra.CheckErr(err) + + cmd.Flags().StringVar(&name, "name", "", "workflow name") + cmd.Flags().StringVar(&team, "team", "", "team name") + cmd.Flags().StringVar(&project, "project", "", "project name") + cmd.Flags().BoolVar(&public, "public", false, "is the workflow public") + + return cmd +} diff --git a/app/cli/internal/action/workflow_update.go b/app/cli/internal/action/workflow_update.go new file mode 100644 index 000000000..56dbd0ea1 --- /dev/null +++ b/app/cli/internal/action/workflow_update.go @@ -0,0 +1,50 @@ +// +// Copyright 2023 The Chainloop Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package action + +import ( + "context" + + pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1" +) + +type WorkflowUpdate struct { + cfg *ActionsOpts +} + +func NewWorkflowUpdate(cfg *ActionsOpts) *WorkflowUpdate { + return &WorkflowUpdate{cfg} +} + +type NewWorkflowUpdateOpts struct { + Name, Project, Team *string + Public *bool +} + +func (action *WorkflowUpdate) Run(ctx context.Context, id string, opts *NewWorkflowUpdateOpts) (*WorkflowItem, error) { + client := pb.NewWorkflowServiceClient(action.cfg.CPConnection) + resp, err := client.Update(ctx, &pb.WorkflowServiceUpdateRequest{ + Id: id, + Name: opts.Name, Project: opts.Project, Team: opts.Team, + Public: opts.Public, + }) + + if err != nil { + return nil, err + } + + return pbWorkflowItemToAction(resp.Result), nil +} From 11b77095b755be408d9aee723d1f11e1df537904 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Tue, 14 Nov 2023 16:05:51 +0100 Subject: [PATCH 3/4] Update workflow API Signed-off-by: Miguel Martinez Trivino --- .../biz/casmapping_integration_test.go | 4 +- .../internal/biz/workflow_integration_test.go | 124 ++++++++++++------ app/controlplane/internal/data/workflow.go | 4 + 3 files changed, 91 insertions(+), 41 deletions(-) diff --git a/app/controlplane/internal/biz/casmapping_integration_test.go b/app/controlplane/internal/biz/casmapping_integration_test.go index 69d960b06..1059c6e34 100644 --- a/app/controlplane/internal/biz/casmapping_integration_test.go +++ b/app/controlplane/internal/biz/casmapping_integration_test.go @@ -326,9 +326,7 @@ func (s *casMappingIntegrationSuite) SetupTest() { workflow, err := s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org1.ID}) assert.NoError(err) - publicWorkflow, err := s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org1.ID}) - assert.NoError(err) - _, err = s.Workflow.ChangeVisibility(ctx, s.org1.ID, publicWorkflow.ID.String(), true) + publicWorkflow, err := s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org1.ID, Public: true}) assert.NoError(err) // Robot account diff --git a/app/controlplane/internal/biz/workflow_integration_test.go b/app/controlplane/internal/biz/workflow_integration_test.go index ee04da268..063633b7a 100644 --- a/app/controlplane/internal/biz/workflow_integration_test.go +++ b/app/controlplane/internal/biz/workflow_integration_test.go @@ -22,67 +22,110 @@ import ( "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz" "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz/testhelpers" "github.com/docker/distribution/uuid" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" ) -func (s *workflowIntegrationTestSuite) TestChangeVisibility() { - assert := assert.New(s.T()) +func (s *workflowIntegrationTestSuite) TestUpdate() { + ctx := context.Background() + const ( + name = "test workflow" + team = "test team" + project = "test project" + ) + org2, err := s.Organization.Create(context.Background(), "testing org") - assert.NoError(err) + require.NoError(s.T(), err) + workflow, err := s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: name, OrgID: s.org.ID}) + require.NoError(s.T(), err) + + s.Run("by default the workflow is private", func() { + s.False(workflow.Public) + }) - s.Run("by default the workflow is non public", func() { - assert.False(s.workflow.Public) + s.Run("can't update a workflow in another org", func() { + got, err := s.Workflow.Update(ctx, org2.ID, workflow.ID.String(), nil) + s.True(biz.IsNotFound(err)) + s.Error(err) + s.Nil(got) }) testCases := []struct { - name string - workflowID string - orgID string - public bool - wantErr bool + name string + // if not set, it will use the workflow we create on each run + id string + updates *biz.WorkflowUpdateOpts + want *biz.Workflow + wantErr bool }{ { - name: "non existing workflow", - workflowID: uuid.Generate().String(), - orgID: s.org.ID, - wantErr: true, + name: "non existing workflow", + id: uuid.Generate().String(), + updates: &biz.WorkflowUpdateOpts{Name: toPtrS("new name")}, + wantErr: true, + }, + { + name: "invalid uuid", + id: "deadbeef", + updates: &biz.WorkflowUpdateOpts{Name: toPtrS("new name")}, + wantErr: true, + }, + { + name: "no updates", + want: &biz.Workflow{Name: name, Team: team, Project: project, Public: false}, + }, + { + name: "update name", + updates: &biz.WorkflowUpdateOpts{Name: toPtrS("new name")}, + want: &biz.Workflow{Name: "new name", Team: team, Project: project, Public: false}, }, { - name: "invalid uuid", - workflowID: "deadbeef", - orgID: s.org.ID, - wantErr: true, + name: "update visibility", + updates: &biz.WorkflowUpdateOpts{Public: toPtrBool(true)}, + want: &biz.Workflow{Name: name, Team: team, Project: project, Public: true}, }, { - name: "valid workflow set to true", - workflowID: s.workflow.ID.String(), - orgID: s.org.ID, - public: true, + name: "update all options", + updates: &biz.WorkflowUpdateOpts{Name: toPtrS("new name"), Project: toPtrS("new project"), Team: toPtrS("new team"), Public: toPtrBool(true)}, + want: &biz.Workflow{Name: "new name", Team: "new team", Project: "new project", Public: true}, }, { - name: "valid workflow set to false", - workflowID: s.workflow.ID.String(), - orgID: s.org.ID, - public: false, + name: "name can't be emptied", + updates: &biz.WorkflowUpdateOpts{Name: toPtrS("")}, + want: &biz.Workflow{Name: name, Team: team, Project: project}, }, { - name: "valid workflow in other org", - workflowID: s.workflow.ID.String(), - orgID: org2.ID, - wantErr: true, + name: "but other opts can", + updates: &biz.WorkflowUpdateOpts{Team: toPtrS(""), Project: toPtrS("")}, + want: &biz.Workflow{Name: name, Team: "", Project: ""}, }, } for _, tc := range testCases { s.Run(tc.name, func() { - wf, err := s.Workflow.ChangeVisibility(context.Background(), tc.orgID, tc.workflowID, tc.public) + workflow, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: name, Team: team, Project: project, OrgID: s.org.ID}) + require.NoError(s.T(), err) + + workflowID := tc.id + if workflowID == "" { + workflowID = workflow.ID.String() + } + + got, err := s.Workflow.Update(ctx, s.org.ID, workflowID, tc.updates) if tc.wantErr { - assert.Error(err) + s.Error(err) return } - assert.NoError(err) - assert.Equal(tc.public, wf.Public) + s.NoError(err) + + if diff := cmp.Diff(tc.want, got, + cmpopts.IgnoreFields(biz.Workflow{}, "CreatedAt", "ID", "OrgID", "ContractID"), + ); diff != "" { + s.Failf("mismatch (-want +got):\n%s", diff) + } }) } } @@ -95,8 +138,7 @@ func TestWorkflowUseCase(t *testing.T) { // Utility struct to hold the test suite type workflowIntegrationTestSuite struct { testhelpers.UseCasesEachTestSuite - org *biz.Organization - workflow *biz.Workflow + org *biz.Organization } func (s *workflowIntegrationTestSuite) SetupTest() { @@ -107,6 +149,12 @@ func (s *workflowIntegrationTestSuite) SetupTest() { ctx := context.Background() s.org, err = s.Organization.Create(ctx, "testing org") assert.NoError(err) - s.workflow, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{Name: "test workflow", OrgID: s.org.ID}) - assert.NoError(err) +} + +func toPtrS(s string) *string { + return &s +} + +func toPtrBool(b bool) *bool { + return &b } diff --git a/app/controlplane/internal/data/workflow.go b/app/controlplane/internal/data/workflow.go index 9e1cd573c..06e6e99e7 100644 --- a/app/controlplane/internal/data/workflow.go +++ b/app/controlplane/internal/data/workflow.go @@ -70,6 +70,10 @@ func (r *WorkflowRepo) Create(ctx context.Context, opts *biz.WorkflowCreateOpts) } func (r *WorkflowRepo) Update(ctx context.Context, id uuid.UUID, opts *biz.WorkflowUpdateOpts) (*biz.Workflow, error) { + if opts == nil { + opts = &biz.WorkflowUpdateOpts{} + } + req := r.data.db.Workflow.UpdateOneID(id). SetNillableTeam(opts.Team). SetNillableProject(opts.Project). From 0c211e38151b8b38adc05d444081f4f05c88c102 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Tue, 14 Nov 2023 16:12:17 +0100 Subject: [PATCH 4/4] Update workflow API Signed-off-by: Miguel Martinez Trivino --- app/controlplane/internal/service/workflow.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/controlplane/internal/service/workflow.go b/app/controlplane/internal/service/workflow.go index 364961aed..985c1a646 100644 --- a/app/controlplane/internal/service/workflow.go +++ b/app/controlplane/internal/service/workflow.go @@ -26,8 +26,6 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" ) -const workflowEntity = "Workflow" - type WorkflowService struct { pb.UnimplementedWorkflowServiceServer *service