terraform-provider-gitlab icon indicating copy to clipboard operation
terraform-provider-gitlab copied to clipboard

`public_builds` is always read as `false`

Open mtneug opened this issue 1 year ago • 4 comments

GitLab Provider version

v3.17.0

GitLab version

GitLab Enterprise Edition 15.1.2-ee

Terraform version

v1.2.8

Relevant Terraform Configuration

resource "gitlab_project" "test" {
  name                = "test"
  path                = "test"
  builds_access_level = "private"
  pipelines_enabled   = true
  public_builds       = true
}

# Executing this a second time detects a change in public_builds

# Changing public_builds to false does not detect a change

Relevant log output

No response

Description

Changing public_builds from true to false does not work. This is because the GitLab API changes the name of this field to public_jobs in the response. PublicBuilds is thus never set and uses the default false value.

This inconsistency is known by GitLab, but there has been no recent movement to fix this (this would be a breaking change). One other option would be to map this in the GitLab API client, or this terraform provider.

See https://gitlab.com/gitlab-org/gitlab/-/issues/329725

mtneug avatar Aug 29 '22 10:08 mtneug

This isn't quite as bad as it seems at first glance to fix. I did some testing on a 15.0+ gitlab instance, and "public_jobs" is accepted as both a parameter and provided as a response. Since public_jobs and public_builds are synonyms in this case, we should be able to resolve the bug by updating the go-gitlab library upstream to use the proper verbiage and translating that to the public_builds parameter within the provier.

Flagging as a go-gitlab change along with a bug here.

image

https://github.com/xanzy/go-gitlab/blob/master/projects.go#L85

PatrickRice-KSC avatar Aug 29 '22 19:08 PatrickRice-KSC

Upstream work has been completed so removing go-gitlab label

Shocktrooper avatar Sep 12 '22 04:09 Shocktrooper

@Shocktrooper - We should probably add a new test to the provider for this, just to ensure it's fixed. However, it should "just work" now, I think.

PatrickRice-KSC avatar Sep 14 '22 02:09 PatrickRice-KSC

It would be awesome if any of you could add a test to verify this 😇

timofurrer avatar Sep 16 '22 08:09 timofurrer