File: accountid.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.30.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 662,428 kB
  • sloc: java: 16,875; makefile: 432; sh: 175
file content (37 lines) | stat: -rw-r--r-- 1,138 bytes parent folder | download | duplicates (5)
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)
}