Skip to content

Commit f818824

Browse files
authored
Merge pull request #815 from timofurrer/feature/align-to-tf-scaffold
Change provider structure to best practices from terraform-provider-scaffolding project
2 parents 08ca704 + 4c2c4f4 commit f818824

File tree

114 files changed

+893
-1043
lines changed

Some content is hidden

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

114 files changed

+893
-1043
lines changed

.github/labeler-pr-triage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ linter:
1616

1717
provider:
1818
- '.go-version'
19-
- 'gitlab/**/*'
19+
- 'internal/provider/**/*'
2020
- 'main.go'
2121

2222
resource:
23-
- 'gitlab/resource_*.go'
23+
- 'internal/provider/resource_*.go'
2424

2525
data-source:
26-
- 'gitlab/data_source_*.go'
26+
- 'internal/provider/data_source_*.go'
2727

2828
tests:
2929
- '**/*_test.go'

GNUmakefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ default: reviewable
33
reviewable: build fmt generate test ## Run before committing.
44

55
GOBIN = $(shell pwd)/bin
6+
PROVIDER_SRC_DIR := ./internal/provider
67

78
build: ## Build the provider binary.
89
go mod tidy
@@ -17,7 +18,7 @@ TESTARGS += -test.run $(RUN)
1718
endif
1819

1920
test: ## Run unit tests.
20-
go test $(TESTARGS) ./gitlab
21+
go test $(TESTARGS) $(PROVIDER_SRC_DIR)
2122

2223
TFPROVIDERLINTX_CHECKS = -XAT001=false -XR003=false -XS002=false
2324

@@ -68,7 +69,7 @@ testacc-down: ## Teardown a GitLab instance.
6869
docker-compose down
6970

7071
testacc: ## Run acceptance tests against a GitLab instance.
71-
TF_ACC=1 GITLAB_TOKEN=$(GITLAB_TOKEN) GITLAB_BASE_URL=$(GITLAB_BASE_URL) go test -v ./gitlab $(TESTARGS) -timeout 40m
72+
TF_ACC=1 GITLAB_TOKEN=$(GITLAB_TOKEN) GITLAB_BASE_URL=$(GITLAB_BASE_URL) go test -v $(PROVIDER_SRC_DIR) $(TESTARGS) -timeout 40m
7273

7374
# TOOLS
7475
# Tool dependencies are installed into a project-local /bin folder.

gitlab/provider.go

Lines changed: 0 additions & 152 deletions
This file was deleted.

gitlab/provider_test.go

Lines changed: 0 additions & 43 deletions
This file was deleted.

gitlab/access_level_helpers.go renamed to internal/provider/access_level_helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gitlab
1+
package provider
22

33
import (
44
"github.com/xanzy/go-gitlab"

gitlab/config.go renamed to internal/provider/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gitlab
1+
package provider
22

33
import (
44
"crypto/tls"

gitlab/custom_attribute_helper.go renamed to internal/provider/custom_attribute_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gitlab
1+
package provider
22

33
import (
44
"fmt"

gitlab/data_source_gitlab_group.go renamed to internal/provider/data_source_gitlab_group.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gitlab
1+
package provider
22

33
import (
44
"context"
@@ -10,7 +10,7 @@ import (
1010
"github.com/xanzy/go-gitlab"
1111
)
1212

13-
func dataSourceGitlabGroup() *schema.Resource {
13+
var _ = registerDataSource("gitlab_group", func() *schema.Resource {
1414
return &schema.Resource{
1515
Description: "Provide details about a specific group in the gitlab provider.\n\n" +
1616
"> **Note**: exactly one of group_id or full_path must be provided.",
@@ -93,7 +93,7 @@ func dataSourceGitlabGroup() *schema.Resource {
9393
},
9494
},
9595
}
96-
}
96+
})
9797

9898
func dataSourceGitlabGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
9999
client := meta.(*gitlab.Client)

gitlab/data_source_gitlab_group_membership.go renamed to internal/provider/data_source_gitlab_group_membership.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gitlab
1+
package provider
22

33
import (
44
"context"
@@ -13,7 +13,7 @@ import (
1313
"github.com/xanzy/go-gitlab"
1414
)
1515

16-
func dataSourceGitlabGroupMembership() *schema.Resource {
16+
var _ = registerDataSource("gitlab_group_membership", func() *schema.Resource {
1717
return &schema.Resource{
1818
Description: "Provide details about a list of group members in the gitlab provider. The results include id, username, name and more about the requested members.\n\n" +
1919
"> **Note**: exactly one of group_id or full_path must be provided.",
@@ -96,7 +96,7 @@ func dataSourceGitlabGroupMembership() *schema.Resource {
9696
},
9797
},
9898
}
99-
}
99+
})
100100

101101
func dataSourceGitlabGroupMembershipRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
102102
client := meta.(*gitlab.Client)

gitlab/data_source_gitlab_group_membership_test.go renamed to internal/provider/data_source_gitlab_group_membership_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gitlab
1+
package provider
22

33
import (
44
"fmt"
@@ -12,8 +12,8 @@ func TestAccDataSourceGitlabMembership_basic(t *testing.T) {
1212
rInt := acctest.RandInt()
1313

1414
resource.Test(t, resource.TestCase{
15-
PreCheck: func() { testAccPreCheck(t) },
16-
Providers: testAccProviders,
15+
PreCheck: func() { testAccPreCheck(t) },
16+
ProviderFactories: providerFactories,
1717
Steps: []resource.TestStep{
1818
// Create the group and one member
1919
{

0 commit comments

Comments
 (0)