Skip to content

Commit

Permalink
fix: user datasource naming
Browse files Browse the repository at this point in the history
  • Loading branch information
bosc0 committed Dec 31, 2024
1 parent 4df1a6a commit 74b1ab3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions internal/provider/data_source_user.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand All @@ -11,29 +14,29 @@ import (
"github.com/slack-go/slack"
)

var _ datasource.DataSource = &UserDataDataSource{}
var _ datasource.DataSource = &UserDataSource{}

func NewUserDataDataSource() datasource.DataSource {
return &UserDataDataSource{}
func NewUserDataSource() datasource.DataSource {
return &UserDataSource{}
}

type UserDataDataSource struct {
type UserDataSource struct {
client *slack.Client
}

type UserDataDataSourceModel struct {
type UserDataSourceModel struct {
UserID types.String `tfsdk:"user_id"`
Email types.String `tfsdk:"email"`
RealName types.String `tfsdk:"real_name"`
DisplayName types.String `tfsdk:"display_name"`
ID types.String `tfsdk:"id"`
}

func (d *UserDataDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
func (d *UserDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_user_data"
}

func (d *UserDataDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
func (d *UserDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: "Retrieve Slack user information.",
Attributes: map[string]schema.Attribute{
Expand Down Expand Up @@ -61,7 +64,7 @@ func (d *UserDataDataSource) Schema(ctx context.Context, req datasource.SchemaRe
}
}

func (d *UserDataDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
func (d *UserDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
if req.ProviderData == nil {
// https://stackoverflow.com/questions/78623763/terraform-provider-method-configure-not-getting-called
return
Expand All @@ -79,8 +82,8 @@ func (d *UserDataDataSource) Configure(ctx context.Context, req datasource.Confi
d.client = providerData.Client
}

func (d *UserDataDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var data UserDataDataSourceModel
func (d *UserDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var data UserDataSourceModel

resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (p *SlackProvider) Resources(ctx context.Context) []func() resource.Resourc

func (p *SlackProvider) DataSources(ctx context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
NewUserDataDataSource,
NewUserDataSource,
}
}

Expand Down

0 comments on commit 74b1ab3

Please sign in to comment.