-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathcontext.go
More file actions
42 lines (34 loc) · 752 Bytes
/
Copy pathcontext.go
File metadata and controls
42 lines (34 loc) · 752 Bytes
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
38
39
40
41
42
package ecschedule
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
)
type contextKey string
const appKey contextKey = "app"
type app struct {
Config *Config
AccountID string
AwsConf aws.Config
ExtStr map[string]string
ExtCode map[string]string
}
func (a *app) loadConfigOptions() []LoadConfigOption {
var opts []LoadConfigOption
if len(a.ExtStr) > 0 {
opts = append(opts, WithExtStr(a.ExtStr))
}
if len(a.ExtCode) > 0 {
opts = append(opts, WithExtCode(a.ExtCode))
}
return opts
}
func setApp(ctx context.Context, a *app) context.Context {
return context.WithValue(ctx, appKey, a)
}
func getApp(ctx context.Context) *app {
iface := ctx.Value(appKey)
if a, ok := iface.(*app); ok {
return a
}
return nil
}