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

Remove deprecated session.New method #729

Merged
merged 1 commit into from
Nov 21, 2019
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
7 changes: 5 additions & 2 deletions pkg/ec2metadata/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ type EC2Metadata interface {
Region() (string, error)
}

// NewEC2Metadata creates a new EC2Metadata object
// New creates a new EC2Metadata object
func New() EC2Metadata {
return ec2metadatasvc.New(session.New(), aws.NewConfig().WithMaxRetries(10))
awsSession := session.Must(session.NewSession(aws.NewConfig().
WithMaxRetries(10),
))
return ec2metadatasvc.New(awsSession)
}
10 changes: 6 additions & 4 deletions pkg/ec2metadatawrapper/ec2metadatawrapper.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// package ecmetadatawrapper is used to retrieve data from EC2 IMDS
// Package ec2metadatawrapper is used to retrieve data from EC2 IMDS
package ec2metadatawrapper

import (
Expand Down Expand Up @@ -32,10 +32,12 @@ type ec2MetadataClientImpl struct {
// New creates an ec2metadata client to retrieve metadata
func New(client HttpClient) EC2MetadataClient {
if client == nil {
return &ec2MetadataClientImpl{client: ec2metadata.New(session.New(), aws.NewConfig().WithMaxRetries(metadataRetries))}
} else {
return &ec2MetadataClientImpl{client: client}
awsSession := session.Must(session.NewSession(aws.NewConfig().
WithMaxRetries(metadataRetries),
))
return &ec2MetadataClientImpl{client: ec2metadata.New(awsSession)}
}
return &ec2MetadataClientImpl{client: client}
}

// InstanceIdentityDocument returns instance identity documents
Expand Down