Skip to content

Commit

Permalink
Release 1.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
IBMalok authored and GitHub Enterprise committed Feb 6, 2024
1 parent bc52078 commit d043a17
Show file tree
Hide file tree
Showing 84 changed files with 6,115 additions and 6,243 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGELOG

## 1.10.2

### Content

#### Defect Fixes

* Internal fixes and improvements
* Support for Golang 1.19, 1.20 and 1.21.0

## 1.10.1

### Content
Expand Down
80 changes: 39 additions & 41 deletions aws/awserr/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,23 @@ package awserr
//
// Example:
//
// output, err := s3manage.Upload(svc, input, opts)
// if err != nil {
// if awsErr, ok := err.(awserr.Error); ok {
// // Get error details
// log.Println("Error:", awsErr.Code(), awsErr.Message())
//
// // Prints out full error message, including original error if there was one.
// log.Println("Error:", awsErr.Error())
//
// // Get original error
// if origErr := awsErr.OrigErr(); origErr != nil {
// // operate on original error.
// }
// } else {
// fmt.Println(err.Error())
// }
// }
//
// output, err := s3manage.Upload(svc, input, opts)
// if err != nil {
// if awsErr, ok := err.(awserr.Error); ok {
// // Get error details
// log.Println("Error:", awsErr.Code(), awsErr.Message())
//
// // Prints out full error message, including original error if there was one.
// log.Println("Error:", awsErr.Error())
//
// // Get original error
// if origErr := awsErr.OrigErr(); origErr != nil {
// // operate on original error.
// }
// } else {
// fmt.Println(err.Error())
// }
// }
type Error interface {
// Satisfy the generic error interface.
error
Expand Down Expand Up @@ -100,32 +99,31 @@ func NewBatchError(code, message string, errs []error) BatchedErrors {
//
// Example:
//
// output, err := s3manage.Upload(svc, input, opts)
// if err != nil {
// if reqerr, ok := err.(RequestFailure); ok {
// log.Println("Request failed", reqerr.Code(), reqerr.Message(), reqerr.RequestID())
// } else {
// log.Println("Error:", err.Error())
// }
// }
// output, err := s3manage.Upload(svc, input, opts)
// if err != nil {
// if reqerr, ok := err.(RequestFailure); ok {
// log.Println("Request failed", reqerr.Code(), reqerr.Message(), reqerr.RequestID())
// } else {
// log.Println("Error:", err.Error())
// }
// }
//
// Combined with awserr.Error:
//
// output, err := s3manage.Upload(svc, input, opts)
// if err != nil {
// if awsErr, ok := err.(awserr.Error); ok {
// // Generic AWS Error with Code, Message, and original error (if any)
// fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
//
// if reqErr, ok := err.(awserr.RequestFailure); ok {
// // A service error occurred
// fmt.Println(reqErr.StatusCode(), reqErr.RequestID())
// }
// } else {
// fmt.Println(err.Error())
// }
// }
//
// output, err := s3manage.Upload(svc, input, opts)
// if err != nil {
// if awsErr, ok := err.(awserr.Error); ok {
// // Generic AWS Error with Code, Message, and original error (if any)
// fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
//
// if reqErr, ok := err.(awserr.RequestFailure); ok {
// // A service error occurred
// fmt.Println(reqErr.StatusCode(), reqErr.RequestID())
// }
// } else {
// fmt.Println(err.Error())
// }
// }
type RequestFailure interface {
Error

Expand Down
1 change: 0 additions & 1 deletion aws/client/default_retryer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
// DefaultRetryer implements basic retry logic using exponential backoff for
// most services. If you want to implement custom retry logic, you can implement the
// request.Retryer interface.
//
type DefaultRetryer struct {
// Num max Retries is the number of max retries that will be performed.
// By default, this is zero.
Expand Down
23 changes: 11 additions & 12 deletions aws/credentials/chain_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,18 @@ var (
// does not return any credentials ChainProvider will return the error
// ErrNoValidProvidersFoundInChain
//
// creds := credentials.NewChainCredentials(
// []credentials.Provider{
// &credentials.EnvProvider{},
// &ec2rolecreds.EC2RoleProvider{
// Client: ec2metadata.New(sess),
// },
// })
//
// // Usage of ChainCredentials with aws.Config
// svc := ec2.New(session.Must(session.NewSession(&aws.Config{
// Credentials: creds,
// })))
// creds := credentials.NewChainCredentials(
// []credentials.Provider{
// &credentials.EnvProvider{},
// &ec2rolecreds.EC2RoleProvider{
// Client: ec2metadata.New(sess),
// },
// })
//
// // Usage of ChainCredentials with aws.Config
// svc := ec2.New(session.Must(session.NewSession(&aws.Config{
// Credentials: creds,
// })))
type ChainProvider struct {
Providers []Provider
curr Provider
Expand Down
51 changes: 25 additions & 26 deletions aws/credentials/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,36 @@
//
// Example of using the environment variable credentials.
//
// creds := credentials.NewEnvCredentials()
// creds := credentials.NewEnvCredentials()
//
// // Retrieve the credentials value
// credValue, err := creds.Get()
// if err != nil {
// // handle error
// }
// // Retrieve the credentials value
// credValue, err := creds.Get()
// if err != nil {
// // handle error
// }
//
// Example of forcing credentials to expire and be refreshed on the next Get().
// This may be helpful to proactively expire credentials and refresh them sooner
// than they would naturally expire on their own.
//
// creds := credentials.NewCredentials(&ec2rolecreds.EC2RoleProvider{})
// creds.Expire()
// credsValue, err := creds.Get()
// // New credentials will be retrieved instead of from cache.
// creds := credentials.NewCredentials(&ec2rolecreds.EC2RoleProvider{})
// creds.Expire()
// credsValue, err := creds.Get()
// // New credentials will be retrieved instead of from cache.
//
//
// Custom Provider
// # Custom Provider
//
// Each Provider built into this package also provides a helper method to generate
// a Credentials pointer setup with the provider. To use a custom Provider just
// create a type which satisfies the Provider interface and pass it to the
// NewCredentials method.
//
// type MyProvider struct{}
// func (m *MyProvider) Retrieve() (Value, error) {...}
// func (m *MyProvider) IsExpired() bool {...}
//
// creds := credentials.NewCredentials(&MyProvider{})
// credValue, err := creds.Get()
// type MyProvider struct{}
// func (m *MyProvider) Retrieve() (Value, error) {...}
// func (m *MyProvider) IsExpired() bool {...}
//
// creds := credentials.NewCredentials(&MyProvider{})
// credValue, err := creds.Get()
package credentials

import (
Expand All @@ -68,10 +66,10 @@ import (
// when making service API calls. For example, when accessing public
// s3 buckets.
//
// svc := s3.New(session.Must(session.NewSession(&aws.Config{
// Credentials: credentials.AnonymousCredentials,
// })))
// // Access public S3 buckets.
// svc := s3.New(session.Must(session.NewSession(&aws.Config{
// Credentials: credentials.AnonymousCredentials,
// })))
// // Access public S3 buckets.
var AnonymousCredentials = NewStaticCredentials("", "", "")

// A Value is the AWS credentials value for individual credential fields.
Expand Down Expand Up @@ -165,10 +163,11 @@ func (p ErrorProvider) IsExpired() bool {
// provider's struct.
//
// Example:
// type EC2RoleProvider struct {
// Expiry
// ...
// }
//
// type EC2RoleProvider struct {
// Expiry
// ...
// }
type Expiry struct {
// The date/time when to expire on
expiration time.Time
Expand Down
31 changes: 17 additions & 14 deletions aws/credentials/endpointcreds/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,29 @@
//
// Static credentials will never expire once they have been retrieved. The format
// of the static credentials response:
// {
// "AccessKeyId" : "MUA...",
// "SecretAccessKey" : "/7PC5om....",
// }
//
// {
// "AccessKeyId" : "MUA...",
// "SecretAccessKey" : "/7PC5om....",
// }
//
// Refreshable credentials will expire within the "ExpiryWindow" of the Expiration
// value in the response. The format of the refreshable credentials response:
// {
// "AccessKeyId" : "MUA...",
// "SecretAccessKey" : "/7PC5om....",
// "Token" : "AQoDY....=",
// "Expiration" : "2016-02-25T06:03:31Z"
// }
//
// {
// "AccessKeyId" : "MUA...",
// "SecretAccessKey" : "/7PC5om....",
// "Token" : "AQoDY....=",
// "Expiration" : "2016-02-25T06:03:31Z"
// }
//
// Errors should be returned in the following format and only returned with 400
// or 500 HTTP status codes.
// {
// "code": "ErrorCode",
// "message": "Helpful error message."
// }
//
// {
// "code": "ErrorCode",
// "message": "Helpful error message."
// }
package endpointcreds

import (
Expand Down
26 changes: 16 additions & 10 deletions aws/credentials/ibmiam/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ type Provider struct {

// NewProvider allows the creation of a custom IBM IAM Provider
// Parameters:
// Provider Name
// AWS Config
// API Key
// IBM IAM Authentication Server Endpoint
// Service Instance ID
// Token Manager client
//
// Provider Name
// AWS Config
// API Key
// IBM IAM Authentication Server Endpoint
// Service Instance ID
// Token Manager client
//
// Returns:
// Provider
//
// Provider
func NewProvider(providerName string, config *aws.Config, apiKey, authEndPoint, serviceInstanceID string,
client tokenmanager.IBMClientDo) (provider *Provider) { //linter complain about (provider *Provider) {
provider = new(Provider)
Expand Down Expand Up @@ -99,15 +102,17 @@ func NewProvider(providerName string, config *aws.Config, apiKey, authEndPoint,

// IsValid ...
// Returns:
//
// Provider validation - boolean
func (p *Provider) IsValid() bool {
return nil == p.ErrorStatus
}

// Retrieve ...
// Returns:
// Credential values
// Error
//
// Credential values
// Error
func (p *Provider) Retrieve() (credentials.Value, error) {
if p.ErrorStatus != nil {
if p.logLevel.Matches(aws.LogDebug) {
Expand Down Expand Up @@ -135,7 +140,8 @@ func (p *Provider) Retrieve() (credentials.Value, error) {
}

// IsExpired ...
// Provider expired or not - boolean
//
// Provider expired or not - boolean
func (p *Provider) IsExpired() bool {
return true
}
13 changes: 8 additions & 5 deletions aws/credentials/ibmiam/common_ini_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ const (
// commonIni constructor of the IBM IAM provider that loads IAM credentials from
// an ini file
// Parameters:
// AWS Config
// Profile filename
// Profile prefix
//
// AWS Config
// Profile filename
// Profile prefix
//
// Returns:
// New provider with Provider name, config, API Key, IBM IAM Authentication Server end point,
// Service Instance ID
//
// New provider with Provider name, config, API Key, IBM IAM Authentication Server end point,
// Service Instance ID
func commonIniProvider(providerName string, config *aws.Config, filename, profilename string) *Provider {

// Opens an ini file with the filename passed in for shared credentials
Expand Down
17 changes: 10 additions & 7 deletions aws/credentials/ibmiam/custom_init_func_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ const CustomInitFuncProviderName = "CustomInitFuncProviderIBM"

// NewCustomInitFuncProvider constructor of IBM IAM Provider with a custom init Function
// Parameters:
// aws.config: AWS Config to provide service configuration for service clients. By default,
// all clients will use the defaults.DefaultConfig structure.
// initFunc token: Contents of the token
// authEndPoint: IAM Authentication Server end point
// serviceInstanceID: service instance ID of the IBM account
// client: Token Management's client
//
// aws.config: AWS Config to provide service configuration for service clients. By default,
// all clients will use the defaults.DefaultConfig structure.
// initFunc token: Contents of the token
// authEndPoint: IAM Authentication Server end point
// serviceInstanceID: service instance ID of the IBM account
// client: Token Management's client
//
// Returns:
// A complete Provider with Token Manager initialized
//
// A complete Provider with Token Manager initialized
func NewCustomInitFuncProvider(config *aws.Config, initFunc func() (*token.Token, error), authEndPoint,
serviceInstanceID string, client tokenmanager.IBMClientDo) *Provider {

Expand Down
9 changes: 6 additions & 3 deletions aws/credentials/ibmiam/env_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ const EnvProviderName = "EnvProviderIBM"
// NewEnvProvider constructor of the IBM IAM provider that loads IAM credentials from environment
// variables
// Parameter:
// AWS Config
//
// AWS Config
//
// Returns:
// A new provider with AWS config, API Key, IBM IAM Authentication Server Endpoint and
// Service Instance ID
//
// A new provider with AWS config, API Key, IBM IAM Authentication Server Endpoint and
// Service Instance ID
func NewEnvProvider(config *aws.Config) *Provider {
apiKey := os.Getenv("IBM_API_KEY_ID")
serviceInstanceID := os.Getenv("IBM_SERVICE_INSTANCE_ID")
Expand Down
Loading

0 comments on commit d043a17

Please sign in to comment.