-
Notifications
You must be signed in to change notification settings - Fork 892
Adding a computed attribute for the repository owner to the github_repository #2675
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
base: main
Are you sure you want to change the base?
Adding a computed attribute for the repository owner to the github_repository #2675
Conversation
…epository` resource and data source. Fixes integrations#2503
nickfloyd
left a comment
There was a problem hiding this 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()) |
There was a problem hiding this comment.
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
| 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", "")
}
Resolves #2503
Before the change?
full_name, or passed around as a separate variable.After the change?
name+ownerwhen using anonymous auth.full_namewill also still work.Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!