-
Notifications
You must be signed in to change notification settings - Fork 61
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
Portfolio manual selection #211
Conversation
Thanks for the kind words and the contribution!!! Would be pretty cool if SonarSource wanted to fork and maintain a official provider. |
} | ||
return nil | ||
} | ||
|
||
// Validate the regexp and tag fields if the corresponding selection_mode is chosen | ||
func validatePortfolioResource(d *schema.ResourceData) error { | ||
switch selectionMode := d.Get("selection_mode"); selectionMode { | ||
case "NONE", "MANUAL", "REST": | ||
// TODO: Validate MANUAL properly |
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.
Can you be more descriptive on what we need to validate here. So that in the future we know what should be checked.
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.
Ops I forgot to remove the comment. My idea when I wrote it was that if MANUAL mode was selected, then there should be a validation that selected_projects should have at least one value in it, but I later realized that should not be done.
Firstly because you can just create a MANUAL portfolio and not populate it in the UI. The same should be possible in the provider. But also, if anyone today is using the provider to define MANUAL portfolios, and then add projects to it manually, then using the provider after this goes through would crash.
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.
Actually, that's a test case I didn't cover. What will happen to MANUAL portfolios with projects added outside of terraform. I think the behaviour should be that a bump in version of this provider should not change them at all, but I'll have to test it. I'll do that today or tomorrow
Continuation of comments here. Hmm, so this seems to break existing Portfolios. Having a I'm not sure what the way forward here should be, I can see the following options:
@jdamata I would appreciate feedback here. I'm leaning towards option 2, or maybe 1, but I'm not entirely sure. |
I think i am leaning to option 4. Silently failing/wiping out manual configuration sounds pretty harsh for a breaking change. If there are folks that don't like to fully define their project in terraform, we can revise this later in a future feature request. Otherwise option 2 sounds ok to me as well. |
Option 4 it is! Since we can't really tell how the provider is used in the wild, I think this is a reasonable compromise. The work needed for 4 is minimal, and we are only potentially breaking something. We don't actually know that this is a usecase that someone has, we can only speculate. So I agree with your assessment that a future feature request can rectify it if that is indeed the case |
@jdamata I've learnt something new. Terraform has a built in system for validating a schema after a plan is completed (docs here). My changes since your last review moves the resource "sonarqube_portfolio" "main" {
key = "test-tf-portfolo"
name = "test-tf-portfolo"
description = "test-tf-portfolo"
selection_mode = "MANUAL"
# selected_projects {
# project_key = "my-cool-project"
# }
} |
@felixlut LGTM. Are we good to merge this? |
Yes! And just so you don't forget, it's a breaking change |
@jdamata can we get a new release with this change? I have a Jira ticket with my name on it I wanna close 😅 |
This PR introduces:
MAIN BRANCH
of the projectSide note, @jdamata you're a fucking hero for dealing with the SonarQube API as much as you have ❤️
Using SonarQube at work wouldn't be possible without this. The fact that SonarQube themselves isn't maintaining a provider is beyond me