Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verify that all resources have Description & MarkdownDescription #55

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions internal/provider/data_source_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"
)

type branchDataSource struct{}
type BranchDataSource struct{}

var (
_ datasource.DataSource = (*branchDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*branchDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*branchDataSource)(nil)
_ datasource.DataSource = (*BranchDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*BranchDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*BranchDataSource)(nil)
)

type branchDataSourceModel struct {
Expand All @@ -35,14 +35,14 @@ type branchDataSourceModel struct {
}

func NewBranchDataSource() datasource.DataSource {
return &branchDataSource{}
return &BranchDataSource{}
}

func (d *branchDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
func (d *BranchDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_branch"
}

func (d *branchDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
func (d *BranchDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{
Description: "Fetches information about a specific branch of a Git repository.",
MarkdownDescription: "Fetches information about a specific branch of a Git repository.",
Expand Down Expand Up @@ -93,7 +93,7 @@ func (d *branchDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diag
}, nil
}

func (d *branchDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
func (d *BranchDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Read data source git_branch")

var inputs branchDataSourceModel
Expand Down
10 changes: 10 additions & 0 deletions internal/provider/data_source_branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@
package provider_test

import (
"context"
"fmt"
"github.com/go-git/go-git/v5/config"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/metio/terraform-provider-git/internal/provider"
"github.com/metio/terraform-provider-git/internal/testutils"
"os"
"regexp"
"testing"
)

func TestDataSourceGitBranch_GetSchema(t *testing.T) {
t.Parallel()
r := &provider.BranchDataSource{}
schema, _ := r.GetSchema(context.TODO())

testutils.VerifySchemaDescriptions(t, schema)
}

func TestDataSourceGitBranch(t *testing.T) {
t.Parallel()
directory, repository := testutils.CreateRepository(t)
Expand Down
16 changes: 8 additions & 8 deletions internal/provider/data_source_branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"
)

type branchesDataSource struct{}
type BranchesDataSource struct{}

var (
_ datasource.DataSource = (*branchesDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*branchesDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*branchesDataSource)(nil)
_ datasource.DataSource = (*BranchesDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*BranchesDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*BranchesDataSource)(nil)
)

type branchesDataSourceModel struct {
Expand All @@ -33,14 +33,14 @@ type branchesDataSourceModel struct {
}

func NewBranchesDataSource() datasource.DataSource {
return &branchesDataSource{}
return &BranchesDataSource{}
}

func (d *branchesDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
func (d *BranchesDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_branches"
}

func (d *branchesDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
func (d *BranchesDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{
Description: "Fetches all branches of a Git repository.",
MarkdownDescription: "Fetches all branches of a Git repository.",
Expand Down Expand Up @@ -89,7 +89,7 @@ func (d *branchesDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Di
}, nil
}

func (d *branchesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
func (d *BranchesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Read data source git_branches")

var inputs branchesDataSourceModel
Expand Down
10 changes: 10 additions & 0 deletions internal/provider/data_source_branches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
package provider_test

import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/metio/terraform-provider-git/internal/provider"
"github.com/metio/terraform-provider-git/internal/testutils"
"os"
"regexp"
"testing"
)

func TestDataSourceGitBranches_GetSchema(t *testing.T) {
t.Parallel()
r := &provider.BranchesDataSource{}
schema, _ := r.GetSchema(context.TODO())

testutils.VerifySchemaDescriptions(t, schema)
}

func TestDataSourceGitBranches(t *testing.T) {
t.Parallel()
directory, repository := testutils.CreateRepository(t)
Expand Down
16 changes: 8 additions & 8 deletions internal/provider/data_source_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"
)

type commitDataSource struct{}
type CommitDataSource struct{}

var (
_ datasource.DataSource = (*commitDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*commitDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*commitDataSource)(nil)
_ datasource.DataSource = (*CommitDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*CommitDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*CommitDataSource)(nil)
)

type commitDataSourceModel struct {
Expand All @@ -37,14 +37,14 @@ type commitDataSourceModel struct {
}

func NewCommitDataSource() datasource.DataSource {
return &commitDataSource{}
return &CommitDataSource{}
}

func (d *commitDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
func (d *CommitDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_commit"
}

func (d *commitDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
func (d *CommitDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{
Description: "Fetches information about a single commit.",
MarkdownDescription: "Fetches information about a single commit.",
Expand Down Expand Up @@ -159,7 +159,7 @@ func (d *commitDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diag
}, nil
}

func (d *commitDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
func (d *CommitDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Read data source git_commit")

var inputs commitDataSourceModel
Expand Down
10 changes: 10 additions & 0 deletions internal/provider/data_source_commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
package provider_test

import (
"context"
"fmt"
"github.com/go-git/go-git/v5"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/metio/terraform-provider-git/internal/provider"
"github.com/metio/terraform-provider-git/internal/testutils"
"os"
"testing"
)

func TestDataSourceGitCommit_GetSchema(t *testing.T) {
t.Parallel()
r := &provider.CommitDataSource{}
schema, _ := r.GetSchema(context.TODO())

testutils.VerifySchemaDescriptions(t, schema)
}

func TestDataSourceGitCommit(t *testing.T) {
t.Parallel()
directory, repository := testutils.CreateRepository(t)
Expand Down
16 changes: 8 additions & 8 deletions internal/provider/data_source_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (
"github.com/metio/terraform-provider-git/internal/modifiers"
)

type configDataSource struct{}
type ConfigDataSource struct{}

var (
_ datasource.DataSource = (*configDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*configDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*configDataSource)(nil)
_ datasource.DataSource = (*ConfigDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*ConfigDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*ConfigDataSource)(nil)
)

type configDataSourceModel struct {
Expand All @@ -37,14 +37,14 @@ type configDataSourceModel struct {
}

func NewConfigDataSource() datasource.DataSource {
return &configDataSource{}
return &ConfigDataSource{}
}

func (d *configDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
func (d *ConfigDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_config"
}

func (d *configDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
func (d *ConfigDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{
Description: "Reads the configuration of a Git repository.",
MarkdownDescription: "Reads the configuration of a Git repository.",
Expand Down Expand Up @@ -121,7 +121,7 @@ func (d *configDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diag
}, nil
}

func (d *configDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
func (d *ConfigDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Read data source git_config")

var inputs configDataSourceModel
Expand Down
10 changes: 10 additions & 0 deletions internal/provider/data_source_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
package provider_test

import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/metio/terraform-provider-git/internal/provider"
"github.com/metio/terraform-provider-git/internal/testutils"
"os"
"regexp"
"testing"
)

func TestDataSourceGitConfig_GetSchema(t *testing.T) {
t.Parallel()
r := &provider.ConfigDataSource{}
schema, _ := r.GetSchema(context.TODO())

testutils.VerifySchemaDescriptions(t, schema)
}

func TestDataSourceGitConfig(t *testing.T) {
t.Parallel()
directory, repository := testutils.CreateRepository(t)
Expand Down
16 changes: 8 additions & 8 deletions internal/provider/data_source_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
"github.com/metio/terraform-provider-git/internal/modifiers"
)

type logDataSource struct{}
type LogDataSource struct{}

var (
_ datasource.DataSource = (*logDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*logDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*logDataSource)(nil)
_ datasource.DataSource = (*LogDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*LogDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*LogDataSource)(nil)
)

type logDataSourceModel struct {
Expand All @@ -41,14 +41,14 @@ type logDataSourceModel struct {
}

func NewLogDataSource() datasource.DataSource {
return &logDataSource{}
return &LogDataSource{}
}

func (d *logDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
func (d *LogDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_log"
}

func (d *logDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
func (d *LogDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{
Description: "Fetches the commit log of a Git repository similar to 'git log'.",
MarkdownDescription: "Fetches the commit log of a Git repository similar to `git log`.",
Expand Down Expand Up @@ -157,7 +157,7 @@ func (d *logDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnos
}, nil
}

func (d *logDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
func (d *LogDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Read data source git_log")

var inputs logDataSourceModel
Expand Down
10 changes: 10 additions & 0 deletions internal/provider/data_source_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
package provider_test

import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/metio/terraform-provider-git/internal/provider"
"github.com/metio/terraform-provider-git/internal/testutils"
"os"
"regexp"
"testing"
)

func TestDataSourceGitLog_GetSchema(t *testing.T) {
t.Parallel()
r := &provider.LogDataSource{}
schema, _ := r.GetSchema(context.TODO())

testutils.VerifySchemaDescriptions(t, schema)
}

func TestDataSourceGitLog(t *testing.T) {
t.Parallel()
directory, repository := testutils.CreateRepository(t)
Expand Down
16 changes: 8 additions & 8 deletions internal/provider/data_source_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"
)

type remoteDataSource struct{}
type RemoteDataSource struct{}

var (
_ datasource.DataSource = (*remoteDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*remoteDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*remoteDataSource)(nil)
_ datasource.DataSource = (*RemoteDataSource)(nil)
_ datasource.DataSourceWithGetSchema = (*RemoteDataSource)(nil)
_ datasource.DataSourceWithMetadata = (*RemoteDataSource)(nil)
)

type remoteDataSourceModel struct {
Expand All @@ -31,14 +31,14 @@ type remoteDataSourceModel struct {
}

func NewRemoteDataSource() datasource.DataSource {
return &remoteDataSource{}
return &RemoteDataSource{}
}

func (d *remoteDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
func (d *RemoteDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_remote"
}

func (d *remoteDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
func (d *RemoteDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{
Description: "Reads information about a specific remote of a Git repository.",
MarkdownDescription: "Reads information about a specific remote of a Git repository.",
Expand Down Expand Up @@ -79,7 +79,7 @@ func (d *remoteDataSource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diag
}, nil
}

func (d *remoteDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
func (d *RemoteDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Read data source git_remote")

var inputs remoteDataSourceModel
Expand Down
Loading