-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Add namespcace ID attribute #14483
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -56,6 +60,10 @@ func resourceGitlabProject() *schema.Resource { | |
Default: "private", | ||
}, | ||
|
||
"id": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
}, | ||
"ssh_url_to_repo": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
|
@@ -82,6 +90,7 @@ func resourceGitlabProjectSetToState(d *schema.ResourceData, project *gitlab.Pro | |
d.Set("snippets_enabled", project.SnippetsEnabled) | ||
d.Set("visibility_level", visibilityLevelToString(project.VisibilityLevel)) | ||
|
||
d.Set("id", project.ID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this, it's already done elsewhere There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @richardc it would be worth documenting then as I cannot see that in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, the docs are in the repo too. Probably also worth adding the missing example to |
||
d.Set("ssh_url_to_repo", project.SSHURLToRepo) | ||
d.Set("http_url_to_repo", project.HTTPURLToRepo) | ||
d.Set("web_url", project.WebURL) | ||
|
@@ -91,6 +100,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)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
|
||
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)), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed. The reason you cite for adding it is to help work with the
gitlab_project_hook
resource, but if you look at the acceptance tests for that code you'll see that the id is already exposed and used in its tests: https://github.com/hashicorp/terraform/blob/master/builtin/providers/gitlab/resource_gitlab_project_hook_test.go#L189 Its just an automatically exported attribute that all resources get.