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

Expose code change webhook from sleuth_code_change_source resource #200

Open
davejbax opened this issue Oct 1, 2024 · 5 comments
Open

Comments

@davejbax
Copy link
Contributor

davejbax commented Oct 1, 2024

We're managing our Sleuth code change sources using this provider, which works great for the most part!

We'd also like to manage the GitLab project webhooks from within the same set of Terraform. The GitLab Terraform provider allows us to create these, but the Sleuth provider does not currently expose the webhook URL or secret for a given code change source.

As I understand, the webhook URL/secret is exposed by Sleuth's GraphQL API. Would it be possible to add these as attributes exposed by a sleuth_code_change_source?

@zigomir
Copy link
Contributor

zigomir commented Oct 2, 2024

Sleuth's GraphQL does expose a repository field via CodeChangeSource > RepositoryType which includes webhook field. That webhook is only meant for creating a webhook that Sleuth itself uses for tracking repository events (i.e. PR merged) and not as a generic webhook. That's why we don't expose webook related fields in a createCodeChangeSource mutation's input.

Why would you prefer using Sleuth's TF provider over GitLab one for managing GitLab project webhooks?

@davejbax
Copy link
Contributor Author

davejbax commented Oct 2, 2024

That webhook is only meant for creating a webhook that Sleuth itself uses for tracking repository events (i.e. PR merged)

Sorry, I should have clarified: we're using GitLab integration in Sleuth in read-only mode. Hence, if I'm not misunderstanding, we need to set up the same webhook ourselves.

in a createCodeChangeSource mutation's input.

To clarify, the issue is not about providing a custom webhook URL to the Sleuth provider, but exposing the webhook URL as an output attribute of the code change source resource. The intention is that our Terraform would create the code change resource, get the webhook URL Sleuth has created along with it, and then set this URL in the GitLab repository ourselves using the GitLab provider (since we are using read-only mode).

Does that help to explain the issue, or am I misunderstanding your question?

@zigomir
Copy link
Contributor

zigomir commented Oct 2, 2024

np, sorry for misunderstanding from my side.

(I'm not too familiar with TF and am sorry if am asking silly questions)

So defining the sleuth_code_change_source block you'd like to see if it would've returned webhook URL and webhook secret (we call it API key on our side) so you could use it for other GitLab specific TF definitions?

i.e.:

# creates code change source in Sleuth
resource "sleuth_code_change_source" "cd" {
  project_slug = sleuth_project.tf.slug
  name = "foo"
  repository = {
     …
  }
}

# Does something in GitLab…
resource "something_gitlab" "gl" {
  webhook = sleuth_code_change_source.cd.webhook
  webhook_secret = sleuth_code_change_source.cd.webhook_secret
}

@davejbax
Copy link
Contributor Author

davejbax commented Oct 2, 2024

Yes, exactly that! 😄 The GitLab resource we'd be using for reference is gitlab_project_hook

@zigomir
Copy link
Contributor

zigomir commented Oct 2, 2024

Got it 👍 I'll see what we can do about it and will keep you updated.

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

No branches or pull requests

2 participants