Skip to content

Commit

Permalink
Fix resourceGithubDependabotOrganizationSecretCreateOrUpdate (#1759)
Browse files Browse the repository at this point in the history
Fixes a regression used when trying to create/update a dependabot
organization secret. List is an `int` so cannot be cast to a different
type. We therefore double convert it.

There was a regression introduced by version 5.27. This
happened as the go-github client moved over to using int64 as ids in
v53.0.0

```hcl
terraform {
  required_providers {
    github = {
      source = "integrations/github"
      version = "5.27.0"
    }
  }
}

provider "github" {
  owner = var.owner
}

variable "owner" {
  type = string
}

resource "github_repository" "example" {
  name        = "example"
  description = "My awesome codebase"
  visibility = "public"
}

resource "github_dependabot_organization_secret" "example" {
  secret_name     = "example"
  visibility      = "selected"
  plaintext_value = "anything"
  selected_repository_ids = [
    github_repository.example.repo_id,
  ]
}
```
  • Loading branch information
frankywahl authored Jun 27, 2023
1 parent c9a7c1a commit db1c41c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions github/resource_github_dependabot_organization_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"
"encoding/base64"
"fmt"
"log"
"net/http"

"github.com/google/go-github/v53/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"log"
"net/http"
)

func resourceGithubDependabotOrganizationSecret() *schema.Resource {
Expand Down Expand Up @@ -101,7 +102,7 @@ func resourceGithubDependabotOrganizationSecretCreateOrUpdate(d *schema.Resource
ids := selectedRepositories.(*schema.Set).List()

for _, id := range ids {
selectedRepositoryIDs = append(selectedRepositoryIDs, id.(int64))
selectedRepositoryIDs = append(selectedRepositoryIDs, int64(id.(int)))
}
}

Expand Down

0 comments on commit db1c41c

Please sign in to comment.