-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Conversation
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 hashicorp#14471
I am not proficient in Go enough to write tests to cover new functionality though. |
"id": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
}, |
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.
@@ -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 comment
The 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 comment
The 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 gitlab_project
Attributes Reference
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.
Sure, the docs are in the repo too. Probably also worth adding the missing example to gitlab_project_hooks
too, so the next user doesn't think that "${gitlab_project.foo.id}"
isn't usable already.
This adds a gitlab_group resource. This combined with hashicorp#14483 should allow you to create projects in a group (untested) The implementation of this is a little ugly as go-gitlab doesn't have a function already present for EditGroup, so we hack it into being as part of the implementation of resourceGitlabGroupUpdate
Cherry-picking this over to my gitlab_group branch (resulting frankenbranch at https://github.com/richardc/terraform/tree/feature/add_gitlab_group_plus_cherry) does result in the ability to create a project in a group with as simply as this:
👍 though it will need docs and tests. |
@@ -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)), |
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.
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))
}
Spoke too soon, it breaks the case where a namespace_id isn't provided as you're not handling the optional nature correctly. Notes on how to fix it on the line. |
Fixed
--
Łukasz Niemier
lukasz@niemier.pl
… Wiadomość napisana przez Richard Clamp ***@***.***> w dniu 15.05.2017, o godz. 14:09:
Spoke too soon, it breaks the case where a namespace_id isn't provided as you're not handling the optional nature correctly. Notes on how to fix it on the line.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#14483 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AARzN8atig8GPoMrv4x5dwgAp_6fa-K5ks5r6EBwgaJpZM4Na2hq>.
|
This adds a gitlab_group resource. This combined with hashicorp#14483 will allow you to create projects in a group. The implementation of this is a little ugly as go-gitlab doesn't have a function already present for EditGroup, so we hack it into being as part of the implementation of resourceGitlabGroupUpdate
This adds a gitlab_group resource. This combined with hashicorp#14483 will allow you to create projects in a group. The implementation of this is a little ugly as go-gitlab doesn't have a function already present for EditGroup, so we hack it into being as part of the implementation of resourceGitlabGroupUpdate
This adds a gitlab_group resource. This combined with hashicorp#14483 will allow you to create projects in a group.
* vendor: Update go-gitlab to master@e6c11e Update go-gitlab to master@e6c11e. This brings in UpdateGroup in addition to fuller management of other attributes. * provider/gitlab: Add `gitlab_group` resource This adds a gitlab_group resource. This combined with #14483 will allow you to create projects in a group.
Hi @hauleth Thanks for the work here and thanks @richardc for the review. I merged #14490 first and now the tests pass as expected:
One thing to note - this new param hasn't had any documentation included. Please can you follow up with that? Thanks Paul |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This commit also introduce
id
comouted value which is numeric valueused by GitLab to iteract with repository. This should simplify use of
gitlab_project_hook
usage and would allow to introduce other resourcesas described in #14471