-
Notifications
You must be signed in to change notification settings - Fork 871
Description
Describe the need
The github_repository data source works in two "modes": authenticated or anonymous.
When authenticated, the owner can be implied from the current provider instance, so all that is needed to look up the repository is the name. The full_name is populated in the <organization>/<name> format.
When anonymous, the owner cannot be implied, so the full_name must be used. name is returned as the name portion of the full name.
I propose adding an Optional, Computed owner field to the data source. This could be used in the anonymous mode along with name to specify the repository. Otherwise, it would be populated with the owner of the repository.
This would also have the benefit of keeping all information about the repository contained within the data source object so that it could be used in e.g. a module. Currently, either the owner must be passed as a separate variable or the full_name must be split. This would make the owner a "first-class" field of the data source alongside name, rather than needing to derive it.
For parity between the data source and the resource, also add owner as a Computed field to the resource.
For example, a module can take the resource or data source as an object value. The object will have full_name and name as attributes, but if the owner is needed, it must either be passed separately or parsed from full_name.
Currently your module must be like either
variable "repository" {
type = object({
name = string
...
})
}
variable "repository_owner" {
type = string
}
# Do something with separate fields
...
repo_owner = var.repository_owner
repo_name = var.repository.nameor
variable "repository" {
type = object({
full_name = string
name = string
...
})
}
locals {
repository_owner = split("/", var.repository.full_name)[0]
}
# Do something with separate fields
...
repo_owner = local. repository_owner
repo_name = var.repository.nameIf owner is added as a field, we could do the following:
variable "repository" {
type = object({
name = string
owner = string
...
})
}
# Do something with separate fields
...
repo_owner = var.repository.owner
repo_name = var.repository.nameSDK Version
No response
API Version
No response
Relevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
Status