Skip to content

Commit bf71210

Browse files
committed
fix linter
1 parent 80221f9 commit bf71210

File tree

9 files changed

+75
-42
lines changed

9 files changed

+75
-42
lines changed

cloudenv/local_cloudenv.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ func (c *LocalCloudEnv) loadCloudFile() error {
130130
func (c *LocalCloudEnv) loadAppName() {
131131
c.appName = "<unknown>"
132132
codecRegistry := viper.NewCodecRegistry()
133-
codecRegistry.RegisterCodec("hcl", hcl.Codec{})
134133
err := codecRegistry.RegisterCodec("hcl", hcl.Codec{})
135134
if err != nil {
136135
panic(fmt.Errorf("fatal error on registering codec: %s", err))

connectors/databases/raw/mongodb_connector.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package raw
33
import (
44
"github.com/cloudfoundry-community/gautocloud/connectors"
55
"github.com/cloudfoundry-community/gautocloud/connectors/databases/dbtype"
6-
. "github.com/cloudfoundry-community/gautocloud/connectors/databases/schema"
6+
"github.com/cloudfoundry-community/gautocloud/connectors/databases/schema"
77
)
88

99
type MongodbRawConnector struct{}
@@ -20,8 +20,8 @@ func (c MongodbRawConnector) Name() string {
2020
func (c MongodbRawConnector) Tags() []string {
2121
return []string{"mongo.*"}
2222
}
23-
func (c MongodbRawConnector) Load(schema interface{}) (interface{}, error) {
24-
fSchema := schema.(MongoDbSchema)
23+
func (c MongodbRawConnector) Load(dbschema any) (any, error) {
24+
fSchema := dbschema.(schema.MongoDbSchema)
2525
if fSchema.Uri.Host == "" {
2626
return dbtype.MongodbDatabase{
2727
User: fSchema.User,
@@ -45,6 +45,6 @@ func (c MongodbRawConnector) Load(schema interface{}) (interface{}, error) {
4545
Options: fSchema.Uri.RawQuery,
4646
}, nil
4747
}
48-
func (c MongodbRawConnector) Schema() interface{} {
49-
return MongoDbSchema{}
48+
func (c MongodbRawConnector) Schema() any {
49+
return schema.MongoDbSchema{}
5050
}

connectors/databases/raw/mssql_connector.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package raw
33
import (
44
"github.com/cloudfoundry-community/gautocloud/connectors"
55
"github.com/cloudfoundry-community/gautocloud/connectors/databases/dbtype"
6-
. "github.com/cloudfoundry-community/gautocloud/connectors/databases/schema"
6+
"github.com/cloudfoundry-community/gautocloud/connectors/databases/schema"
77
)
88

99
type MssqlRawConnector struct{}
@@ -20,8 +20,8 @@ func (c MssqlRawConnector) Name() string {
2020
func (c MssqlRawConnector) Tags() []string {
2121
return []string{"mssql.*", "sqlserver"}
2222
}
23-
func (c MssqlRawConnector) Load(schema interface{}) (interface{}, error) {
24-
fSchema := schema.(MssqlSchema)
23+
func (c MssqlRawConnector) Load(dbschema any) (any, error) {
24+
fSchema := dbschema.(schema.MssqlSchema)
2525
if fSchema.Uri.Host == "" {
2626
return dbtype.MssqlDatabase{
2727
User: fSchema.User,
@@ -45,6 +45,6 @@ func (c MssqlRawConnector) Load(schema interface{}) (interface{}, error) {
4545
Options: fSchema.Uri.RawQuery,
4646
}, nil
4747
}
48-
func (c MssqlRawConnector) Schema() interface{} {
49-
return MssqlSchema{}
48+
func (c MssqlRawConnector) Schema() any {
49+
return schema.MssqlSchema{}
5050
}

connectors/databases/raw/mysql_connector.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package raw
33
import (
44
"github.com/cloudfoundry-community/gautocloud/connectors"
55
"github.com/cloudfoundry-community/gautocloud/connectors/databases/dbtype"
6-
. "github.com/cloudfoundry-community/gautocloud/connectors/databases/schema"
6+
"github.com/cloudfoundry-community/gautocloud/connectors/databases/schema"
77
)
88

99
type MysqlRawConnector struct{}
@@ -20,8 +20,8 @@ func (c MysqlRawConnector) Name() string {
2020
func (c MysqlRawConnector) Tags() []string {
2121
return []string{"mysql", "maria.*"}
2222
}
23-
func (c MysqlRawConnector) Load(schema interface{}) (interface{}, error) {
24-
fSchema := schema.(MysqlSchema)
23+
func (c MysqlRawConnector) Load(dbschema any) (any, error) {
24+
fSchema := dbschema.(schema.MysqlSchema)
2525
if fSchema.Uri.Host == "" {
2626
return dbtype.MysqlDatabase{
2727
User: fSchema.User,
@@ -45,6 +45,6 @@ func (c MysqlRawConnector) Load(schema interface{}) (interface{}, error) {
4545
Options: fSchema.Uri.RawQuery,
4646
}, nil
4747
}
48-
func (c MysqlRawConnector) Schema() interface{} {
49-
return MysqlSchema{}
48+
func (c MysqlRawConnector) Schema() any {
49+
return schema.MysqlSchema{}
5050
}

interceptor/cli/urfave/doc_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ func Example() {
2020

2121
// Initialize a fake cloud env only for example, normally you should do this in init() function
2222
os.Clearenv()
23-
os.Setenv("DYNO", "true")
23+
err := os.Setenv("DYNO", "true")
24+
if err != nil {
25+
panic(err)
26+
}
2427
// Here we set a value for Orig field from MyConfig schema
25-
os.Setenv("CONFIG_ORIG", "<injected by gautocloud>")
28+
err = os.Setenv("CONFIG_ORIG", "<injected by gautocloud>")
29+
if err != nil {
30+
panic(err)
31+
}
2632
gautocloud.RegisterConnector(generic.NewConfigGenericConnector(MyConfig{}, cliInterceptor))
2733
gautocloud.ReloadConnectors()
2834
//////
@@ -68,7 +74,10 @@ func Example() {
6874
Action: action,
6975
},
7076
}
71-
app.Run([]string{"app", "--foo=bar", "doo", "--bar"})
77+
err = app.Run([]string{"app", "--foo=bar", "doo", "--bar"})
78+
if err != nil {
79+
panic(err)
80+
}
7281

7382
// Output: urfave_test.MyConfig{Foo:"bar", Bar:true, Orig:"<injected by gautocloud>"}
7483
}

interceptor/configfile/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package configfile
22

33
import (
4-
"errors"
54
"fmt"
5+
"os"
6+
"path/filepath"
7+
"reflect"
8+
69
"github.com/cloudfoundry-community/gautocloud/decoder"
710
"github.com/cloudfoundry-community/gautocloud/interceptor"
811
"github.com/cloudfoundry-community/gautocloud/utils"
912
log "github.com/sirupsen/logrus"
1013
"github.com/spf13/viper"
11-
"os"
12-
"path/filepath"
13-
"reflect"
1414
)
1515

1616
type ConfigFileInterceptor struct {
@@ -44,12 +44,12 @@ func (i ConfigFileInterceptor) Intercept(current, found interface{}) (interface{
4444
viper.SetConfigFile(confPath)
4545
err = viper.ReadInConfig()
4646
if err != nil {
47-
return nil, errors.New(fmt.Sprintf("Fatal error on reading config file: %s \n", err.Error()))
47+
return nil, fmt.Errorf("fatal error on reading config file: %s", err.Error())
4848
}
4949
var creds map[interface{}]interface{}
5050
err = viper.Unmarshal(&creds)
5151
if err != nil {
52-
return nil, errors.New(fmt.Sprintf("Fatal error when unmarshaling config file: %s \n", err.Error()))
52+
return nil, fmt.Errorf("fatal error when unmarshaling config file: %s", err.Error())
5353
}
5454
finalCreds := utils.ConvertMapInterface(creds).(map[string]interface{})
5555
schemaPtr := interceptor.InterfaceAsPtr(schema)

interceptor/doc_test.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,18 @@ import (
1010

1111
func init() {
1212
os.Clearenv()
13-
os.Setenv("DYNO", "true")
14-
os.Setenv("CONFIG_FOO", "gautocloud")
15-
os.Setenv("CONFIG_BAR", "<injected by gautocloud>")
13+
err := os.Setenv("DYNO", "true")
14+
if err != nil {
15+
panic(err)
16+
}
17+
err = os.Setenv("CONFIG_FOO", "gautocloud")
18+
if err != nil {
19+
panic(err)
20+
}
21+
err = os.Setenv("CONFIG_BAR", "<injected by gautocloud>")
22+
if err != nil {
23+
panic(err)
24+
}
1625
gautocloud.RegisterConnector(generic.NewConfigGenericConnector(MyConfig{}))
1726
gautocloud.RegisterConnector(generic.NewConfigGenericConnector(MySchema{}))
1827
gautocloud.ReloadConnectors()
@@ -49,7 +58,10 @@ func (s *MySchema) Intercept(found interface{}) error {
4958

5059
func ExampleNewSchema() {
5160
var mySchema MySchema
52-
gautocloud.Inject(&mySchema)
61+
err := gautocloud.Inject(&mySchema)
62+
if err != nil {
63+
panic(err)
64+
}
5365
fmt.Printf("%#v\n", mySchema)
5466
// Output: interceptor_test.MySchema{Foo:"write", Bar:"<injected by gautocloud>"}
5567
}

loader/loader_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ var _ = Describe("Loader", func() {
400400
})
401401
AfterEach(func() {
402402
log.SetLevel(currentLvl)
403-
os.Unsetenv(DEBUG_MODE_ENV_VAR)
403+
err := os.Unsetenv(DEBUG_MODE_ENV_VAR)
404+
Expect(err).NotTo(HaveOccurred())
405+
404406
})
405407
It("should show debug log if env var set", func() {
406408
log.SetLevel(log.WarnLevel)

test-integration/test_integration_test.go

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,42 +39,53 @@ var _ = Describe("Connectors integration", func() {
3939
}
4040

4141
log.SetLevel(log.DebugLevel)
42-
os.Unsetenv("MAIL") // travis set this env var which make connector detect it
42+
err := os.Unsetenv("MAIL") // travis set this env var which make connector detect it
43+
Expect(err).ToNot(HaveOccurred())
4344
os.Setenv("MYSQL_URL", CreateEnvValue(ServiceUrl{
4445
Type: "mysql",
4546
User: "user",
4647
Password: "password",
4748
Port: 3406,
4849
Target: "mydb",
4950
}))
50-
os.Setenv("POSTGRES_URL", CreateEnvValue(ServiceUrl{
51+
err = os.Setenv("POSTGRES_URL", CreateEnvValue(ServiceUrl{
5152
Type: "postgres",
5253
User: "user",
5354
Password: "password",
5455
Port: 5532,
5556
Target: "mydb",
5657
Options: "sslmode=disable",
5758
}))
58-
os.Setenv("MSSQL_URL", CreateEnvValue(ServiceUrl{
59+
Expect(err).ToNot(HaveOccurred())
60+
err = os.Setenv("MSSQL_URL", CreateEnvValue(ServiceUrl{
5961
Type: "sqlserver",
6062
User: "sa",
6163
Password: "password",
6264
Port: 1433,
6365
Target: "test",
6466
}))
65-
os.Setenv("MONGODB_URL", CreateEnvValue(ServiceUrl{
67+
Expect(err).ToNot(HaveOccurred())
68+
err = os.Setenv("MONGODB_URL", CreateEnvValue(ServiceUrl{
6669
Type: "mongo",
6770
Port: 27017,
6871
Target: "test",
6972
}))
70-
os.Setenv("SSO_TOKEN_URI", "http://localhost/tokenUri")
71-
os.Setenv("SSO_AUTH_URI", "http://localhost/authUri")
72-
os.Setenv("SSO_USER_INFO_URI", "http://localhost/userInfo")
73-
os.Setenv("SSO_CLIENT_ID", "myId")
74-
os.Setenv("SSO_CLIENT_SECRET", "mySecret")
75-
os.Setenv("SSO_GRANT_TYPE", "grant1,grant2")
76-
os.Setenv("SSO_SCOPES", "scope1,scope2")
77-
os.Setenv("REDIS_URL", CreateEnvValue(ServiceUrl{
73+
Expect(err).ToNot(HaveOccurred())
74+
err = os.Setenv("SSO_TOKEN_URI", "http://localhost/tokenUri")
75+
Expect(err).ToNot(HaveOccurred())
76+
err = os.Setenv("SSO_AUTH_URI", "http://localhost/authUri")
77+
Expect(err).ToNot(HaveOccurred())
78+
err = os.Setenv("SSO_USER_INFO_URI", "http://localhost/userInfo")
79+
Expect(err).ToNot(HaveOccurred())
80+
err = os.Setenv("SSO_CLIENT_ID", "myId")
81+
Expect(err).ToNot(HaveOccurred())
82+
err = os.Setenv("SSO_CLIENT_SECRET", "mySecret")
83+
Expect(err).ToNot(HaveOccurred())
84+
err = os.Setenv("SSO_GRANT_TYPE", "grant1,grant2")
85+
Expect(err).ToNot(HaveOccurred())
86+
err = os.Setenv("SSO_SCOPES", "scope1,scope2")
87+
Expect(err).ToNot(HaveOccurred())
88+
err = os.Setenv("REDIS_URL", CreateEnvValue(ServiceUrl{
7889
Type: "redis",
7990
User: "redis",
8091
Password: "redis",

0 commit comments

Comments
 (0)