forked from Versent/saml2aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flags.go
86 lines (72 loc) · 1.96 KB
/
flags.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package flags
import (
"github.com/versent/saml2aws/pkg/cfg"
)
// CommonFlags flags common to all of the `saml2aws` commands (except `help`)
type CommonFlags struct {
AppID string
ClientID string
ClientSecret string
ConfigFile string
IdpAccount string
IdpProvider string
MFA string
MFAToken string
URL string
Username string
Password string
RoleArn string
AmazonWebservicesURN string
SessionDuration int
SkipPrompt bool
SkipVerify bool
Profile string
Subdomain string
ResourceID string
}
// LoginExecFlags flags for the Login / Exec commands
type LoginExecFlags struct {
CommonFlags *CommonFlags
Force bool
DuoMFAOption string
ExecProfile string
}
// ApplyFlagOverrides overrides IDPAccount with command line settings
func ApplyFlagOverrides(commonFlags *CommonFlags, account *cfg.IDPAccount) {
if commonFlags.AppID != "" {
account.AppID = commonFlags.AppID
}
if commonFlags.URL != "" {
account.URL = commonFlags.URL
}
if commonFlags.Username != "" {
account.Username = commonFlags.Username
}
if commonFlags.SkipVerify {
account.SkipVerify = commonFlags.SkipVerify
}
if commonFlags.IdpProvider != "" {
account.Provider = commonFlags.IdpProvider
}
if commonFlags.MFA != "" {
account.MFA = commonFlags.MFA
}
if commonFlags.AmazonWebservicesURN != "" {
account.AmazonWebservicesURN = commonFlags.AmazonWebservicesURN
}
if commonFlags.SessionDuration != 0 {
account.SessionDuration = commonFlags.SessionDuration
}
if commonFlags.Profile != "" {
account.Profile = commonFlags.Profile
}
if commonFlags.Subdomain != "" {
account.Subdomain = commonFlags.Subdomain
}
if commonFlags.RoleArn != "" {
account.RoleARN = commonFlags.RoleArn
}
if commonFlags.ResourceID != "" {
account.ResourceID = commonFlags.ResourceID
}
}