Skip to content

Conversation

@AlanCitrix
Copy link

Resolves #2503


Before the change?

  • The repository owner has to either be parsed out of the full_name, or passed around as a separate variable.

After the change?

  • Repository owner is now a computed field in both the repository resource and data source.
  • The data source can be queried by name + owner when using anonymous auth. full_name will also still work.

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@nickfloyd nickfloyd moved this from 🆕 Triage to 👀 In review in 🧰 Octokit Active Jun 3, 2025
@github-actions github-actions bot added Type: Feature New feature or request Type: Documentation Improvements or additions to documentation labels Nov 10, 2025
@nickfloyd nickfloyd moved this from Backlog to In Review in Terraform Provider Nov 10, 2025
Copy link
Member

@nickfloyd nickfloyd left a comment

Choose a reason for hiding this comment

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

Just a comment about making things a little more safe.

d.Set("topics", flattenStringList(repo.Topics))
d.Set("node_id", repo.GetNodeID())
d.Set("repo_id", repo.GetID())
d.Set("owner", repo.GetOwner().GetLogin())
Copy link
Member

Choose a reason for hiding this comment

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

I belive this will panic if nil Recommend using go-github's safe accessor

Suggested change
d.Set("owner", repo.GetOwner().GetLogin())
if repo.Owner != nil {
d.Set("owner", repo.Owner.GetLogin())
}

Alternatively we could defensively:

if repo != nil && repo.Owner != nil {
    d.Set("owner", repo.Owner.GetLogin())
} else {
    d.Set("owner", "")
}

@github-project-automation github-project-automation bot moved this from 👀 In review to 🏗 In progress in 🧰 Octokit Active Nov 10, 2025
@nickfloyd nickfloyd added this to the v6.x version wrap up milestone Nov 20, 2025
_ = d.Set("topics", flattenStringList(repo.Topics))
_ = d.Set("node_id", repo.GetNodeID())
_ = d.Set("repo_id", repo.GetID())
_ = d.Set("owner", repo.GetOwner().GetLogin())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the contribution @AlanCitrix!

Minor fix: please run go fmt . to format your files.


* `full_name` - (Optional) Full name of the repository (in `org/name` format).

* `owner` - (Optional) Owner of the repository. If not provided, the owner specified in the provider configuration will be used.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* `owner` - (Optional) Owner of the repository. If not provided, the owner specified in the provider configuration will be used.
* `owner` - (Optional) Owner of the repository. If not provided, the provider's default owner is used.

This is the phrase used in other resources, since no owner is specified in the provider's configuration.

@diofeher diofeher self-assigned this Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Documentation Improvements or additions to documentation Type: Feature New feature or request

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

[FEAT]: Add owner attribute to github_repository data source and resource

3 participants