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

Changing pipelines_enabled from true to false on a bitbucket_repository does not disable pipelines #191

Open
giveadamakick opened this issue Dec 8, 2023 · 1 comment

Comments

@giveadamakick
Copy link

Terraform Version

1.6.1

Affected Resource(s)

  • bitbucket_repository

Terraform Configuration Files

resource "bitbucket_repository" "infrastructure" {
  owner                  = "myteam"
  name                   = "terraform-code"
  pipelines_enabled = false
}

Expected Behavior

The "Enable Pipelines" setting of the repo should have been set to false.

Actual Behavior

The "Enable Pipelines" setting of the repo was still set to true.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Define a bitbucket_repository resource with pipelines_enabled set to true.
  2. terraform apply the new resource.
  3. Note that pipelines are enabled for the new repo, see https://bitbucket.org//<repo_slug>/admin/pipelines/settings
  4. Set pipelines_enabled to false in the Terraform config for that repo.
  5. terraform apply the change.
  6. Note that pipelines are still enabled for the repo.

Important Factoids

Creating a new repo with pipelines_enabled initially to false does work - pipelines are disabled. This bug only occurs when a repo that previously had pipelines enabled is updated to disable pipelines.

References

@Nkmol
Copy link

Nkmol commented Apr 2, 2024

I had a quick look at what could cause this, and it seems to be caused by the encoding of the body to JSON of the client. The following struct defines the pipelines configuration entity:

type PipelinesConfig struct {
	Type_ string `json:"type"`
	Enabled    bool        `json:"enabled,omitempty"`
	Repository *Repository `json:"repository,omitempty"`
}

The problem here is that omitempty is also applied when Enabled: false, thus the value is never sent to the Bitbucket API.

The code solution is to transform the type to a pointer, so the value is only omitted when nil.


Related issue: swagger-api/swagger-codegen#7391

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