Skip to content

Commit 091c23f

Browse files
committed
Change id to TypeString in gitlab_project data source
Fixes #140. Signed-off-by: Sune Keller <[email protected]>
1 parent a101a1c commit 091c23f

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

docs/data-sources/project.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ data "gitlab_project" "example" {
1010
}
1111
```
1212

13+
```hcl
14+
data "gitlab_project" "example" {
15+
id = "foo/bar/baz"
16+
}
17+
```
18+
1319
## Argument Reference
1420

1521
The following arguments are supported:
1622

17-
* `id` - (Required) The integer that uniquely identifies the project within the gitlab install.
23+
* `id` - (Required) The integer or path with namespace that uniquely identifies the project within the gitlab install.
1824

1925
## Attributes Reference
2026

gitlab/data_source_gitlab_project.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func dataSourceGitlabProject() *schema.Resource {
1616

1717
Schema: map[string]*schema.Schema{
1818
"id": {
19-
Type: schema.TypeInt,
19+
Type: schema.TypeString,
2020
Required: true,
2121
},
2222
"name": {

gitlab/data_source_gitlab_project_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ func TestAccDataGitlabProject_basic(t *testing.T) {
1616
PreCheck: func() { testAccPreCheck(t) },
1717
Providers: testAccProviders,
1818
Steps: []resource.TestStep{
19+
{
20+
Config: testAccDataGitlabProjectConfigByPathWithNamespace(projectname),
21+
Check: testAccDataSourceGitlabProject("gitlab_project.test", "data.gitlab_project.foo",
22+
[]string{"id", "name", "path", "visibility", "description"}),
23+
},
1924
{
2025
Config: testAccDataGitlabProjectConfig(projectname),
2126
Check: testAccDataSourceGitlabProject("gitlab_project.test", "data.gitlab_project.foo",
@@ -68,6 +73,21 @@ data "gitlab_project" "foo" {
6873
`, projectname, projectname)
6974
}
7075

76+
func testAccDataGitlabProjectConfigByPathWithNamespace(projectname string) string {
77+
return fmt.Sprintf(`
78+
resource "gitlab_project" "test"{
79+
name = "%s"
80+
path = "%s"
81+
description = "Terraform acceptance tests"
82+
visibility_level = "public"
83+
}
84+
85+
data "gitlab_project" "foo" {
86+
id = gitlab_project.test.path_with_namespace
87+
}
88+
`, projectname, projectname)
89+
}
90+
7191
func testAccDataGitlabProjectConfigPushRules(projectName string) string {
7292
return fmt.Sprintf(`
7393
resource "gitlab_project" "test"{

0 commit comments

Comments
 (0)