Skip to content

Commit

Permalink
Remove deprecated function calls flagged by staticcheck (coredns#3333)
Browse files Browse the repository at this point in the history
* Use session.NewSession instead of session.New

Signed-off-by: Erfan Besharat <erbesharat@gmail.com>

* Use grpc.DialContext instead of grpc.WithTimeout

Signed-off-by: Erfan Besharat <erbesharat@gmail.com>

* Pass non-nil context to context.WithTimeout

Signed-off-by: Erfan Besharat <erbesharat@gmail.com>

* Return the error directly in route53 setup

Co-Authored-By: Miek Gieben <miek@miek.nl>
Signed-off-by: Erfan Besharat <erbesharat@gmail.com>
  • Loading branch information
erbesharat and miekg committed Oct 1, 2019
1 parent dbd1c04 commit 4ffbee2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion plugin/route53/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ func setup(c *caddy.Controller, f func(*credentials.Credentials) route53iface.Ro
return plugin.Error("route53", c.Errf("unknown property '%s'", c.Val()))
}
}

session, err := session.NewSession(&aws.Config{})
if err != nil {
return plugin.Error("route53", err)
}

providers = append(providers, &credentials.EnvProvider{}, sharedProvider, &ec2rolecreds.EC2RoleProvider{
Client: ec2metadata.New(session.New(&aws.Config{})),
Client: ec2metadata.New(session),
})
client := f(credentials.NewChainCredentials(providers))
ctx := context.Background()
Expand Down
3 changes: 2 additions & 1 deletion test/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ func TestGrpc(t *testing.T) {
}
defer g.Stop()

conn, err := grpc.Dial(tcp, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(5*time.Second))
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
conn, err := grpc.DialContext(ctx, tcp, grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
t.Fatalf("Expected no error but got: %s", err)
}
Expand Down

0 comments on commit 4ffbee2

Please sign in to comment.