-
Notifications
You must be signed in to change notification settings - Fork 597
/
accountid.go
37 lines (30 loc) · 1.11 KB
/
accountid.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package customizations
import (
"context"
"github.com/aws/smithy-go/middleware"
)
type setDefaultAccountID func(input interface{}, accountID string) interface{}
// AddDefaultAccountIDMiddleware adds the DefaultAccountID to the stack using
// the given options.
func AddDefaultAccountIDMiddleware(stack *middleware.Stack, setDefaultAccountID setDefaultAccountID) error {
return stack.Initialize.Add(&DefaultAccountID{
setDefaultAccountID: setDefaultAccountID,
}, middleware.Before)
}
// DefaultAccountID sets the account ID to "-" if it isn't already set
type DefaultAccountID struct {
setDefaultAccountID setDefaultAccountID
}
// ID returns the id of the middleware
func (*DefaultAccountID) ID() string {
return "Glacier:DefaultAccountID"
}
// HandleInitialize implements the InitializeMiddleware interface
func (m *DefaultAccountID) HandleInitialize(
ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler,
) (
out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
in.Parameters = m.setDefaultAccountID(in.Parameters, "-")
return next.HandleInitialize(ctx, in)
}