Skip to content

Commit 41a4ddb

Browse files
committed
Refactor datasourceSchemaFromResourceSchema to allow more string parameters
1 parent 61400af commit 41a4ddb

6 files changed

+7
-7
lines changed

internal/provider/data_source_gitlab_project_issue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var _ = registerDataSource("gitlab_project_issue", func() *schema.Resource {
1515
**Upstream API**: [GitLab API docs](https://docs.gitlab.com/ee/api/issues.html)`,
1616

1717
ReadContext: dataSourceGitlabProjectIssueRead,
18-
Schema: datasourceSchemaFromResourceSchema(gitlabProjectIssueGetSchema(), "project", "iid"),
18+
Schema: datasourceSchemaFromResourceSchema(gitlabProjectIssueGetSchema(), []string{"project", "iid"}),
1919
}
2020
})
2121

internal/provider/data_source_gitlab_project_issues.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ var _ = registerDataSource("gitlab_project_issues", func() *schema.Resource {
206206
Type: schema.TypeList,
207207
Computed: true,
208208
Elem: &schema.Resource{
209-
Schema: datasourceSchemaFromResourceSchema(gitlabProjectIssueGetSchema()),
209+
Schema: datasourceSchemaFromResourceSchema(gitlabProjectIssueGetSchema(), nil),
210210
},
211211
},
212212
},

internal/provider/data_source_gitlab_project_tag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var _ = registerDataSource("gitlab_project_tag", func() *schema.Resource {
1717

1818
ReadContext: dataSourceGitlabProjectTagRead,
1919
Schema: constructSchema(
20-
datasourceSchemaFromResourceSchema(gitlabProjectTagGetSchema(), "name"),
20+
datasourceSchemaFromResourceSchema(gitlabProjectTagGetSchema(), []string{"name"}),
2121
map[string]*schema.Schema{
2222
"project": {
2323
Description: "The ID or URL-encoded path of the project owned by the authenticated user.",

internal/provider/data_source_gitlab_project_tags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var _ = registerDataSource("gitlab_project_tags", func() *schema.Resource {
4444
Type: schema.TypeList,
4545
Computed: true,
4646
Elem: &schema.Resource{
47-
Schema: datasourceSchemaFromResourceSchema(gitlabProjectTagGetSchema()),
47+
Schema: datasourceSchemaFromResourceSchema(gitlabProjectTagGetSchema(), nil),
4848
},
4949
},
5050
},

internal/provider/data_source_gitlab_repository_file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var _ = registerDataSource("gitlab_repository_file", func() *schema.Resource {
1717
**Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/repository_files.html)`,
1818

1919
ReadContext: dataSourceGitlabRepositoryFileRead,
20-
Schema: datasourceSchemaFromResourceSchema(gitlabRepositoryFileGetSchema(), "project", "file_path", "ref"),
20+
Schema: datasourceSchemaFromResourceSchema(gitlabRepositoryFileGetSchema(), []string{"project", "file_path", "ref"}),
2121
}
2222
})
2323

internal/provider/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ func attributeNamesFromSchema(schema map[string]*schema.Schema) []string {
346346
// - all attributes have ForceNew, Required = false
347347
// - Validation funcs and attributes (e.g. MaxItems) are not copied
348348
// Adapted from https://github.com/hashicorp/terraform-provider-google/blob/1a72f93a8dcf6f1e59d5f25aefcb6d794a116bf5/google/datasource_helpers.go#L13
349-
func datasourceSchemaFromResourceSchema(rs map[string]*schema.Schema, arguments ...string) map[string]*schema.Schema {
349+
func datasourceSchemaFromResourceSchema(rs map[string]*schema.Schema, arguments []string) map[string]*schema.Schema {
350350
ds := make(map[string]*schema.Schema, len(rs))
351351
for k, v := range rs {
352352
dv := &schema.Schema{
@@ -373,7 +373,7 @@ func datasourceSchemaFromResourceSchema(rs map[string]*schema.Schema, arguments
373373
if elem, ok := v.Elem.(*schema.Resource); ok {
374374
// handle the case where the Element is a sub-resource
375375
dv.Elem = &schema.Resource{
376-
Schema: datasourceSchemaFromResourceSchema(elem.Schema),
376+
Schema: datasourceSchemaFromResourceSchema(elem.Schema, nil),
377377
}
378378
} else {
379379
// handle simple primitive case

0 commit comments

Comments
 (0)