Skip to content

Commit 4b223f9

Browse files
authored
Merge pull request #60 from mineiros-io/mariux/fix-57
feat!: Add visibility parameter and deprecate private parameter
2 parents 64d8146 + 02e49be commit 4b223f9

File tree

10 files changed

+47
-20
lines changed

10 files changed

+47
-20
lines changed

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.7.0]
11+
12+
### Added
13+
14+
- Add support for `visibility` parameter. Defaults to `private` and respects desired state as defined in deprecated `private` parameter.
15+
16+
### Changed
17+
18+
- Add deprecation of `private` parameter.
19+
- **BREAKING CHANGE:** Minimum Github Terraform Provider version increased to `2.9.0`.
20+
1021
### Added
1122

1223
## [0.6.1]
@@ -189,11 +200,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
189200

190201
<!-- markdown-link-check-disable -->
191202

192-
[unreleased]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.6.0...HEAD
193-
[0.6.1]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.6.0...v0.6.1
203+
[unreleased]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.7.0...HEAD
204+
[0.7.0]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.6.1...v0.7.0
194205

195206
<!-- markdown-link-check-enable -->
196207

208+
[0.6.1]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.6.0...v0.6.1
197209
[0.6.0]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.5.1...v0.6.0
198210
[0.5.1]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.5.0...v0.5.1
199211
[0.5.0]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.4.2...v0.5.0

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,29 @@ See [variables.tf] and [examples/] for details and use-cases.
143143
- **`description`**: _(Optional `string`)_
144144

145145
A description of the repository.
146-
Default is `""`
146+
Default is `""`.
147147

148148
- **`delete_branch_on_merge`**: _(Optional `string`)_
149149

150150
Set to `false` to disable the automatic deletion of head branches after pull requests are merged.
151-
Default is `true`
151+
Default is `true`.
152152

153153
- **`homepage_url`**: _(Optional `string`)_
154154

155155
URL of a page describing the project.
156-
Default is `""`
156+
Default is `""`.
157157

158-
- **`private`**: _(Optional `bool`)_
158+
- ~`private`~: _(Optional `bool`)_
159159

160-
Set to false to create a public repository.
161-
Default is `true`
160+
DEPRICATED. Please use `visibility` instead and update your code. parameter will be removed in a future version
161+
162+
- **`visibility`**: _(Optional `string`)_
163+
164+
Can be `public` or `private`.
165+
If your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+, `visibility` can also be `internal`.
166+
The `visibility` parameter overrides the deprecated `private` parameter.
167+
Default is `private`.
168+
If the deprecated `private` boolean parameter is used, the default value is adjusted to respect this setting.
162169

163170
- **`has_issues`**: _(Optional `bool`)_
164171

@@ -192,7 +199,7 @@ See [variables.tf] and [examples/] for details and use-cases.
192199
after a correct reference has been created for the target branch inside the repository.
193200
This means a user will have to omit this parameter from the initial repository creation and
194201
create the target branch inside of the repository prior to setting this attribute.
195-
Default is `""`
202+
Default is `""`.
196203

197204
- **`archived`**: _(Optional `bool`)_
198205

@@ -411,7 +418,7 @@ removed thislimitation.
411418
This is a special argument to set various defaults to be reused for multiple repositories.
412419
The following top-level arguments can be set as defaults:
413420
`homepage_url`,
414-
`private`,
421+
`visibility`,
415422
`has_issues`,
416423
`has_projects`,
417424
`has_wiki`,

examples/public-repository/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ branch protection.
1515
```hcl
1616
module "repository" {
1717
source = "mineiros-io/repository/github"
18-
version = "~> 0.6.0"
18+
version = "~> 0.7.0"
1919
2020
module_depends_on = [
2121
github_team.team
@@ -24,7 +24,7 @@ module "repository" {
2424
name = "my-public-repository"
2525
description = "A description of the repository."
2626
homepage_url = "https://github.com/mineiros-io"
27-
private = false
27+
visibility = "private"
2828
has_issues = true
2929
has_projects = false
3030
has_wiki = true

examples/public-repository/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module "repository" {
1616
name = "my-public-repository"
1717
description = "A description of the repository."
1818
homepage_url = "https://github.com/mineiros-io"
19-
private = false
19+
visibility = "public"
2020
has_issues = true
2121
has_projects = false
2222
has_wiki = true

main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
locals {
88
homepage_url = var.homepage_url == null ? lookup(var.defaults, "homepage_url", "") : var.homepage_url
99
private = var.private == null ? lookup(var.defaults, "private", true) : var.private
10+
private_visibility = local.private ? "private" : "public"
11+
visibility = var.visibility == null ? lookup(var.defaults, "visibility", local.private_visibility) : var.visibility
1012
has_issues = var.has_issues == null ? lookup(var.defaults, "has_issues", false) : var.has_issues
1113
has_projects = var.has_projects == null ? lookup(var.defaults, "has_projects", false) : length(var.projects) > 0 ? true : var.has_projects
1214
has_wiki = var.has_wiki == null ? lookup(var.defaults, "has_wiki", false) : var.has_wiki
@@ -86,7 +88,7 @@ resource "github_repository" "repository" {
8688
name = var.name
8789
description = var.description
8890
homepage_url = local.homepage_url
89-
private = local.private
91+
visibility = local.visibility
9092
has_issues = local.has_issues
9193
has_projects = local.has_projects
9294
has_wiki = local.has_wiki

test/public-repository-complete-example/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ variable "repository_defaults" {
174174
type = any
175175
default = {
176176
homepage_url = "https://github.com/mineiros-io"
177-
private = false
177+
visibility = "private"
178178
allow_merge_commit = true
179179
gitignore_template = "Terraform"
180180
license_template = "mit"

test/public-repository-with-collaborators/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module "repository" {
88
name = var.name
99
description = var.description
1010
homepage_url = var.url
11-
private = false
11+
visibility = "private"
1212
has_issues = var.has_issues
1313
has_projects = var.has_projects
1414
has_wiki = var.has_wiki

test/public_repository_complete_example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestGithubPublicRepositoryCompleteExample(t *testing.T) {
2020
// We pass this map of default repository settings as a variable to Terraform
2121
expectedRepositoryDefaults := map[string]interface{}{
2222
"homepage_url": "https://github.com/mineiros-io",
23-
"private": "false",
23+
"visibility": "public",
2424
"allow_merge_commit": "true",
2525
"gitignore_template": "Terraform",
2626
"license_template": "mit",

variables.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ variable "defaults" {
2828
# Example:
2929
# defaults = {
3030
# homepage_url = "https://mineiros.io/"
31-
# private = true
31+
# visibility = "private"
3232
# has_issues = false
3333
# has_projects = false
3434
# has_wiki = false
@@ -60,11 +60,17 @@ variable "homepage_url" {
6060
}
6161

6262
variable "private" {
63-
description = "Set to false to create a public repository. (Default: true)"
63+
description = "(DEPRECATED: use visibility)"
6464
type = bool
6565
default = null
6666
}
6767

68+
variable "visibility" {
69+
description = "Can be 'public', 'private' or 'internal' (GHE only).The visibility parameter overrides the private parameter. Defaults to 'private' if neither private nor visibility are set, default to state of private parameter if it is set."
70+
type = string
71+
default = null
72+
}
73+
6874
variable "has_issues" {
6975
description = "Set to true to enable the GitHub Issues features on the repository. (Default: false)"
7076
type = bool

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ terraform {
66
required_version = ">= 0.12.20, < 0.15"
77

88
required_providers {
9-
github = ">= 2.6, < 4.0, != 3.1.0"
9+
github = ">= 2.9, < 4.0, != 3.1.0"
1010
}
1111
}

0 commit comments

Comments
 (0)