Skip to content
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

Add namespcace ID attribute #14483

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions builtin/providers/gitlab/resource_gitlab_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func resourceGitlabProject() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
"namespace_id": {
Type: schema.TypeInt,
Optional: true,
},
"description": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -91,6 +95,7 @@ func resourceGitlabProjectCreate(d *schema.ResourceData, meta interface{}) error
client := meta.(*gitlab.Client)
options := &gitlab.CreateProjectOptions{
Name: gitlab.String(d.Get("name").(string)),
NamespaceID: gitlab.Int(d.Get("namespace_id").(int)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One change needed here, this is optional, so it needs to move from here and go with the d.GetOk("") patterned stuff:

if v, ok := d.GetOk("namespace_id"); ok {
   options.NamespaceID = gitlab.Int(v.(int))
}

IssuesEnabled: gitlab.Bool(d.Get("issues_enabled").(bool)),
MergeRequestsEnabled: gitlab.Bool(d.Get("merge_requests_enabled").(bool)),
WikiEnabled: gitlab.Bool(d.Get("wiki_enabled").(bool)),
Expand Down
26 changes: 13 additions & 13 deletions builtin/providers/gitlab/resource_gitlab_project_hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ resource "gitlab_project" "foo" {
}

resource "gitlab_project_hook" "foo" {
project = "${gitlab_project.foo.id}"
url = "https://example.com/hook-%d"
project = "${gitlab_project.foo.id}"
url = "https://example.com/hook-%d"
}
`, rInt, rInt)
}
Expand All @@ -204,17 +204,17 @@ resource "gitlab_project" "foo" {
}

resource "gitlab_project_hook" "foo" {
project = "${gitlab_project.foo.id}"
url = "https://example.com/hook-%d"
enable_ssl_verification = false
push_events = false
issues_events = true
merge_requests_events = true
tag_push_events = true
note_events = true
build_events = true
pipeline_events = true
wiki_page_events = true
project = "${gitlab_project.foo.id}"
url = "https://example.com/hook-%d"
enable_ssl_verification = false
push_events = false
issues_events = true
merge_requests_events = true
tag_push_events = true
note_events = true
build_events = true
pipeline_events = true
wiki_page_events = true
}
`, rInt, rInt)
}
8 changes: 4 additions & 4 deletions builtin/providers/gitlab/resource_gitlab_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ resource "gitlab_project" "foo" {
# with no billing
visibility_level = "public"

issues_enabled = false
merge_requests_enabled = false
wiki_enabled = false
snippets_enabled = false
issues_enabled = false
merge_requests_enabled = false
wiki_enabled = false
snippets_enabled = false
}
`, rInt)
}