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

resource/gitlab_project: correctly handle push rules add and edit #838

Merged
merged 1 commit into from
Feb 7, 2022

Conversation

timofurrer
Copy link
Member

@timofurrer timofurrer commented Feb 3, 2022

This is a possible approach to fix https://github.com/gitlabhq/terraform-provider-gitlab/issues/836. Even though, I am not sure if that is
really that elegant of a solution ...

The root problem here is that the SDK v2 doesn't support to check if an
attribute value was set in config, state or the plan. During creation of
push rules, we don't have a way to distinguish between the default and
if the user has set the default explicitly. This makes the behavior
working for all cases (AFAIK) (incl. changing the instance default push
rules, no automated test possible yet).

This will be possbile in the new terraform provider framework

@timofurrer timofurrer requested a review from armsnyder February 3, 2022 12:29
@timofurrer timofurrer self-assigned this Feb 3, 2022
@github-actions github-actions bot added provider resource Adds or modifies a resource tests size/M labels Feb 3, 2022
@timofurrer timofurrer changed the title resource/gitlab_project: correctly handle push rules add and edit WIP: resource/gitlab_project: correctly handle push rules add and edit Feb 4, 2022
@timofurrer timofurrer added the blocked We are currently blocked to implement this label Feb 4, 2022
@timofurrer timofurrer force-pushed the bugfix/project-push-rules branch 2 times, most recently from 18acd20 to 8b65434 Compare February 4, 2022 09:54
@timofurrer timofurrer removed the blocked We are currently blocked to implement this label Feb 4, 2022
@timofurrer timofurrer force-pushed the bugfix/project-push-rules branch from 8b65434 to 7e3ee19 Compare February 4, 2022 09:56
Copy link
Collaborator

@armsnyder armsnyder left a comment

Choose a reason for hiding this comment

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

Thanks for the new test

gitlab/resource_gitlab_project.go Show resolved Hide resolved
gitlab/resource_gitlab_project.go Outdated Show resolved Hide resolved
@timofurrer timofurrer force-pushed the bugfix/project-push-rules branch from 7e3ee19 to 944a927 Compare February 5, 2022 10:19
@timofurrer
Copy link
Member Author

@armsnyder What do you think about how I solved this? I kinda dislike it and but failed to come up with something better given the constraints of the SDK v2. That exact problem is one of the things addressed in the new framework: https://www.terraform.io/plugin/which-sdk (which we shouldn't switch to just yet, but just saying :D )

@timofurrer timofurrer requested a review from armsnyder February 5, 2022 11:25
Copy link
Collaborator

@armsnyder armsnyder left a comment

Choose a reason for hiding this comment

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

I didn't look too closely since I was happy with the test. Now that you mention it I see a couple things that could be simplified. 😄

gitlab/resource_gitlab_project.go Outdated Show resolved Hide resolved
gitlab/resource_gitlab_project.go Outdated Show resolved Hide resolved
gitlab/resource_gitlab_project.go Outdated Show resolved Hide resolved
@timofurrer timofurrer added the blocked We are currently blocked to implement this label Feb 6, 2022
@timofurrer timofurrer force-pushed the bugfix/project-push-rules branch from 944a927 to 5c3f5cd Compare February 6, 2022 19:59
@timofurrer timofurrer requested a review from armsnyder February 6, 2022 20:00
@timofurrer timofurrer changed the title WIP: resource/gitlab_project: correctly handle push rules add and edit resource/gitlab_project: correctly handle push rules add and edit Feb 6, 2022
@timofurrer timofurrer removed the blocked We are currently blocked to implement this label Feb 7, 2022
This is a possible approach to fix #836. Even though, I am not sure if that is
really that elegant of a solution ...

The root problem here is that the SDK v2 doesn't support to check if an
attribute value was set in config, state or the plan. During creation of
push rules, we don't have a way to distinguish between the default and
if the user has set the default explicitly. This makes the behavior
working for all cases (AFAIK) (incl. changing the instance default push
rules, no automated test possible yet).

This will be possbile in the new terraform provider framework.
@timofurrer timofurrer force-pushed the bugfix/project-push-rules branch from 5c3f5cd to f27db8c Compare February 7, 2022 06:31
@timofurrer timofurrer merged commit bdeab25 into gitlabhq:main Feb 7, 2022
@armsnyder armsnyder added this to the v3.10.0 milestone Feb 7, 2022
@github-actions
Copy link

This functionality has been released in v3.10.0 of the Terraform GitLab Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue. Thank you!

@github-actions github-actions bot locked and limited conversation to collaborators Nov 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

2 participants