Skip to content
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

Add RDE Type hooks #1122

Merged
merged 10 commits into from
Oct 11, 2023
Merged

Add RDE Type hooks #1122

merged 10 commits into from
Oct 11, 2023

Conversation

adambarreiro
Copy link
Collaborator

@adambarreiro adambarreiro commented Sep 28, 2023

Overview

This PR adds a new feature to existing vcd_rde_type resource and data source: The hook blocks.

A hook block maps a lifecycle event of a given Runtime Defined Entity (vcd_rde), one of:

  • PostCreate: After the RDE of this type is created
  • PostUpdate: After the RDE of this type is updated
  • PreDelete: Before the RDE of this type is deleted
  • PostDelete: After the RDE of this type is deleted

with an existing Behavior. This allows customers to automatically invoke the desired Behavior when these lifecycle events are triggered.

For example, let's imagine there's a Behavior that calls a webhook to send a message to a Slack channel.
If we have an RDE Type with the new block:

hook {
 event = "PostCreate"
 behavior_id = ... # my "send to Slack" behavior ID
}

Whenever a RDE of that Type is created, it will send a message to Slack!

Implementation details

A new block hook is added to vcd_rde_type resource and data source. This has the sub-properties event (the lifecycle event) and behavior_id.

The Behavior referenced by the ID must exist already.

Tests

Tests passed in VCD 10.5.0

Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro self-assigned this Sep 28, 2023
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro marked this pull request as ready for review September 29, 2023 12:58
@adambarreiro adambarreiro changed the title WIP: Add RDE Type hooks Add RDE Type hooks Sep 29, 2023
Signed-off-by: abarreiro <abarreiro@vmware.com>
vcd/resource_vcd_rde_type.go Outdated Show resolved Hide resolved
Signed-off-by: abarreiro <abarreiro@vmware.com>
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Test also passed in 10.4.0, 10.4.1, 10.4.2

@adambarreiro adambarreiro merged commit 73a4e84 into vmware:main Oct 11, 2023
3 checks passed
@adambarreiro adambarreiro deleted the rde-type-hooks branch October 11, 2023 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants