github.com/versent/saml2aws@v2.17.0+incompatible/pkg/flags/flags.go (about) 1 package flags 2 3 import ( 4 "github.com/versent/saml2aws/pkg/cfg" 5 ) 6 7 // CommonFlags flags common to all of the `saml2aws` commands (except `help`) 8 type CommonFlags struct { 9 AppID string 10 ClientID string 11 ClientSecret string 12 ConfigFile string 13 IdpAccount string 14 IdpProvider string 15 MFA string 16 MFAToken string 17 URL string 18 Username string 19 Password string 20 RoleArn string 21 AmazonWebservicesURN string 22 SessionDuration int 23 SkipPrompt bool 24 SkipVerify bool 25 Profile string 26 Subdomain string 27 ResourceID string 28 } 29 30 // LoginExecFlags flags for the Login / Exec commands 31 type LoginExecFlags struct { 32 CommonFlags *CommonFlags 33 Force bool 34 DuoMFAOption string 35 ExecProfile string 36 } 37 38 // ApplyFlagOverrides overrides IDPAccount with command line settings 39 func ApplyFlagOverrides(commonFlags *CommonFlags, account *cfg.IDPAccount) { 40 if commonFlags.AppID != "" { 41 account.AppID = commonFlags.AppID 42 } 43 44 if commonFlags.URL != "" { 45 account.URL = commonFlags.URL 46 } 47 48 if commonFlags.Username != "" { 49 account.Username = commonFlags.Username 50 } 51 52 if commonFlags.SkipVerify { 53 account.SkipVerify = commonFlags.SkipVerify 54 } 55 56 if commonFlags.IdpProvider != "" { 57 account.Provider = commonFlags.IdpProvider 58 } 59 60 if commonFlags.MFA != "" { 61 account.MFA = commonFlags.MFA 62 } 63 64 if commonFlags.AmazonWebservicesURN != "" { 65 account.AmazonWebservicesURN = commonFlags.AmazonWebservicesURN 66 } 67 68 if commonFlags.SessionDuration != 0 { 69 account.SessionDuration = commonFlags.SessionDuration 70 } 71 72 if commonFlags.Profile != "" { 73 account.Profile = commonFlags.Profile 74 } 75 76 if commonFlags.Subdomain != "" { 77 account.Subdomain = commonFlags.Subdomain 78 } 79 80 if commonFlags.RoleArn != "" { 81 account.RoleARN = commonFlags.RoleArn 82 } 83 if commonFlags.ResourceID != "" { 84 account.ResourceID = commonFlags.ResourceID 85 } 86 }