Skip to content

Commit 75b042b

Browse files
authored
Merge pull request #20 from roidelapluie/v4
Move to V4 API
2 parents 75d259c + 1b63c6e commit 75b042b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2750
-1782
lines changed

gitlab/resource_gitlab_group.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func resourceGitlabGroupCreate(d *schema.ResourceData, meta interface{}) error {
6666
}
6767

6868
if v, ok := d.GetOk("visibility_level"); ok {
69-
options.VisibilityLevel = stringToVisibilityLevel(v.(string))
69+
options.Visibility = stringToVisibilityLevel(v.(string))
7070
}
7171

7272
log.Printf("[DEBUG] create gitlab group %q", options.Name)
@@ -131,7 +131,7 @@ func resourceGitlabGroupUpdate(d *schema.ResourceData, meta interface{}) error {
131131
}
132132

133133
if d.HasChange("visibility_level") {
134-
options.VisibilityLevel = stringToVisibilityLevel(d.Get("visibility_level").(string))
134+
options.Visibility = stringToVisibilityLevel(d.Get("visibility_level").(string))
135135
}
136136

137137
log.Printf("[DEBUG] update gitlab group %s", d.Id())

gitlab/resource_gitlab_project.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func resourceGitlabProjectSetToState(d *schema.ResourceData, project *gitlab.Pro
8686
d.Set("merge_requests_enabled", project.MergeRequestsEnabled)
8787
d.Set("wiki_enabled", project.WikiEnabled)
8888
d.Set("snippets_enabled", project.SnippetsEnabled)
89-
d.Set("visibility_level", visibilityLevelToString(project.VisibilityLevel))
89+
d.Set("visibility_level", string(project.Visibility))
9090

9191
d.Set("ssh_url_to_repo", project.SSHURLToRepo)
9292
d.Set("http_url_to_repo", project.HTTPURLToRepo)
@@ -101,6 +101,7 @@ func resourceGitlabProjectCreate(d *schema.ResourceData, meta interface{}) error
101101
MergeRequestsEnabled: gitlab.Bool(d.Get("merge_requests_enabled").(bool)),
102102
WikiEnabled: gitlab.Bool(d.Get("wiki_enabled").(bool)),
103103
SnippetsEnabled: gitlab.Bool(d.Get("snippets_enabled").(bool)),
104+
Visibility: stringToVisibilityLevel(d.Get("visibility_level").(string)),
104105
}
105106

106107
if v, ok := d.GetOk("namespace_id"); ok {
@@ -111,10 +112,6 @@ func resourceGitlabProjectCreate(d *schema.ResourceData, meta interface{}) error
111112
options.Description = gitlab.String(v.(string))
112113
}
113114

114-
if v, ok := d.GetOk("visibility_level"); ok {
115-
options.VisibilityLevel = stringToVisibilityLevel(v.(string))
116-
}
117-
118115
log.Printf("[DEBUG] create gitlab project %q", options.Name)
119116

120117
project, _, err := client.Projects.CreateProject(options)
@@ -164,7 +161,7 @@ func resourceGitlabProjectUpdate(d *schema.ResourceData, meta interface{}) error
164161
}
165162

166163
if d.HasChange("visibility_level") {
167-
options.VisibilityLevel = stringToVisibilityLevel(d.Get("visibility_level").(string))
164+
options.Visibility = stringToVisibilityLevel(d.Get("visibility_level").(string))
168165
}
169166

170167
if d.HasChange("issues_enabled") {

gitlab/resource_gitlab_project_hook.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func resourceGitlabProjectHook() *schema.Resource {
5555
Optional: true,
5656
Default: false,
5757
},
58-
"build_events": {
58+
"job_events": {
5959
Type: schema.TypeBool,
6060
Optional: true,
6161
Default: false,
@@ -89,7 +89,7 @@ func resourceGitlabProjectHookCreate(d *schema.ResourceData, meta interface{}) e
8989
MergeRequestsEvents: gitlab.Bool(d.Get("merge_requests_events").(bool)),
9090
TagPushEvents: gitlab.Bool(d.Get("tag_push_events").(bool)),
9191
NoteEvents: gitlab.Bool(d.Get("note_events").(bool)),
92-
BuildEvents: gitlab.Bool(d.Get("build_events").(bool)),
92+
JobEvents: gitlab.Bool(d.Get("job_events").(bool)),
9393
PipelineEvents: gitlab.Bool(d.Get("pipeline_events").(bool)),
9494
WikiPageEvents: gitlab.Bool(d.Get("wiki_page_events").(bool)),
9595
EnableSSLVerification: gitlab.Bool(d.Get("enable_ssl_verification").(bool)),
@@ -137,7 +137,7 @@ func resourceGitlabProjectHookRead(d *schema.ResourceData, meta interface{}) err
137137
d.Set("merge_requests_events", hook.MergeRequestsEvents)
138138
d.Set("tag_push_events", hook.TagPushEvents)
139139
d.Set("note_events", hook.NoteEvents)
140-
d.Set("build_events", hook.BuildEvents)
140+
d.Set("job_events", hook.JobEvents)
141141
d.Set("pipeline_events", hook.PipelineEvents)
142142
d.Set("wiki_page_events", hook.WikiPageEvents)
143143
d.Set("enable_ssl_verification", hook.EnableSSLVerification)
@@ -158,7 +158,7 @@ func resourceGitlabProjectHookUpdate(d *schema.ResourceData, meta interface{}) e
158158
MergeRequestsEvents: gitlab.Bool(d.Get("merge_requests_events").(bool)),
159159
TagPushEvents: gitlab.Bool(d.Get("tag_push_events").(bool)),
160160
NoteEvents: gitlab.Bool(d.Get("note_events").(bool)),
161-
BuildEvents: gitlab.Bool(d.Get("build_events").(bool)),
161+
JobEvents: gitlab.Bool(d.Get("job_events").(bool)),
162162
PipelineEvents: gitlab.Bool(d.Get("pipeline_events").(bool)),
163163
WikiPageEvents: gitlab.Bool(d.Get("wiki_page_events").(bool)),
164164
EnableSSLVerification: gitlab.Bool(d.Get("enable_ssl_verification").(bool)),

gitlab/resource_gitlab_project_hook_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestAccGitlabProjectHook_basic(t *testing.T) {
4444
MergeRequestsEvents: true,
4545
TagPushEvents: true,
4646
NoteEvents: true,
47-
BuildEvents: true,
47+
JobEvents: true,
4848
PipelineEvents: true,
4949
WikiPageEvents: true,
5050
EnableSSLVerification: false,
@@ -100,7 +100,7 @@ type testAccGitlabProjectHookExpectedAttributes struct {
100100
MergeRequestsEvents bool
101101
TagPushEvents bool
102102
NoteEvents bool
103-
BuildEvents bool
103+
JobEvents bool
104104
PipelineEvents bool
105105
WikiPageEvents bool
106106
EnableSSLVerification bool
@@ -136,8 +136,8 @@ func testAccCheckGitlabProjectHookAttributes(hook *gitlab.ProjectHook, want *tes
136136
return fmt.Errorf("got note_events %t; want %t", hook.NoteEvents, want.NoteEvents)
137137
}
138138

139-
if hook.BuildEvents != want.BuildEvents {
140-
return fmt.Errorf("got build_events %t; want %t", hook.BuildEvents, want.BuildEvents)
139+
if hook.JobEvents != want.JobEvents {
140+
return fmt.Errorf("got job_events %t; want %t", hook.JobEvents, want.JobEvents)
141141
}
142142

143143
if hook.PipelineEvents != want.PipelineEvents {
@@ -212,7 +212,7 @@ resource "gitlab_project_hook" "foo" {
212212
merge_requests_events = true
213213
tag_push_events = true
214214
note_events = true
215-
build_events = true
215+
job_events = true
216216
pipeline_events = true
217217
wiki_page_events = true
218218
}

gitlab/resource_gitlab_project_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestAccGitlabProject_basic(t *testing.T) {
3131
MergeRequestsEnabled: true,
3232
WikiEnabled: true,
3333
SnippetsEnabled: true,
34-
VisibilityLevel: 20,
34+
Visibility: gitlab.PublicVisibility,
3535
}),
3636
),
3737
},
@@ -41,9 +41,9 @@ func TestAccGitlabProject_basic(t *testing.T) {
4141
Check: resource.ComposeTestCheckFunc(
4242
testAccCheckGitlabProjectExists("gitlab_project.foo", &project),
4343
testAccCheckGitlabProjectAttributes(&project, &testAccGitlabProjectExpectedAttributes{
44-
Name: fmt.Sprintf("foo-%d", rInt),
45-
Description: "Terraform acceptance tests!",
46-
VisibilityLevel: 20,
44+
Name: fmt.Sprintf("foo-%d", rInt),
45+
Description: "Terraform acceptance tests!",
46+
Visibility: gitlab.PublicVisibility,
4747
}),
4848
),
4949
},
@@ -59,7 +59,7 @@ func TestAccGitlabProject_basic(t *testing.T) {
5959
MergeRequestsEnabled: true,
6060
WikiEnabled: true,
6161
SnippetsEnabled: true,
62-
VisibilityLevel: 20,
62+
Visibility: gitlab.PublicVisibility,
6363
}),
6464
),
6565
},
@@ -97,7 +97,7 @@ type testAccGitlabProjectExpectedAttributes struct {
9797
MergeRequestsEnabled bool
9898
WikiEnabled bool
9999
SnippetsEnabled bool
100-
VisibilityLevel gitlab.VisibilityLevelValue
100+
Visibility gitlab.VisibilityValue
101101
}
102102

103103
func testAccCheckGitlabProjectAttributes(project *gitlab.Project, want *testAccGitlabProjectExpectedAttributes) resource.TestCheckFunc {
@@ -129,8 +129,8 @@ func testAccCheckGitlabProjectAttributes(project *gitlab.Project, want *testAccG
129129
return fmt.Errorf("got snippets_enabled %t; want %t", project.SnippetsEnabled, want.SnippetsEnabled)
130130
}
131131

132-
if project.VisibilityLevel != want.VisibilityLevel {
133-
return fmt.Errorf("got default branch %q; want %q", project.VisibilityLevel, want.VisibilityLevel)
132+
if project.Visibility != want.Visibility {
133+
return fmt.Errorf("got visibility %q; want %q", project.Visibility, want.Visibility)
134134
}
135135

136136
return nil

gitlab/util.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ func validateValueFunc(values []string) schema.SchemaValidateFunc {
2626
}
2727
}
2828

29-
func stringToVisibilityLevel(s string) *gitlab.VisibilityLevelValue {
30-
lookup := map[string]gitlab.VisibilityLevelValue{
29+
func stringToVisibilityLevel(s string) *gitlab.VisibilityValue {
30+
lookup := map[string]gitlab.VisibilityValue{
3131
"private": gitlab.PrivateVisibility,
3232
"internal": gitlab.InternalVisibility,
3333
"public": gitlab.PublicVisibility,
@@ -39,16 +39,3 @@ func stringToVisibilityLevel(s string) *gitlab.VisibilityLevelValue {
3939
}
4040
return &value
4141
}
42-
43-
func visibilityLevelToString(v gitlab.VisibilityLevelValue) *string {
44-
lookup := map[gitlab.VisibilityLevelValue]string{
45-
gitlab.PrivateVisibility: "private",
46-
gitlab.InternalVisibility: "internal",
47-
gitlab.PublicVisibility: "public",
48-
}
49-
value, ok := lookup[v]
50-
if !ok {
51-
return nil
52-
}
53-
return &value
54-
}

gitlab/util_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestGitlab_validation(t *testing.T) {
3939
func TestGitlab_visbilityHelpers(t *testing.T) {
4040
cases := []struct {
4141
String string
42-
Level gitlab.VisibilityLevelValue
42+
Level gitlab.VisibilityValue
4343
}{
4444
{
4545
String: "private",
@@ -57,8 +57,8 @@ func TestGitlab_visbilityHelpers(t *testing.T) {
5757
t.Fatalf("got %v expected %v", level, tc.Level)
5858
}
5959

60-
sv := visibilityLevelToString(tc.Level)
61-
if sv == nil || *sv != tc.String {
60+
sv := string(tc.Level)
61+
if sv == "" || sv != tc.String {
6262
t.Fatalf("got %v expected %v", sv, tc.String)
6363
}
6464
}

vendor/github.com/xanzy/go-gitlab/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/xanzy/go-gitlab/README.md

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/xanzy/go-gitlab/branches.go

Lines changed: 15 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)