@@ -269,13 +269,14 @@ func (c *ConfigFile) ProfileNames() []string {
269269
270270// ConfigLoader loads config from configfile and environment variables
271271type ConfigLoader struct {
272- BaseConfig Config
273- File * ConfigFile
274- ActiveProfile string
272+ BaseConfig ProfileConfig
273+ File * ConfigFile
274+ ActiveProfile string
275+
275276 visitedProfiles []string
276277}
277278
278- func NewConfigLoader (baseConfig Config , file * ConfigFile , activeProfile string ) * ConfigLoader {
279+ func NewConfigLoader (baseConfig ProfileConfig , file * ConfigFile , activeProfile string ) * ConfigLoader {
279280 return & ConfigLoader {
280281 BaseConfig : baseConfig ,
281282 File : file ,
@@ -297,7 +298,7 @@ func (cl *ConfigLoader) resetLoopDetection() {
297298 cl .visitedProfiles = []string {}
298299}
299300
300- func (cl * ConfigLoader ) populateFromDefaults (config * Config ) {
301+ func (cl * ConfigLoader ) populateFromDefaults (config * ProfileConfig ) {
301302 if config .AssumeRoleDuration == 0 {
302303 config .AssumeRoleDuration = DefaultSessionDuration
303304 }
@@ -312,7 +313,7 @@ func (cl *ConfigLoader) populateFromDefaults(config *Config) {
312313 }
313314}
314315
315- func (cl * ConfigLoader ) populateFromConfigFile (config * Config , profileName string ) error {
316+ func (cl * ConfigLoader ) populateFromConfigFile (config * ProfileConfig , profileName string ) error {
316317 if ! cl .visitProfile (profileName ) {
317318 return fmt .Errorf ("Loop detected in config file for profile '%s'" , profileName )
318319 }
@@ -419,7 +420,7 @@ func (cl *ConfigLoader) populateFromConfigFile(config *Config, profileName strin
419420 return nil
420421}
421422
422- func (cl * ConfigLoader ) populateFromEnv (profile * Config ) {
423+ func (cl * ConfigLoader ) populateFromEnv (profile * ProfileConfig ) {
423424 if region := os .Getenv ("AWS_REGION" ); region != "" && profile .Region == "" {
424425 log .Printf ("Using region %q from AWS_REGION" , region )
425426 profile .Region = region
@@ -501,9 +502,9 @@ func (cl *ConfigLoader) populateFromEnv(profile *Config) {
501502 }
502503}
503504
504- func (cl * ConfigLoader ) hydrateSourceConfig (config * Config ) error {
505+ func (cl * ConfigLoader ) hydrateSourceConfig (config * ProfileConfig ) error {
505506 if config .SourceProfileName != "" {
506- sc , err := cl .LoadFromProfile (config .SourceProfileName )
507+ sc , err := cl .GetProfileConfig (config .SourceProfileName )
507508 if err != nil {
508509 return err
509510 }
@@ -513,8 +514,8 @@ func (cl *ConfigLoader) hydrateSourceConfig(config *Config) error {
513514 return nil
514515}
515516
516- // LoadFromProfile loads the profile from the config file and environment variables into config
517- func (cl * ConfigLoader ) LoadFromProfile (profileName string ) (* Config , error ) {
517+ // GetProfileConfig loads the profile from the config file and environment variables into config
518+ func (cl * ConfigLoader ) GetProfileConfig (profileName string ) (* ProfileConfig , error ) {
518519 config := cl .BaseConfig
519520 config .ProfileName = profileName
520521 cl .populateFromEnv (& config )
@@ -535,19 +536,19 @@ func (cl *ConfigLoader) LoadFromProfile(profileName string) (*Config, error) {
535536 return & config , nil
536537}
537538
538- // Config is a collection of configuration options for creating temporary credentials
539- type Config struct {
539+ // ProfileConfig is a collection of configuration options for creating temporary credentials
540+ type ProfileConfig struct {
540541 // ProfileName specifies the name of the profile config
541542 ProfileName string
542543
543544 // SourceProfile is the profile where credentials come from
544545 SourceProfileName string
545546
546547 // SourceProfile is the profile where credentials come from
547- SourceProfile * Config
548+ SourceProfile * ProfileConfig
548549
549- // ChainedFromProfile is the profile that used this profile as it's source profile
550- ChainedFromProfile * Config
550+ // ChainedFromProfile is the profile that used this profile as its source profile
551+ ChainedFromProfile * ProfileConfig
551552
552553 // Region is the AWS region
553554 Region string
@@ -619,7 +620,7 @@ type Config struct {
619620}
620621
621622// SetSessionTags parses a comma separated key=vaue string and sets Config.SessionTags map
622- func (c * Config ) SetSessionTags (s string ) error {
623+ func (c * ProfileConfig ) SetSessionTags (s string ) error {
623624 c .SessionTags = make (map [string ]string )
624625 for _ , tag := range strings .Split (s , "," ) {
625626 kvPair := strings .SplitN (tag , "=" , 2 )
@@ -633,54 +634,54 @@ func (c *Config) SetSessionTags(s string) error {
633634}
634635
635636// SetTransitiveSessionTags parses a comma separated string and sets Config.TransitiveSessionTags
636- func (c * Config ) SetTransitiveSessionTags (s string ) {
637+ func (c * ProfileConfig ) SetTransitiveSessionTags (s string ) {
637638 for _ , tag := range strings .Split (s , "," ) {
638639 if tag = strings .TrimSpace (tag ); tag != "" {
639640 c .TransitiveSessionTags = append (c .TransitiveSessionTags , tag )
640641 }
641642 }
642643}
643644
644- func (c * Config ) IsChained () bool {
645+ func (c * ProfileConfig ) IsChained () bool {
645646 return c .ChainedFromProfile != nil
646647}
647648
648- func (c * Config ) HasSourceProfile () bool {
649+ func (c * ProfileConfig ) HasSourceProfile () bool {
649650 return c .SourceProfile != nil
650651}
651652
652- func (c * Config ) HasMfaSerial () bool {
653+ func (c * ProfileConfig ) HasMfaSerial () bool {
653654 return c .MfaSerial != ""
654655}
655656
656- func (c * Config ) HasRole () bool {
657+ func (c * ProfileConfig ) HasRole () bool {
657658 return c .RoleARN != ""
658659}
659660
660- func (c * Config ) HasSSOSession () bool {
661+ func (c * ProfileConfig ) HasSSOSession () bool {
661662 return c .SSOSession != ""
662663}
663664
664- func (c * Config ) HasSSOStartURL () bool {
665+ func (c * ProfileConfig ) HasSSOStartURL () bool {
665666 return c .SSOStartURL != ""
666667}
667668
668- func (c * Config ) HasWebIdentity () bool {
669+ func (c * ProfileConfig ) HasWebIdentity () bool {
669670 return c .WebIdentityTokenFile != "" || c .WebIdentityTokenProcess != ""
670671}
671672
672- func (c * Config ) HasCredentialProcess () bool {
673+ func (c * ProfileConfig ) HasCredentialProcess () bool {
673674 return c .CredentialProcess != ""
674675}
675676
676- func (c * Config ) GetSessionTokenDuration () time.Duration {
677+ func (c * ProfileConfig ) GetSessionTokenDuration () time.Duration {
677678 if c .IsChained () {
678679 return c .ChainedGetSessionTokenDuration
679680 }
680681 return c .NonChainedGetSessionTokenDuration
681682}
682683
683- func (c * Config ) Validate () error {
684+ func (c * ProfileConfig ) Validate () error {
684685 if c .HasSSOSession () && ! c .HasSSOStartURL () {
685686 return fmt .Errorf ("profile '%s' has sso_session but no sso_start_url" , c .ProfileName )
686687 }
@@ -700,7 +701,6 @@ func (c *Config) Validate() error {
700701 } else if c .HasRole () {
701702 n ++
702703 }
703-
704704 if n > 1 {
705705 return fmt .Errorf ("profile '%s' has more than one source of credentials" , c .ProfileName )
706706 }
0 commit comments