diff --git a/internal/provider/data_source_git_branch.go b/internal/provider/data_source_git_branch.go index 31d8c96..44ea36e 100644 --- a/internal/provider/data_source_git_branch.go +++ b/internal/provider/data_source_git_branch.go @@ -137,9 +137,9 @@ func (r *dataSourceGitBranch) Read(ctx context.Context, req tfsdk.ReadDataSource return } - state.Directory = types.String{Value: directory} - state.Id = types.String{Value: directory} - state.Branch = types.String{Value: branch.Name} + state.Directory = inputs.Directory + state.Id = inputs.Directory + state.Branch = inputs.Branch state.Remote = types.String{Value: branch.Remote} state.Rebase = types.String{Value: branch.Rebase} diff --git a/internal/provider/data_source_git_commit.go b/internal/provider/data_source_git_commit.go index 2fa704e..8e8e986 100644 --- a/internal/provider/data_source_git_commit.go +++ b/internal/provider/data_source_git_commit.go @@ -146,9 +146,9 @@ func (r *dataSourceGitCommit) Read(ctx context.Context, req tfsdk.ReadDataSource return } - state.Directory = types.String{Value: directory} - state.Id = types.String{Value: sha1} - state.SHA1 = types.String{Value: sha1} + state.Directory = inputs.Directory + state.Id = inputs.SHA1 + state.SHA1 = inputs.SHA1 commit, err := repository.CommitObject(plumbing.NewHash(sha1)) if err != nil { diff --git a/internal/provider/data_source_git_config.go b/internal/provider/data_source_git_config.go index 70f94b1..1b65e2d 100644 --- a/internal/provider/data_source_git_config.go +++ b/internal/provider/data_source_git_config.go @@ -147,9 +147,9 @@ func (r *dataSourceGitConfig) Read(ctx context.Context, req tfsdk.ReadDataSource "scope": scope, }) - state.Directory = types.String{Value: directory} - state.Id = types.String{Value: directory} - state.Scope = types.String{Value: scope} + state.Directory = inputs.Directory + state.Id = inputs.Directory + state.Scope = inputs.Scope state.UserName = types.String{Value: cfg.User.Name} state.UserEmail = types.String{Value: cfg.User.Email} state.AuthorName = types.String{Value: cfg.Author.Name} diff --git a/internal/provider/data_source_git_remotes.go b/internal/provider/data_source_git_remotes.go index 679c43f..088c9c1 100644 --- a/internal/provider/data_source_git_remotes.go +++ b/internal/provider/data_source_git_remotes.go @@ -115,8 +115,8 @@ func (r *dataSourceGitRemotes) Read(ctx context.Context, req tfsdk.ReadDataSourc } } - state.Directory = types.String{Value: directory} - state.Id = types.String{Value: directory} + state.Directory = inputs.Directory + state.Id = inputs.Directory state.Remotes = types.Map{ ElemType: types.ObjectType{ AttrTypes: remoteType, diff --git a/internal/provider/data_source_git_repository.go b/internal/provider/data_source_git_repository.go index b98829c..2467789 100644 --- a/internal/provider/data_source_git_repository.go +++ b/internal/provider/data_source_git_repository.go @@ -93,8 +93,8 @@ func (r *dataSourceGitRepository) Read(ctx context.Context, req tfsdk.ReadDataSo "head": head.Name().String(), }) - state.Directory = types.String{Value: directory} - state.Id = types.String{Value: directory} + state.Directory = inputs.Directory + state.Id = inputs.Directory state.Branch = types.String{Value: head.Name().Short()} diags = resp.State.Set(ctx, &state) diff --git a/internal/provider/data_source_git_status.go b/internal/provider/data_source_git_status.go index a096c80..2c15142 100644 --- a/internal/provider/data_source_git_status.go +++ b/internal/provider/data_source_git_status.go @@ -96,9 +96,9 @@ func (r *dataSourceGitStatus) Read(ctx context.Context, req tfsdk.ReadDataSource return } - state.Directory = types.String{Value: directory} - state.Id = types.String{Value: fileName} - state.File = types.String{Value: fileName} + state.Directory = inputs.Directory + state.Id = inputs.File + state.File = inputs.File worktree, err := repository.Worktree() if err == git.ErrIsBareRepository { diff --git a/internal/provider/data_source_git_statuses.go b/internal/provider/data_source_git_statuses.go index 6d96c33..794cce3 100644 --- a/internal/provider/data_source_git_statuses.go +++ b/internal/provider/data_source_git_statuses.go @@ -96,8 +96,8 @@ func (r *dataSourceGitStatuses) Read(ctx context.Context, req tfsdk.ReadDataSour return } - state.Directory = types.String{Value: directory} - state.Id = types.String{Value: directory} + state.Directory = inputs.Directory + state.Id = inputs.Directory statusType := map[string]attr.Type{ "staging": types.StringType, diff --git a/internal/provider/resource_git_init.go b/internal/provider/resource_git_init.go index 41df248..a147e94 100644 --- a/internal/provider/resource_git_init.go +++ b/internal/provider/resource_git_init.go @@ -85,6 +85,11 @@ func (r *resourceGitInit) Create(ctx context.Context, req tfsdk.CreateResourceRe return } + // NOTE: It seems default values are not working? + if inputs.Bare.IsNull() { + inputs.Bare = types.Bool{Value: false} + } + directory := inputs.Directory.Value bare := inputs.Bare.Value @@ -102,9 +107,9 @@ func (r *resourceGitInit) Create(ctx context.Context, req tfsdk.CreateResourceRe "bare": bare, }) - state.Directory = types.String{Value: directory} - state.Id = types.String{Value: directory} - state.Bare = types.Bool{Value: bare} + state.Directory = inputs.Directory + state.Id = inputs.Directory + state.Bare = inputs.Bare diags = resp.State.Set(ctx, &state) resp.Diagnostics.Append(diags...)