Skip to content

Commit 720567e

Browse files
add org id to capability request metadata (#1953)
1 parent c6f7067 commit 720567e

5 files changed

Lines changed: 23 additions & 4 deletions

File tree

pkg/capabilities/capabilities.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ type SpendLimit struct {
171171
type RequestMetadata struct {
172172
WorkflowID string
173173
WorkflowOwner string
174+
OrgID string
174175
WorkflowExecutionID string
175176
WorkflowName string
176177
WorkflowDonID uint32
@@ -192,7 +193,9 @@ type RequestMetadata struct {
192193

193194
func (m *RequestMetadata) ContextWithCRE(ctx context.Context) context.Context {
194195
val := contexts.CREValue(ctx)
195-
// preserve org, if set
196+
if m.OrgID != "" {
197+
val.Org = m.OrgID
198+
}
196199
val.Owner = m.WorkflowOwner
197200
val.Workflow = m.WorkflowID
198201
return contexts.WithCRE(ctx, val)

pkg/capabilities/pb/capabilities.pb.go

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

pkg/capabilities/pb/capabilities.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ message RequestMetadata {
4242
string workflow_id = 1;
4343
string workflow_execution_id = 2;
4444
string workflow_owner = 3;
45+
string org_id = 16;
4546
string workflow_name = 4;
4647
uint32 workflow_don_id = 6;
4748
uint32 workflow_don_config_version = 7;
@@ -210,4 +211,4 @@ service Settings {
210211
message SettingsUpdate {
211212
string settings = 1; // default format TOML
212213
string hash = 2; // default sha256
213-
}
214+
}

pkg/capabilities/pb/capabilities_helpers.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func CapabilityRequestToProto(req capabilities.CapabilityRequest) *CapabilityReq
6666
WorkflowId: req.Metadata.WorkflowID,
6767
WorkflowExecutionId: req.Metadata.WorkflowExecutionID,
6868
WorkflowOwner: req.Metadata.WorkflowOwner,
69+
OrgId: req.Metadata.OrgID,
6970
WorkflowName: req.Metadata.WorkflowName,
7071
WorkflowDonId: req.Metadata.WorkflowDonID,
7172
WorkflowDonConfigVersion: req.Metadata.WorkflowDonConfigVersion,
@@ -147,6 +148,7 @@ func CapabilityRequestFromProto(pr *CapabilityRequest) (capabilities.CapabilityR
147148
WorkflowID: md.WorkflowId,
148149
WorkflowExecutionID: md.WorkflowExecutionId,
149150
WorkflowOwner: md.WorkflowOwner,
151+
OrgID: md.OrgId,
150152
WorkflowName: md.WorkflowName,
151153
WorkflowDonID: md.WorkflowDonId,
152154
WorkflowDonConfigVersion: md.WorkflowDonConfigVersion,
@@ -364,6 +366,7 @@ func TriggerRegistrationRequestToProto(req capabilities.TriggerRegistrationReque
364366
WorkflowId: md.WorkflowID,
365367
WorkflowExecutionId: md.WorkflowExecutionID,
366368
WorkflowOwner: md.WorkflowOwner,
369+
OrgId: md.OrgID,
367370
WorkflowName: md.WorkflowName,
368371
WorkflowDonId: md.WorkflowDonID,
369372
WorkflowDonConfigVersion: md.WorkflowDonConfigVersion,
@@ -428,6 +431,7 @@ func TriggerRegistrationRequestFromProto(req *TriggerRegistrationRequest) (capab
428431
Metadata: capabilities.RequestMetadata{
429432
WorkflowID: md.WorkflowId,
430433
WorkflowOwner: md.WorkflowOwner,
434+
OrgID: md.OrgId,
431435
WorkflowExecutionID: md.WorkflowExecutionId,
432436
WorkflowName: md.WorkflowName,
433437
WorkflowDonID: md.WorkflowDonId,

pkg/capabilities/pb/capabilities_helpers_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func TestMarshalUnmarshalRequest(t *testing.T) {
139139
WorkflowID: "test-workflow-id",
140140
WorkflowExecutionID: testWorkflowID,
141141
WorkflowOwner: "0xaa",
142+
OrgID: "org-123",
142143
WorkflowName: testWorkflowName,
143144
WorkflowDonID: 1,
144145
WorkflowDonConfigVersion: 1,
@@ -236,6 +237,7 @@ func TestMarshalUnmarshalTriggerRegistrationRequest(t *testing.T) {
236237
WorkflowID: "test-workflow-id",
237238
WorkflowExecutionID: testWorkflowID,
238239
WorkflowOwner: testWorkflowOwner,
240+
OrgID: "org-456",
239241
WorkflowName: testWorkflowName,
240242
WorkflowDonID: 2,
241243
WorkflowDonConfigVersion: 3,

0 commit comments

Comments
 (0)