@@ -460,6 +460,11 @@ func fillMissingConfigParameters(cfg *Config) error {
460
460
if authRequiresPassword (cfg ) && strings .TrimSpace (cfg .Password ) == "" {
461
461
return errEmptyPassword ()
462
462
}
463
+
464
+ if authRequiresEitherPasswordOrToken (cfg ) && strings .TrimSpace (cfg .Password ) == "" && strings .TrimSpace (cfg .Token ) == "" {
465
+ return errEmptyPasswordAndToken ()
466
+ }
467
+
463
468
if strings .Trim (cfg .Protocol , " " ) == "" {
464
469
cfg .Protocol = "https"
465
470
}
@@ -576,14 +581,20 @@ func buildHostFromAccountAndRegion(account, region string) string {
576
581
func authRequiresUser (cfg * Config ) bool {
577
582
return cfg .Authenticator != AuthTypeOAuth &&
578
583
cfg .Authenticator != AuthTypeTokenAccessor &&
579
- cfg .Authenticator != AuthTypeExternalBrowser
584
+ cfg .Authenticator != AuthTypeExternalBrowser &&
585
+ cfg .Authenticator != AuthTypePat
580
586
}
581
587
582
588
func authRequiresPassword (cfg * Config ) bool {
583
589
return cfg .Authenticator != AuthTypeOAuth &&
584
590
cfg .Authenticator != AuthTypeTokenAccessor &&
585
591
cfg .Authenticator != AuthTypeExternalBrowser &&
586
- cfg .Authenticator != AuthTypeJwt
592
+ cfg .Authenticator != AuthTypeJwt &&
593
+ cfg .Authenticator != AuthTypePat
594
+ }
595
+
596
+ func authRequiresEitherPasswordOrToken (cfg * Config ) bool {
597
+ return cfg .Authenticator == AuthTypePat
587
598
}
588
599
589
600
// transformAccountToHost transforms account to host
@@ -905,7 +916,7 @@ type ConfigParam struct {
905
916
906
917
// GetConfigFromEnv is used to parse the environment variable values to specific fields of the Config
907
918
func GetConfigFromEnv (properties []* ConfigParam ) (* Config , error ) {
908
- var account , user , password , role , host , portStr , protocol , warehouse , database , schema , region , passcode , application string
919
+ var account , user , password , token , role , host , portStr , protocol , warehouse , database , schema , region , passcode , application string
909
920
var privateKey * rsa.PrivateKey
910
921
var err error
911
922
if len (properties ) == 0 || properties == nil {
@@ -923,6 +934,8 @@ func GetConfigFromEnv(properties []*ConfigParam) (*Config, error) {
923
934
user = value
924
935
case "Password" :
925
936
password = value
937
+ case "Token" :
938
+ token = value
926
939
case "Role" :
927
940
role = value
928
941
case "Host" :
@@ -963,6 +976,7 @@ func GetConfigFromEnv(properties []*ConfigParam) (*Config, error) {
963
976
Account : account ,
964
977
User : user ,
965
978
Password : password ,
979
+ Token : token ,
966
980
Role : role ,
967
981
Host : host ,
968
982
Port : port ,
0 commit comments