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

Initial webhook source setup #271

Merged
merged 12 commits into from
Aug 24, 2023
Merged

Initial webhook source setup #271

merged 12 commits into from
Aug 24, 2023

Conversation

bobbyiliev
Copy link
Contributor

@bobbyiliev bobbyiliev commented Aug 9, 2023

Adding the very initial work for supporting webhook sources.

Things that still need to be ironed out:

  • Add more acceptance tests
  • Improve checkExpression
  • Improve checkOptions
  • I believe that size does not apply to the webhook source, at least judging by the grammar file
  • Integration tests

Closes #270

size string // TODO: size is not supported for webhook sources
bodyFormat string
includeHeaders bool
checkOptions []string
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a custom struct like

type checkOptions struct {
    field string
    alias string
}

Then in the resource we can put in validation to ensure they are only using a field of type BODY, HEADER, or SECRET

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just updated this, but also realized that it might be a bit more complex than my current implementation as I'll have to add a check for the SECRET as well to make sure that an actual secret is provided

`, sourceName)
}

func testAccCheckSourceWebhookExists(name string) resource.TestCheckFunc {
Copy link
Contributor

Choose a reason for hiding this comment

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

Realizing we could just use the same function for all source acceptance tests rather than defining a custom one for each source type. At least for any source that just uses ScanSource.

Optional: true,
ForceNew: true,
},
"size": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the TODO above. Size will eventually be supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not 100% sure if size will ever be supported, as far as I can tell the IN CLUSTER parameter is required. So this is a bit different compared to the rest of the sources that we have. The TODO is mainly for coming up with a way of reimplementing the sourceQuery in a clean way.

if err := b.Create(); err != nil {
return diag.FromErr(err)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Since ownership can be set. Will need a block for the adding ownership.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! Just added this.

@dehume dehume added the new resource A new Terraform resource label Aug 11, 2023
@bobbyiliev bobbyiliev force-pushed the 270-webhook-source branch 5 times, most recently from 65502a6 to d5d713c Compare August 19, 2023 06:34
@bobbyiliev bobbyiliev marked this pull request as ready for review August 21, 2023 21:18
@bobbyiliev bobbyiliev requested a review from dehume August 21, 2023 21:18
@bobbyiliev bobbyiliev merged commit 2602e49 into main Aug 24, 2023
@bobbyiliev bobbyiliev deleted the 270-webhook-source branch August 24, 2023 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new resource A new Terraform resource
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resource Webhook Source
2 participants