Skip to content

Commit

Permalink
chore: add godot to golangci (#1263)
Browse files Browse the repository at this point in the history
* ci: add godot into golangci

* refactor: apply godot
  • Loading branch information
mnagaa authored Oct 10, 2022
1 parent 5337f3a commit 3323470
Show file tree
Hide file tree
Showing 106 changed files with 698 additions and 697 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ run:
- whitespace
- unparam
- scopelint
- godot
4 changes: 2 additions & 2 deletions pkg/datasources/current_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ var currentAccountSchema = map[string]*schema.Schema{
},
}

// CurrentAccount the Snowflake current account resource
// CurrentAccount the Snowflake current account resource.
func CurrentAccount() *schema.Resource {
return &schema.Resource{
Read: ReadCurrentAccount,
Schema: currentAccountSchema,
}
}

// ReadCurrentAccount read the current snowflake account information
// ReadCurrentAccount read the current snowflake account information.
func ReadCurrentAccount(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
acc, err := snowflake.ReadCurrentAccount(db)
Expand Down
4 changes: 2 additions & 2 deletions pkg/datasources/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ var databaseSchema = map[string]*schema.Schema{
},
}

// Database the Snowflake Database resource
// Database the Snowflake Database resource.
func Database() *schema.Resource {
return &schema.Resource{
Read: ReadDatabase,
Schema: databaseSchema,
}
}

// ReadDatabase read the database meta-data information
// ReadDatabase read the database meta-data information.
func ReadDatabase(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
dbx := sqlx.NewDb(db, "snowflake")
Expand Down
4 changes: 2 additions & 2 deletions pkg/datasources/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ var databasesSchema = map[string]*schema.Schema{
},
}

// Databases the Snowflake current account resource
// Databases the Snowflake current account resource.
func Databases() *schema.Resource {
return &schema.Resource{
Read: ReadDatabases,
Schema: databasesSchema,
}
}

// ReadDatabases read the current snowflake account information
// ReadDatabases read the current snowflake account information.
func ReadDatabases(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
dbx := sqlx.NewDb(db, "snowflake")
Expand Down
4 changes: 2 additions & 2 deletions pkg/datasources/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var roleSchema = map[string]*schema.Schema{
},
}

// Role Snowflake Role resource
// Role Snowflake Role resource.
func Role() *schema.Resource {
return &schema.Resource{
Read: ReadRole,
Expand All @@ -33,7 +33,7 @@ func Role() *schema.Resource {
}
}

// ReadRole Reads the database metadata information
// ReadRole Reads the database metadata information.
func ReadRole(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
roleName := d.Get("name").(string)
Expand Down
2 changes: 1 addition & 1 deletion pkg/datasources/system_generate_scim_access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func SystemGenerateSCIMAccessToken() *schema.Resource {
}
}

// ReadSystemGetAWSSNSIAMPolicy implements schema.ReadFunc
// ReadSystemGetAWSSNSIAMPolicy implements schema.ReadFunc.
func ReadSystemGenerateSCIMAccessToken(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
integrationName := d.Get("integration_name").(string)
Expand Down
2 changes: 1 addition & 1 deletion pkg/datasources/system_get_aws_sns_iam_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func SystemGetAWSSNSIAMPolicy() *schema.Resource {
}
}

// ReadSystemGetAWSSNSIAMPolicy implements schema.ReadFunc
// ReadSystemGetAWSSNSIAMPolicy implements schema.ReadFunc.
func ReadSystemGetAWSSNSIAMPolicy(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
awsSNSTopicArn := d.Get("aws_sns_topic_arn").(string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

// FIXME refactor to testhelpers
// FIXME refactor to testhelpers.
func providers() map[string]*schema.Provider {
p := provider.Provider()
return map[string]*schema.Provider{
Expand Down
2 changes: 1 addition & 1 deletion pkg/datasources/system_get_privatelink_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func SystemGetPrivateLinkConfig() *schema.Resource {
}
}

// ReadSystemGetPrivateLinkConfig implements schema.ReadFunc
// ReadSystemGetPrivateLinkConfig implements schema.ReadFunc.
func ReadSystemGetPrivateLinkConfig(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)

Expand Down
2 changes: 1 addition & 1 deletion pkg/datasources/system_get_snowflake_platform_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func SystemGetSnowflakePlatformInfo() *schema.Resource {
}
}

// ReadSystemGetSnowflakePlatformInfo implements schema.ReadFunc
// ReadSystemGetSnowflakePlatformInfo implements schema.ReadFunc.
func ReadSystemGetSnowflakePlatformInfo(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
sel := snowflake.SystemGetSnowflakePlatformInfoQuery()
Expand Down
6 changes: 3 additions & 3 deletions pkg/helpers/list_to_string_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// ToDo: We can merge these two functions together and also add more functions here with similar functionality

// This function converts list of string into snowflake formated string like 'ele1', 'ele2'
// This function converts list of string into snowflake formated string like 'ele1', 'ele2'.
func ListToSnowflakeString(list []string) string {
for index, element := range list {
list[index] = fmt.Sprintf(`'%v'`, strings.ReplaceAll(element, "'", "\\'"))
Expand All @@ -17,7 +17,7 @@ func ListToSnowflakeString(list []string) string {
return fmt.Sprintf("%v", strings.Join(list, ", "))
}

// IpListToString formats a list of IPs into a Snowflake-DDL friendly string, e.g. ('192.168.1.0', '192.168.1.100')
// IpListToString formats a list of IPs into a Snowflake-DDL friendly string, e.g. ('192.168.1.0', '192.168.1.100').
func IpListToSnowflakeString(ips []string) string {
for index, element := range ips {
ips[index] = fmt.Sprintf(`'%v'`, element)
Expand All @@ -26,7 +26,7 @@ func IpListToSnowflakeString(ips []string) string {
return fmt.Sprintf("(%v)", strings.Join(ips, ", "))
}

// ListContentToString strips list elements of double quotes or brackets
// ListContentToString strips list elements of double quotes or brackets.
func ListContentToString(listString string) string {
re := regexp.MustCompile(`[\"\[\]]`)
return re.ReplaceAllString(listString, "")
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources"
)

// Provider is a provider
// Provider is a provider.
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) {
return f(req), nil
}

// NewTestClient returns *http.Client with Transport replaced to avoid making real calls
// NewTestClient returns *http.Client with Transport replaced to avoid making real calls.
func NewTestClient(fn RoundTripFunc) *http.Client {
return &http.Client{
Transport: RoundTripFunc(fn),
Expand Down
10 changes: 5 additions & 5 deletions pkg/resources/account_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var accountGrantSchema = map[string]*schema.Schema{
},
}

// AccountGrant returns a pointer to the resource representing an account grant
// AccountGrant returns a pointer to the resource representing an account grant.
func AccountGrant() *TerraformGrantResource {
return &TerraformGrantResource{
Resource: &schema.Resource{
Expand All @@ -79,7 +79,7 @@ func AccountGrant() *TerraformGrantResource {
}
}

// CreateAccountGrant implements schema.CreateFunc
// CreateAccountGrant implements schema.CreateFunc.
func CreateAccountGrant(d *schema.ResourceData, meta interface{}) error {
priv := d.Get("privilege").(string)
grantOption := d.Get("with_grant_option").(bool)
Expand Down Expand Up @@ -107,7 +107,7 @@ func CreateAccountGrant(d *schema.ResourceData, meta interface{}) error {
return ReadAccountGrant(d, meta)
}

// ReadAccountGrant implements schema.ReadFunc
// ReadAccountGrant implements schema.ReadFunc.
func ReadAccountGrant(d *schema.ResourceData, meta interface{}) error {
grantID, err := grantIDFromString(d.Id())
if err != nil {
Expand All @@ -127,14 +127,14 @@ func ReadAccountGrant(d *schema.ResourceData, meta interface{}) error {
return readGenericGrant(d, meta, accountGrantSchema, builder, false, validAccountPrivileges)
}

// DeleteAccountGrant implements schema.DeleteFunc
// DeleteAccountGrant implements schema.DeleteFunc.
func DeleteAccountGrant(d *schema.ResourceData, meta interface{}) error {
builder := snowflake.AccountGrant()

return deleteGenericGrant(d, meta, builder)
}

// UpdateAccountGrant implements schema.UpdateFunc
// UpdateAccountGrant implements schema.UpdateFunc.
func UpdateAccountGrant(d *schema.ResourceData, meta interface{}) error {
// for now the only thing we can update is roles.
// if nothing changed, nothing to update and we're done.
Expand Down
10 changes: 5 additions & 5 deletions pkg/resources/api_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var apiIntegrationSchema = map[string]*schema.Schema{
},
}

// APIIntegration returns a pointer to the resource representing an api integration
// APIIntegration returns a pointer to the resource representing an api integration.
func APIIntegration() *schema.Resource {
return &schema.Resource{
Create: CreateAPIIntegration,
Expand All @@ -105,7 +105,7 @@ func APIIntegration() *schema.Resource {
}
}

// CreateAPIIntegration implements schema.CreateFunc
// CreateAPIIntegration implements schema.CreateFunc.
func CreateAPIIntegration(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
name := d.Get("name").(string)
Expand Down Expand Up @@ -138,7 +138,7 @@ func CreateAPIIntegration(d *schema.ResourceData, meta interface{}) error {
return ReadAPIIntegration(d, meta)
}

// ReadAPIIntegration implements schema.ReadFunc
// ReadAPIIntegration implements schema.ReadFunc.
func ReadAPIIntegration(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
id := d.Id()
Expand Down Expand Up @@ -231,7 +231,7 @@ func ReadAPIIntegration(d *schema.ResourceData, meta interface{}) error {
return err
}

// UpdateAPIIntegration implements schema.UpdateFunc
// UpdateAPIIntegration implements schema.UpdateFunc.
func UpdateAPIIntegration(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
id := d.Id()
Expand Down Expand Up @@ -294,7 +294,7 @@ func UpdateAPIIntegration(d *schema.ResourceData, meta interface{}) error {
return ReadAPIIntegration(d, meta)
}

// DeleteAPIIntegration implements schema.DeleteFunc
// DeleteAPIIntegration implements schema.DeleteFunc.
func DeleteAPIIntegration(d *schema.ResourceData, meta interface{}) error {
return DeleteResource("", snowflake.ApiIntegration)(d, meta)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var databaseSchema = map[string]*schema.Schema{
"tag": tagReferenceSchema,
}

// Database returns a pointer to the resource representing a database
// Database returns a pointer to the resource representing a database.
func Database() *schema.Resource {
return &schema.Resource{
Create: CreateDatabase,
Expand Down Expand Up @@ -112,7 +112,7 @@ func createDatabase(d *schema.ResourceData, builder *snowflake.DatabaseBuilder,
return ReadDatabase(d, meta)
}

// CreateDatabase implements schema.CreateFunc
// CreateDatabase implements schema.CreateFunc.
func CreateDatabase(d *schema.ResourceData, meta interface{}) error {
// TODO: Migrate database from share and from replica to iterative approach
if _, ok := d.GetOk("from_share"); ok {
Expand Down
10 changes: 5 additions & 5 deletions pkg/resources/database_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var databaseGrantSchema = map[string]*schema.Schema{
},
}

// DatabaseGrant returns a pointer to the resource representing a database grant
// DatabaseGrant returns a pointer to the resource representing a database grant.
func DatabaseGrant() *TerraformGrantResource {
return &TerraformGrantResource{
Resource: &schema.Resource{
Expand All @@ -77,7 +77,7 @@ func DatabaseGrant() *TerraformGrantResource {
}
}

// CreateDatabaseGrant implements schema.CreateFunc
// CreateDatabaseGrant implements schema.CreateFunc.
func CreateDatabaseGrant(d *schema.ResourceData, meta interface{}) error {
dbName := d.Get("database_name").(string)
builder := snowflake.DatabaseGrant(dbName)
Expand Down Expand Up @@ -105,7 +105,7 @@ func CreateDatabaseGrant(d *schema.ResourceData, meta interface{}) error {
return ReadDatabaseGrant(d, meta)
}

// ReadDatabaseGrant implements schema.ReadFunc
// ReadDatabaseGrant implements schema.ReadFunc.
func ReadDatabaseGrant(d *schema.ResourceData, meta interface{}) error {
grantID, err := grantIDFromString(d.Id())
if err != nil {
Expand Down Expand Up @@ -134,15 +134,15 @@ func ReadDatabaseGrant(d *schema.ResourceData, meta interface{}) error {
return readGenericGrant(d, meta, databaseGrantSchema, builder, false, validDatabasePrivileges)
}

// DeleteDatabaseGrant implements schema.DeleteFunc
// DeleteDatabaseGrant implements schema.DeleteFunc.
func DeleteDatabaseGrant(d *schema.ResourceData, meta interface{}) error {
dbName := d.Get("database_name").(string)
builder := snowflake.DatabaseGrant(dbName)

return deleteGenericGrant(d, meta, builder)
}

// UpdateDatabaseGrant implements schema.UpdateFunc
// UpdateDatabaseGrant implements schema.UpdateFunc.
func UpdateDatabaseGrant(d *schema.ResourceData, meta interface{}) error {
// for now the only thing we can update are roles or shares
// if nothing changed, nothing to update and we're done
Expand Down
8 changes: 4 additions & 4 deletions pkg/resources/external_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ var externalFunctionSchema = map[string]*schema.Schema{
},
}

// ExternalFunction returns a pointer to the resource representing an external function
// ExternalFunction returns a pointer to the resource representing an external function.
func ExternalFunction() *schema.Resource {
return &schema.Resource{
Create: CreateExternalFunction,
Expand Down Expand Up @@ -227,7 +227,7 @@ func externalFunctionIDFromString(stringID string) (*externalFunctionID, error)
}, nil
}

// CreateExternalFunction implements schema.CreateFunc
// CreateExternalFunction implements schema.CreateFunc.
func CreateExternalFunction(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
database := d.Get("database").(string)
Expand Down Expand Up @@ -324,7 +324,7 @@ func CreateExternalFunction(d *schema.ResourceData, meta interface{}) error {
return ReadExternalFunction(d, meta)
}

// ReadExternalFunction implements schema.ReadFunc
// ReadExternalFunction implements schema.ReadFunc.
func ReadExternalFunction(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
externalFunctionID, err := externalFunctionIDFromString(d.Id())
Expand Down Expand Up @@ -495,7 +495,7 @@ func ReadExternalFunction(d *schema.ResourceData, meta interface{}) error {
return nil
}

// DeleteExternalFunction implements schema.DeleteFunc
// DeleteExternalFunction implements schema.DeleteFunc.
func DeleteExternalFunction(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
externalFunctionID, err := externalFunctionIDFromString(d.Id())
Expand Down
10 changes: 5 additions & 5 deletions pkg/resources/external_oauth_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var oauthExternalIntegrationSchema = map[string]*schema.Schema{
},
}

// ExternalOauthIntegration returns a pointer to the resource representing a network policy
// ExternalOauthIntegration returns a pointer to the resource representing a network policy.
func ExternalOauthIntegration() *schema.Resource {
return &schema.Resource{
Create: CreateExternalOauthIntegration,
Expand All @@ -145,7 +145,7 @@ func ExternalOauthIntegration() *schema.Resource {
}
}

// CreateExternalOauthIntegration implements schema.CreateFunc
// CreateExternalOauthIntegration implements schema.CreateFunc.
func CreateExternalOauthIntegration(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
name := d.Get("name").(string)
Expand Down Expand Up @@ -199,7 +199,7 @@ func CreateExternalOauthIntegration(d *schema.ResourceData, meta interface{}) er
return ReadExternalOauthIntegration(d, meta)
}

// ReadExternalOauthIntegration implements schema.ReadFunc
// ReadExternalOauthIntegration implements schema.ReadFunc.
func ReadExternalOauthIntegration(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
id := d.Id()
Expand Down Expand Up @@ -336,7 +336,7 @@ func ReadExternalOauthIntegration(d *schema.ResourceData, meta interface{}) erro
return err
}

// UpdateExternalOauthIntegration implements schema.UpdateFunc
// UpdateExternalOauthIntegration implements schema.UpdateFunc.
func UpdateExternalOauthIntegration(d *schema.ResourceData, meta interface{}) error {
db := meta.(*sql.DB)
id := d.Id()
Expand Down Expand Up @@ -411,7 +411,7 @@ func UpdateExternalOauthIntegration(d *schema.ResourceData, meta interface{}) er
return ReadExternalOauthIntegration(d, meta)
}

// DeleteExternalOauthIntegration implements schema.DeleteFunc
// DeleteExternalOauthIntegration implements schema.DeleteFunc.
func DeleteExternalOauthIntegration(d *schema.ResourceData, meta interface{}) error {
return DeleteResource("", snowflake.ExternalOauthIntegration)(d, meta)
}
Loading

0 comments on commit 3323470

Please sign in to comment.