-
Couldn't load subscription status.
- Fork 37
feat(events): Send events for workflow contract changes #1663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // | ||
| // Copyright 2024 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 events_test | ||
|
|
||
| import ( | ||
| "flag" | ||
| "os" | ||
| "testing" | ||
| ) | ||
|
|
||
| var updateGolden bool | ||
|
|
||
| const testEmail = "john@cyberdyne.io" | ||
|
|
||
| func TestMain(m *testing.M) { | ||
| flag.BoolVar(&updateGolden, "update-golden", false, "update the expected golden files") | ||
| // Parse the flags | ||
| flag.Parse() | ||
| os.Exit(m.Run()) | ||
| } |
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
...rolplane/pkg/auditor/events/testdata/workflowcontracts/workflow_attached_to_contract.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "ActionType": "WorkflowContractContractAttached", | ||
| "TargetType": "WorkflowContract", | ||
| "TargetID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorType": "API_TOKEN", | ||
| "ActorID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorEmail": "john@cyberdyne.io", | ||
| "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "Description": "john@cyberdyne.io has attached the workflow test-workflow to the workflow contract test-contract", | ||
| "Info": { | ||
| "workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_contract_name": "test-contract", | ||
| "workflow_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_name": "test-workflow" | ||
| }, | ||
| "Digest": "sha256:1107737635a6c56e4fe4143d678783ab06c0321192f62f56ae1a2d76dea57321" | ||
| } | ||
17 changes: 17 additions & 0 deletions
17
...auditor/events/testdata/workflowcontracts/workflow_attached_to_contract_by_api_token.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "ActionType": "WorkflowContractContractAttached", | ||
| "TargetType": "WorkflowContract", | ||
| "TargetID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorType": "API_TOKEN", | ||
| "ActorID": "2089bb36-e27b-428b-8009-d015c8737c55", | ||
| "ActorEmail": "", | ||
| "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has attached the workflow test-workflow to the workflow contract test-contract", | ||
| "Info": { | ||
| "workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_contract_name": "test-contract", | ||
| "workflow_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_name": "test-workflow" | ||
| }, | ||
| "Digest": "sha256:e3fe1a29d29f1427121c5023b5d643eb4f457aa7eacfc212b4cacce49c813512" | ||
| } |
15 changes: 15 additions & 0 deletions
15
...controlplane/pkg/auditor/events/testdata/workflowcontracts/workflow_contract_created.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "ActionType": "WorkflowContractCreated", | ||
| "TargetType": "WorkflowContract", | ||
| "TargetID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorType": "API_TOKEN", | ||
| "ActorID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorEmail": "john@cyberdyne.io", | ||
| "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "Description": "john@cyberdyne.io has created the workflow contract test-contract", | ||
| "Info": { | ||
| "workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_contract_name": "test-contract" | ||
| }, | ||
| "Digest": "sha256:94f1ad7880f9d5bfcbe6f3a5f3d63cfa714123cd8549f9dba2ac3cc62dd5273f" | ||
| } |
15 changes: 15 additions & 0 deletions
15
...pkg/auditor/events/testdata/workflowcontracts/workflow_contract_created_by_api_token.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "ActionType": "WorkflowContractCreated", | ||
| "TargetType": "WorkflowContract", | ||
| "TargetID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorType": "API_TOKEN", | ||
| "ActorID": "2089bb36-e27b-428b-8009-d015c8737c55", | ||
| "ActorEmail": "", | ||
| "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has created the workflow contract test-contract", | ||
| "Info": { | ||
| "workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_contract_name": "test-contract" | ||
| }, | ||
| "Digest": "sha256:5036a6f579dbad881aeb656e4e6a402cff272e154ff5b9e7aa1631004458c07a" | ||
| } |
15 changes: 15 additions & 0 deletions
15
...controlplane/pkg/auditor/events/testdata/workflowcontracts/workflow_contract_deleted.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "ActionType": "WorkflowContractDeleted", | ||
| "TargetType": "WorkflowContract", | ||
| "TargetID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorType": "API_TOKEN", | ||
| "ActorID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorEmail": "john@cyberdyne.io", | ||
| "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "Description": "john@cyberdyne.io has deleted the workflow contract test-contract", | ||
| "Info": { | ||
| "workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_contract_name": "test-contract" | ||
| }, | ||
| "Digest": "sha256:6ecfc282f25617197cb98e5ee9a3695fd9f12de8a1b54fc01e90ed40cf024421" | ||
| } |
15 changes: 15 additions & 0 deletions
15
...pkg/auditor/events/testdata/workflowcontracts/workflow_contract_deleted_by_api_token.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "ActionType": "WorkflowContractDeleted", | ||
| "TargetType": "WorkflowContract", | ||
| "TargetID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorType": "API_TOKEN", | ||
| "ActorID": "2089bb36-e27b-428b-8009-d015c8737c55", | ||
| "ActorEmail": "", | ||
| "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has deleted the workflow contract test-contract", | ||
| "Info": { | ||
| "workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_contract_name": "test-contract" | ||
| }, | ||
| "Digest": "sha256:84d36161f79c03eea04a85262661a87f149f2ae2812000d46f5c9a994726ef7f" | ||
| } |
18 changes: 18 additions & 0 deletions
18
...controlplane/pkg/auditor/events/testdata/workflowcontracts/workflow_contract_updated.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "ActionType": "WorkflowContractUpdated", | ||
| "TargetType": "WorkflowContract", | ||
| "TargetID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorType": "API_TOKEN", | ||
| "ActorID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorEmail": "john@cyberdyne.io", | ||
| "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "Description": "john@cyberdyne.io has updated the workflow contract test-contract", | ||
| "Info": { | ||
| "workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_contract_name": "test-contract", | ||
| "new_revision_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "new_revision": 1, | ||
| "new_description": "test description" | ||
| }, | ||
| "Digest": "sha256:db328afdbdc39f80f12f433e2740c6de395a3f84bb517a109935929a4178511d" | ||
| } |
18 changes: 18 additions & 0 deletions
18
...pkg/auditor/events/testdata/workflowcontracts/workflow_contract_updated_by_api_token.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "ActionType": "WorkflowContractUpdated", | ||
| "TargetType": "WorkflowContract", | ||
| "TargetID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorType": "API_TOKEN", | ||
| "ActorID": "2089bb36-e27b-428b-8009-d015c8737c55", | ||
| "ActorEmail": "", | ||
| "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has updated the workflow contract test-contract", | ||
| "Info": { | ||
| "workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_contract_name": "test-contract", | ||
| "new_revision_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "new_revision": 1, | ||
| "new_description": "test description" | ||
| }, | ||
| "Digest": "sha256:e289498cc45655632b4eef97fedd932a3c78323a6540809cd645e05cebcf3608" | ||
| } |
17 changes: 17 additions & 0 deletions
17
...lplane/pkg/auditor/events/testdata/workflowcontracts/workflow_detached_from_contract.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "ActionType": "WorkflowContractContractDetached", | ||
| "TargetType": "WorkflowContract", | ||
| "TargetID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorType": "API_TOKEN", | ||
| "ActorID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorEmail": "john@cyberdyne.io", | ||
| "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "Description": "john@cyberdyne.io has detached the workflow test-workflow from the workflow contract test-contract", | ||
| "Info": { | ||
| "workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_contract_name": "test-contract", | ||
| "workflow_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_name": "test-workflow" | ||
| }, | ||
| "Digest": "sha256:c625fbc253b26e5f2cd3158f2b1eaf9be552a8d9d9f414addac36b1da7396661" | ||
| } |
17 changes: 17 additions & 0 deletions
17
...ditor/events/testdata/workflowcontracts/workflow_detached_from_contract_by_api_token.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "ActionType": "WorkflowContractContractDetached", | ||
| "TargetType": "WorkflowContract", | ||
| "TargetID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "ActorType": "API_TOKEN", | ||
| "ActorID": "2089bb36-e27b-428b-8009-d015c8737c55", | ||
| "ActorEmail": "", | ||
| "OrgID": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has detached the workflow test-workflow from the workflow contract test-contract", | ||
| "Info": { | ||
| "workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_contract_name": "test-contract", | ||
| "workflow_id": "1089bb36-e27b-428b-8009-d015c8737c54", | ||
| "workflow_name": "test-workflow" | ||
| }, | ||
| "Digest": "sha256:3abb7051833ec7052a7339ec632eed241c9adf216efe8f3f276d01ba29cc3732" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!