Skip to content

Commit

Permalink
fix: log fmt (#1192)
Browse files Browse the repository at this point in the history
  • Loading branch information
sivchari authored Aug 31, 2022
1 parent dd72c8b commit 0f2e2db
Show file tree
Hide file tree
Showing 30 changed files with 45 additions and 46 deletions.
4 changes: 2 additions & 2 deletions pkg/datasources/current_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func ReadCurrentAccount(d *schema.ResourceData, meta interface{}) error {
acc, err := snowflake.ReadCurrentAccount(db)

if err != nil {
log.Printf("[DEBUG] current_account failed to decode")
log.Println("[DEBUG] current_account failed to decode")
d.SetId("")
return nil
}
Expand All @@ -60,7 +60,7 @@ func ReadCurrentAccount(d *schema.ResourceData, meta interface{}) error {
url, err := acc.AccountURL()

if err != nil {
log.Printf("[DEBUG] generating snowflake url failed")
log.Println("[DEBUG] generating snowflake url failed")
d.SetId("")
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/datasources/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ func ReadDatabase(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] database: %v", d.Get("name"))
dbData, err := snowflake.ListDatabase(dbx, d.Get("name").(string))
if err != nil {
log.Printf("[DEBUG] list database failed to decode")
log.Println("[DEBUG] list database failed to decode")
d.SetId("")
return nil
}
if dbData == nil || !dbData.DBName.Valid {
log.Printf("[DEBUG] database not found")
log.Println("[DEBUG] database not found")
d.SetId("")
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/datasources/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func ReadDatabases(d *schema.ResourceData, meta interface{}) error {
dbx := sqlx.NewDb(db, "snowflake")
dbs, err := snowflake.ListDatabases(dbx)
if err != nil {
log.Printf("[DEBUG] list databases failed to decode")
log.Println("[DEBUG] list databases failed to decode")
d.SetId("")
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/datasources/system_get_privatelink_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ func ReadSystemGetPrivateLinkConfig(d *schema.ResourceData, meta interface{}) er

if err == sql.ErrNoRows {
// If not found, mark resource to be removed from statefile during apply or refresh
log.Print("[DEBUG] system_get_privatelink_config not found")
log.Println("[DEBUG] system_get_privatelink_config not found")
d.SetId("")
return nil
}

config, err := rawConfig.GetStructuredConfig()
if err != nil {
log.Printf("[DEBUG] system_get_privatelink_config failed to decode")
log.Println("[DEBUG] system_get_privatelink_config failed to decode")
d.SetId("")
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/datasources/system_get_snowflake_platform_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func ReadSystemGetSnowflakePlatformInfo(d *schema.ResourceData, meta interface{}
if err != nil {
// If not found, mark resource to be removed from statefile during apply or refresh
d.SetId("")
log.Printf("[DEBUG] current_account failed to decode")
log.Println("[DEBUG] current_account failed to decode")
return errors.Wrap(err, "error current_account")
}

Expand All @@ -51,13 +51,13 @@ func ReadSystemGetSnowflakePlatformInfo(d *schema.ResourceData, meta interface{}
rawInfo, err := snowflake.ScanSnowflakePlatformInfo(row)
if err == sql.ErrNoRows {
// If not found, mark resource to be removed from statefile during apply or refresh
log.Print("[DEBUG] system_get_snowflake_platform_info not found")
log.Println("[DEBUG] system_get_snowflake_platform_info not found")
return errors.Wrap(err, "error system_get_snowflake_platform_info")
}

info, err := rawInfo.GetStructuredConfig()
if err != nil {
log.Printf("[DEBUG] system_get_snowflake_platform_info failed to decode")
log.Println("[DEBUG] system_get_snowflake_platform_info failed to decode")
d.SetId("")
return errors.Wrap(err, "error system_get_snowflake_platform_info")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/managed_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func CreateManagedAccount(d *schema.ResourceData, meta interface{}) error {
// some time to appear. This is currently implemented as a sleep. @TODO actually
// wait until the locator is generated.
func initialReadManagedAccount(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] sleeping to give the locator a chance to be generated")
log.Println("[INFO] sleeping to give the locator a chance to be generated")
//lintignore:R018
time.Sleep(10 * time.Second)
return ReadManagedAccount(d, meta)
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func UpdateResource(

}
if d.HasChange("tag") {
log.Printf("[DEBUG] updating tags")
log.Println("[DEBUG] updating tags")
v := d.Get("tag")
tags := getTags(v)
qb.SetTags(tags.toSnowflakeTagValues())
Expand All @@ -122,7 +122,7 @@ func UpdateResource(
return errors.Wrapf(err, "error altering %s", t)
}
}
log.Printf("[DEBUG] performing read")
log.Println("[DEBUG] performing read")
return read(d, meta)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/tag_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func CreateTagAssociation(d *schema.ResourceData, meta interface{}) error {

skipValidate := d.Get("skip_validation").(bool)
if !skipValidate {
log.Printf("[DEBUG] validating tag creation")
log.Println("[DEBUG] validating tag creation")

err = resource.RetryContext(context.Background(), d.Timeout(schema.TimeoutCreate)-time.Minute, func() *resource.RetryError {

Expand Down Expand Up @@ -135,7 +135,7 @@ func ReadTagAssociation(d *schema.ResourceData, meta interface{}) error {
tagValue := d.Get("tag_value").(string)
skipValidate := d.Get("skip_validation").(bool)
if skipValidate {
log.Printf("[DEBUG] skipping read for tag association that has skip_validation enabled")
log.Println("[DEBUG] skipping read for tag association that has skip_validation enabled")
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/snowflake/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func ListDatabases(sdb *sqlx.DB) ([]database, error) {
dbs := []database{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no databases found")
log.Println("[DEBUG] no databases found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand All @@ -297,7 +297,7 @@ func ListDatabase(sdb *sqlx.DB, databaseName string) (*database, error) {
dbs := []database{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows || len(dbs) == 0 {
log.Printf("[DEBUG] no databases found")
log.Println("[DEBUG] no databases found")
return nil, nil
}
db := &database{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/external_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func ListExternalFunctions(databaseName string, schemaName string, db *sql.DB) (
dbs := []externalFunction{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no external functions found")
log.Println("[DEBUG] no external functions found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/external_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func ListExternalTables(databaseName string, schemaName string, db *sql.DB) ([]e
dbs := []externalTable{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no external tables found")
log.Println("[DEBUG] no external tables found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/file_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ func ListFileFormats(databaseName string, schemaName string, db *sql.DB) ([]file
dbs := []fileFormatShow{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no file formats found")
log.Println("[DEBUG] no file formats found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func ListFunctions(databaseName string, schemaName string, db *sql.DB) ([]functi
dbs := []function{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no functions found")
log.Println("[DEBUG] no functions found")
return nil, nil
}
return dbs, pe.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
4 changes: 2 additions & 2 deletions pkg/snowflake/masking_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (mpb *MaskingPolicyBuilder) WithReturnDataType(dataType string) *MaskingPol
//
// Supported DDL operations are:
// - CREATE MASKING POLICY
// - ALTER MASKING POLICY
// - ALTER MASKING POLICY
// - DROP MASKING POLICY
// - SHOW MASKING POLICIES
// - DESCRIBE MASKING POLICY
Expand Down Expand Up @@ -160,7 +160,7 @@ func ListMaskingPolicies(databaseName string, schemaName string, db *sql.DB) ([]
dbs := []MaskingPolicyStruct{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no masking policies found")
log.Println("[DEBUG] no masking policies found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/materialized_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func ListMaterializedViews(databaseName string, schemaName string, db *sql.DB) (
dbs := []materializedView{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no materialized views found")
log.Println("[DEBUG] no materialized views found")
return nil, nil
}
return dbs, pe.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
6 changes: 3 additions & 3 deletions pkg/snowflake/pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ func (pb *PipeBuilder) WithCopyStatement(s string) *PipeBuilder {
return pb
}

/// WithIntegration adds Integration specification to the PipeBuilder
// / WithIntegration adds Integration specification to the PipeBuilder
func (pb *PipeBuilder) WithIntegration(s string) *PipeBuilder {
pb.integration = s
return pb
}

/// WithErrorIntegration adds ErrorIntegration specification to the PipeBuilder
// / WithErrorIntegration adds ErrorIntegration specification to the PipeBuilder
func (pb *PipeBuilder) WithErrorIntegration(s string) *PipeBuilder {
pb.errorIntegration = s
return pb
Expand Down Expand Up @@ -190,7 +190,7 @@ func ListPipes(databaseName string, schemaName string, db *sql.DB) ([]pipe, erro
dbs := []pipe{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no pipes found")
log.Println("[DEBUG] no pipes found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/procedure.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func ListProcedures(databaseName string, schemaName string, db *sql.DB) ([]proce
dbs := []procedure{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no procedures found")
log.Println("[DEBUG] no procedures found")
return nil, nil
}
return dbs, pe.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/resource_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func ListResourceMonitors(db *sql.DB) ([]resourceMonitor, error) {
dbs := []resourceMonitor{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no resouce monitors found")
log.Println("[DEBUG] no resouce monitors found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
5 changes: 2 additions & 3 deletions pkg/snowflake/row_access_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ func (rapb *RowAccessPolicyBuilder) WithRowAccessExpression(rowAccessExpression
//
// Supported DDL operations are:
// - CREATE ROW ACCESS POLICY
// - ALTER ROW ACCESS POLICY
// - ALTER ROW ACCESS POLICY
// - DROP ROW ACCESS POLICY
// - SHOW ROW ACCESS POLICIES
// - DESCRIBE ROW ACCESS POLICY
//
func RowAccessPolicy(name, db, schema string) *RowAccessPolicyBuilder {
return &RowAccessPolicyBuilder{
name: name,
Expand Down Expand Up @@ -159,7 +158,7 @@ func ListRowAccessPolicies(databaseName string, schemaName string, db *sql.DB) (
dbs := []RowAccessPolicyStruct{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no row access policies found")
log.Println("[DEBUG] no row access policies found")
return nil, nil
}
return dbs, pe.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func ListSchemas(databaseName string, db *sql.DB) ([]schema, error) {
dbs := []schema{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no schemas found")
log.Println("[DEBUG] no schemas found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func ListSequences(databaseName string, schemaName string, db *sql.DB) ([]sequen
dbs := []sequence{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no sequences found")
log.Println("[DEBUG] no sequences found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func ListStages(databaseName string, schemaName string, db *sql.DB) ([]stage, er
dbs := []stage{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no stages found")
log.Println("[DEBUG] no stages found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/storage_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func ListStorageIntegrations(db *sql.DB) ([]storageIntegration, error) {
dbs := []storageIntegration{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no resouce monitors found")
log.Println("[DEBUG] no resouce monitors found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func ListStreams(databaseName string, schemaName string, db *sql.DB) ([]descStre
dbs := []descStreamRow{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no stages found")
log.Println("[DEBUG] no stages found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
6 changes: 3 additions & 3 deletions pkg/snowflake/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (tb *TableBuilder) UnsetTag(tag TagValue) string {
return fmt.Sprintf(`ALTER TABLE %s UNSET TAG "%v"."%v"."%v"`, tb.QualifiedName(), tag.Database, tag.Schema, tag.Name)
}

//Function to get clustering definition
// Function to get clustering definition
func (tb *TableBuilder) GetClusterKeyString() string {

return JoinStringList(tb.clusterBy[:], ", ")
Expand Down Expand Up @@ -442,7 +442,7 @@ func (tb *TableBuilder) getCreateStatementBody() string {
return q.String()
}

//function to take the literal snowflake cluster statement returned from SHOW TABLES and convert it to a list of keys.
// function to take the literal snowflake cluster statement returned from SHOW TABLES and convert it to a list of keys.
func ClusterStatementToList(clusterStatement string) []string {
if clusterStatement == "" {
return nil
Expand Down Expand Up @@ -758,7 +758,7 @@ func ListTables(databaseName string, schemaName string, db *sql.DB) ([]table, er
dbs := []table{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no tables found")
log.Println("[DEBUG] no tables found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func ListTags(databaseName, schemaName string, db *sql.DB) ([]tag, error) {
tags := []tag{}
err = sqlx.StructScan(rows, &tags)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no tags found")
log.Println("[DEBUG] no tags found")
return nil, nil
}
return tags, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func ListTasks(databaseName string, schemaName string, db *sql.DB) ([]task, erro
dbs := []task{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no tasks found")
log.Println("[DEBUG] no tasks found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
2 changes: 1 addition & 1 deletion pkg/snowflake/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func ListUsers(pattern string, db *sql.DB) ([]user, error) {
dbs := []user{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no users found")
log.Println("[DEBUG] no users found")
return nil, nil
}
return dbs, errors.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
4 changes: 2 additions & 2 deletions pkg/snowflake/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ViewBuilder struct {
// QualifiedName prepends the db and schema if set and escapes everything nicely
func (vb *ViewBuilder) QualifiedName() (string, error) {
if vb.db == "" || vb.schema == "" {
return "", errors.New("Views must specify a database and a schema")
return "", errors.New("views must specify a database and a schema")
}

return fmt.Sprintf(`"%v"."%v"."%v"`, vb.db, vb.schema, vb.name), nil
Expand Down Expand Up @@ -235,7 +235,7 @@ func ListViews(databaseName string, schemaName string, db *sql.DB) ([]view, erro
dbs := []view{}
err = sqlx.StructScan(rows, &dbs)
if err == sql.ErrNoRows {
log.Printf("[DEBUG] no views found")
log.Println("[DEBUG] no views found")
return nil, nil
}
return dbs, pe.Wrapf(err, "unable to scan row for %s", stmt)
Expand Down
Loading

0 comments on commit 0f2e2db

Please sign in to comment.