Skip to content

Commit 94d2e4e

Browse files
committed
Make go naming consistent with project tag resource and datasource
1 parent 08f1322 commit 94d2e4e

File tree

6 files changed

+41
-40
lines changed

6 files changed

+41
-40
lines changed

docs/data-sources/project_tag.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
page_title: "gitlab_project_tag Data Source - terraform-provider-gitlab"
44
subcategory: ""
55
description: |-
6-
Provide details about a gitlab project tag
6+
The gitlab_project_tag data source allows details of a project tag to be retrieved by its name.
77
Upstream API : GitLab API docs https://docs.gitlab.com/ee/api/tags.html
88
---
99

1010
# gitlab_project_tag (Data Source)
1111

12-
Provide details about a gitlab project tag
13-
12+
The `gitlab_project_tag` data source allows details of a project tag to be retrieved by its name.
13+
1414
**Upstream API** : [GitLab API docs](https://docs.gitlab.com/ee/api/tags.html)
1515

1616
## Example Usage

docs/resources/project_tag.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
page_title: "gitlab_project_tag Resource - terraform-provider-gitlab"
44
subcategory: ""
55
description: |-
6-
This resource allows you to create and manage GitLab tags.
6+
The gitlab_project_tag resource allows to manage the lifecycle of a tag in a project.
77
Upstream API : GitLab API docs https://docs.gitlab.com/ee/api/tags.html
88
---
99

1010
# gitlab_project_tag (Resource)
1111

12-
This resource allows you to create and manage GitLab tags.
12+
The `gitlab_project_tag` resource allows to manage the lifecycle of a tag in a project.
1313

1414
**Upstream API** : [GitLab API docs](https://docs.gitlab.com/ee/api/tags.html)
1515

internal/provider/data_source_gitlab_project_tag.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111

1212
var _ = registerDataSource("gitlab_project_tag", func() *schema.Resource {
1313
return &schema.Resource{
14-
Description: `Provide details about a gitlab project tag
15-
14+
Description: `The ` + "`gitlab_project_tag`" + ` data source allows details of a project tag to be retrieved by its name.
15+
1616
**Upstream API** : [GitLab API docs](https://docs.gitlab.com/ee/api/tags.html)`,
1717

18-
ReadContext: dataSourceGitlabTagRead,
18+
ReadContext: dataSourceGitlabProjectTagRead,
1919
Schema: map[string]*schema.Schema{
2020
"name": {
2121
Description: "The name of a tag.",
@@ -60,7 +60,7 @@ var _ = registerDataSource("gitlab_project_tag", func() *schema.Resource {
6060
}
6161
})
6262

63-
func dataSourceGitlabTagRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
63+
func dataSourceGitlabProjectTagRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
6464
client := meta.(*gitlab.Client)
6565
name := d.Get("name").(string)
6666
project := d.Get("project").(string)

internal/provider/data_source_gitlab_project_tag_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1010
)
1111

12-
func TestAccDataGitlabTag_basic(t *testing.T) {
12+
func TestAccDataGitlabProjectTag_basic(t *testing.T) {
1313
testAccCheck(t)
1414
rInt := acctest.RandInt()
1515
project := testAccCreateProject(t)
@@ -19,16 +19,16 @@ func TestAccDataGitlabTag_basic(t *testing.T) {
1919
ProviderFactories: providerFactories,
2020
Steps: []resource.TestStep{
2121
{
22-
Config: testAccDataGitlabTag(rInt, project.PathWithNamespace),
22+
Config: testAccDataGitlabProjectTag(rInt, project.PathWithNamespace),
2323
Check: resource.ComposeTestCheckFunc(
24-
testAccDataSourceGitlabTag("gitlab_project_tag.foo", "data.gitlab_project_tag.foo"),
24+
testAccDataSourceGitlabProjectTag("gitlab_project_tag.foo", "data.gitlab_project_tag.foo"),
2525
),
2626
},
2727
},
2828
})
2929
}
3030

31-
func testAccDataSourceGitlabTag(src, n string) resource.TestCheckFunc {
31+
func testAccDataSourceGitlabProjectTag(src, n string) resource.TestCheckFunc {
3232
return func(s *terraform.State) error {
3333

3434
tag := s.RootModule().Resources[src]
@@ -57,17 +57,17 @@ func testAccDataSourceGitlabTag(src, n string) resource.TestCheckFunc {
5757
}
5858
}
5959

60-
func testAccDataGitlabTag(rInt int, project string) string {
60+
func testAccDataGitlabProjectTag(rInt int, project string) string {
6161
return fmt.Sprintf(`
6262
%s
6363
data "gitlab_project_tag" "foo" {
6464
name = "${gitlab_project_tag.foo.name}"
6565
project = "%s"
6666
}
67-
`, testAccDataGitlabTagSetup(rInt, project), project)
67+
`, testAccDataGitlabProjectTagSetup(rInt, project), project)
6868
}
6969

70-
func testAccDataGitlabTagSetup(rInt int, project string) string {
70+
func testAccDataGitlabProjectTagSetup(rInt int, project string) string {
7171
return fmt.Sprintf(`
7272
resource "gitlab_project_tag" "foo" {
7373
name = "tag-%[1]d"

internal/provider/resource_gitlab_project_tag.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111

1212
var _ = registerResource("gitlab_project_tag", func() *schema.Resource {
1313
return &schema.Resource{
14-
Description: `This resource allows you to create and manage GitLab tags.
14+
Description: `The ` + "`gitlab_project_tag`" + ` resource allows to manage the lifecycle of a tag in a project.
1515
1616
**Upstream API** : [GitLab API docs](https://docs.gitlab.com/ee/api/tags.html)`,
1717

18-
CreateContext: resourceGitlabTagCreate,
19-
ReadContext: resourceGitlabTagRead,
20-
DeleteContext: resourceGitlabTagDelete,
18+
CreateContext: resourceGitlabProjectTagCreate,
19+
ReadContext: resourceGitlabProjectTagRead,
20+
DeleteContext: resourceGitlabProjectTagDelete,
2121
Importer: &schema.ResourceImporter{
2222
StateContext: schema.ImportStatePassthroughContext,
2323
},
@@ -89,7 +89,7 @@ var releaseNoteSchema = &schema.Resource{
8989
},
9090
}
9191

92-
func resourceGitlabTagCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
92+
func resourceGitlabProjectTagCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
9393
client := meta.(*gitlab.Client)
9494
name := d.Get("name").(string)
9595
project := d.Get("project").(string)
@@ -107,10 +107,10 @@ func resourceGitlabTagCreate(ctx context.Context, d *schema.ResourceData, meta i
107107
}
108108
d.SetId(buildTwoPartID(&project, &name))
109109
d.Set("ref", ref)
110-
return resourceGitlabTagRead(ctx, d, meta)
110+
return resourceGitlabProjectTagRead(ctx, d, meta)
111111
}
112112

113-
func resourceGitlabTagRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
113+
func resourceGitlabProjectTagRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
114114
client := meta.(*gitlab.Client)
115115
project, name, err := parseTwoPartID(d.Id())
116116
if err != nil {
@@ -144,7 +144,7 @@ func resourceGitlabTagRead(ctx context.Context, d *schema.ResourceData, meta int
144144
return nil
145145
}
146146

147-
func resourceGitlabTagDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
147+
func resourceGitlabProjectTagDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
148148
client := meta.(*gitlab.Client)
149149
project, name, err := parseTwoPartID(d.Id())
150150
if err != nil {

internal/provider/resource_gitlab_project_tag_test.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package provider
33
import (
44
"errors"
55
"fmt"
6+
"testing"
7+
68
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
79
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
810
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
911
gitlab "github.com/xanzy/go-gitlab"
10-
"testing"
1112
)
1213

13-
func TestAccGitlabTag_basic(t *testing.T) {
14+
func TestAccGitlabProjectTag_basic(t *testing.T) {
1415
testAccCheck(t)
1516
var tag gitlab.Tag
1617
var tag2 gitlab.Tag
@@ -21,19 +22,19 @@ func TestAccGitlabTag_basic(t *testing.T) {
2122
resource.Test(t, resource.TestCase{
2223
PreCheck: func() { testAccPreCheck(t) },
2324
ProviderFactories: providerFactories,
24-
CheckDestroy: testAccCheckGitlabTagDestroy,
25+
CheckDestroy: testAccCheckGitlabProjectTagDestroy,
2526
Steps: []resource.TestStep{
2627
{
27-
Config: testAccGitlabTagConfig(rInt, rInt2, project.PathWithNamespace, branches[0].Name),
28+
Config: testAccGitlabProjectTagConfig(rInt, rInt2, project.PathWithNamespace, branches[0].Name),
2829
Check: resource.ComposeTestCheckFunc(
29-
testAccCheckGitlabTagExists("foo", &tag, rInt),
30-
testAccCheckGitlabTagExists("foo2", &tag2, rInt2),
31-
testAccCheckGitlabTagAttributes("foo", &tag, &testAccGitlabTagExpectedAttributes{
30+
testAccCheckGitlabProjectTagExists("foo", &tag, rInt),
31+
testAccCheckGitlabProjectTagExists("foo2", &tag2, rInt2),
32+
testAccCheckGitlabProjectTagAttributes("foo", &tag, &testAccGitlabProjectTagExpectedAttributes{
3233
Name: fmt.Sprintf("tag-%d", rInt),
3334
Message: "",
3435
Ref: "main",
3536
}),
36-
testAccCheckGitlabTagAttributes("foo2", &tag2, &testAccGitlabTagExpectedAttributes{
37+
testAccCheckGitlabProjectTagAttributes("foo2", &tag2, &testAccGitlabProjectTagExpectedAttributes{
3738
Name: fmt.Sprintf("tag-%d", rInt2),
3839
Message: fmt.Sprintf("tag-%d", rInt2),
3940
Ref: branches[0].Name,
@@ -49,10 +50,10 @@ func TestAccGitlabTag_basic(t *testing.T) {
4950
},
5051
// update properties in resource
5152
{
52-
Config: testAccGitlabTagConfig(rInt, rInt3, project.PathWithNamespace, branches[0].Name),
53+
Config: testAccGitlabProjectTagConfig(rInt, rInt3, project.PathWithNamespace, branches[0].Name),
5354
Check: resource.ComposeTestCheckFunc(
54-
testAccCheckGitlabTagExists("foo2", &tag2, rInt3),
55-
testAccCheckGitlabTagAttributes("foo2", &tag2, &testAccGitlabTagExpectedAttributes{
55+
testAccCheckGitlabProjectTagExists("foo2", &tag2, rInt3),
56+
testAccCheckGitlabProjectTagAttributes("foo2", &tag2, &testAccGitlabProjectTagExpectedAttributes{
5657
Name: fmt.Sprintf("tag-%d", rInt3),
5758
Message: fmt.Sprintf("tag-%d", rInt3),
5859
Ref: branches[0].Name,
@@ -63,7 +64,7 @@ func TestAccGitlabTag_basic(t *testing.T) {
6364
})
6465
}
6566

66-
func testAccCheckGitlabTagDestroy(s *terraform.State) error {
67+
func testAccCheckGitlabProjectTagDestroy(s *terraform.State) error {
6768
for _, rs := range s.RootModule().Resources {
6869
if rs.Type != "gitlab_project_tag" {
6970
continue
@@ -82,7 +83,7 @@ func testAccCheckGitlabTagDestroy(s *terraform.State) error {
8283
return nil
8384
}
8485

85-
func testAccCheckGitlabTagAttributes(n string, tag *gitlab.Tag, want *testAccGitlabTagExpectedAttributes) resource.TestCheckFunc {
86+
func testAccCheckGitlabProjectTagAttributes(n string, tag *gitlab.Tag, want *testAccGitlabProjectTagExpectedAttributes) resource.TestCheckFunc {
8687
return func(s *terraform.State) error {
8788
rs := s.RootModule().Resources[fmt.Sprintf("gitlab_project_tag.%s", n)]
8889
ref := rs.Primary.Attributes["ref"]
@@ -113,7 +114,7 @@ func testAccCheckGitlabTagAttributes(n string, tag *gitlab.Tag, want *testAccGit
113114
}
114115
}
115116

116-
func testAccCheckGitlabTagExists(n string, tag *gitlab.Tag, rInt int) resource.TestCheckFunc {
117+
func testAccCheckGitlabProjectTagExists(n string, tag *gitlab.Tag, rInt int) resource.TestCheckFunc {
117118
return func(s *terraform.State) error {
118119
rs, ok := s.RootModule().Resources[fmt.Sprintf("gitlab_project_tag.%s", n)]
119120
if !ok {
@@ -132,7 +133,7 @@ func testAccCheckGitlabTagExists(n string, tag *gitlab.Tag, rInt int) resource.T
132133
}
133134
}
134135

135-
func testAccGitlabTagConfig(rInt int, rInt2 int, project string, branch string) string {
136+
func testAccGitlabProjectTagConfig(rInt int, rInt2 int, project string, branch string) string {
136137
return fmt.Sprintf(`
137138
resource "gitlab_project_tag" "foo" {
138139
name = "tag-%[1]d"
@@ -148,7 +149,7 @@ func testAccGitlabTagConfig(rInt int, rInt2 int, project string, branch string)
148149
`, rInt, rInt2, project, branch)
149150
}
150151

151-
type testAccGitlabTagExpectedAttributes struct {
152+
type testAccGitlabProjectTagExpectedAttributes struct {
152153
Name string
153154
Message string
154155
Ref string

0 commit comments

Comments
 (0)