jdamata / terraform-provider-sonarqube

Terraform provider for managing Sonarqube configuration
GNU General Public License v3.0
62 stars 54 forks source link

add logic for handling copy_from argument #132

Closed felixlut closed 1 year ago

felixlut commented 1 year ago

This PR introduces the copy_from argument when creating a SonarQube Quality Gate.

It does so by calling the api/qualitygates/copy API as opposed to the regular api/qualitygates/create endpoint if the copy_from argument is supplied.

Resolves #131

felixlut commented 1 year ago

Testing the copy functionality is not trivial since it's only really the conditions for it that are copied. This in combination that a Quality Gate is created with a number of conditions by default makes it a bit hard.

My idea right now is to do the following steps:

1. Create a base Quality Gate (including the default conditons that comes with this call)
2. Create a custom condition for it on top of the default ones 
3. Create a copy of the base gate
4. Check that the custom condition is indeed in the list of conditions in the copy

Conceptually this is quite easy, but I'll probably have to dig into custom validation functions a bit to make it work

felixlut commented 1 year ago

Testing the copy functionality is not trivial since it's only really the conditions for it that are copied. This in combination that a Quality Gate is created with a number of conditions by default makes it a bit hard.

My idea right now is to do the following steps:

1. Create a base Quality Gate (including the default conditons that comes with this call)

2. Create a custom condition for it on top of the default ones

3. Create a copy of the base gate

4. Check that the custom condition is indeed in the list of conditions in the copy

Conceptually this is quite easy, but I'll probably have to dig into custom validation functions a bit to make it work

Ended up changing step 4 to checking for equality between the base and copied gates