Skip to content

Commit 4b32d78

Browse files
haulethstack72
authored andcommitted
Add namespcace ID attribute (#14483)
* Add namespcace ID attribute This commit also introduce `id` comouted value which is numeric value used by GitLab to iteract with repository. This should simplify use of `gitlab_project_hook` usage and would allow to introduce other resources as described in #14471 * Fixes requested by @richardc * Handle optional `namespace_id`
1 parent fe72309 commit 4b32d78

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

resource_gitlab_project.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ func resourceGitlabProject() *schema.Resource {
2121
Type: schema.TypeString,
2222
Required: true,
2323
},
24+
"namespace_id": {
25+
Type: schema.TypeInt,
26+
Optional: true,
27+
},
2428
"description": {
2529
Type: schema.TypeString,
2630
Optional: true,
@@ -97,6 +101,10 @@ func resourceGitlabProjectCreate(d *schema.ResourceData, meta interface{}) error
97101
SnippetsEnabled: gitlab.Bool(d.Get("snippets_enabled").(bool)),
98102
}
99103

104+
if v, ok := d.GetOk("namespace_id"); ok {
105+
options.NamespaceID = gitlab.Int(v.(int))
106+
}
107+
100108
if v, ok := d.GetOk("description"); ok {
101109
options.Description = gitlab.String(v.(string))
102110
}

resource_gitlab_project_hook_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ resource "gitlab_project" "foo" {
186186
}
187187
188188
resource "gitlab_project_hook" "foo" {
189-
project = "${gitlab_project.foo.id}"
190-
url = "https://example.com/hook-%d"
189+
project = "${gitlab_project.foo.id}"
190+
url = "https://example.com/hook-%d"
191191
}
192192
`, rInt, rInt)
193193
}
@@ -204,17 +204,17 @@ resource "gitlab_project" "foo" {
204204
}
205205
206206
resource "gitlab_project_hook" "foo" {
207-
project = "${gitlab_project.foo.id}"
208-
url = "https://example.com/hook-%d"
209-
enable_ssl_verification = false
210-
push_events = false
211-
issues_events = true
212-
merge_requests_events = true
213-
tag_push_events = true
214-
note_events = true
215-
build_events = true
216-
pipeline_events = true
217-
wiki_page_events = true
207+
project = "${gitlab_project.foo.id}"
208+
url = "https://example.com/hook-%d"
209+
enable_ssl_verification = false
210+
push_events = false
211+
issues_events = true
212+
merge_requests_events = true
213+
tag_push_events = true
214+
note_events = true
215+
build_events = true
216+
pipeline_events = true
217+
wiki_page_events = true
218218
}
219219
`, rInt, rInt)
220220
}

resource_gitlab_project_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ resource "gitlab_project" "foo" {
182182
# with no billing
183183
visibility_level = "public"
184184
185-
issues_enabled = false
186-
merge_requests_enabled = false
187-
wiki_enabled = false
188-
snippets_enabled = false
185+
issues_enabled = false
186+
merge_requests_enabled = false
187+
wiki_enabled = false
188+
snippets_enabled = false
189189
}
190190
`, rInt)
191191
}

0 commit comments

Comments
 (0)