Skip to content

Commit 4557448

Browse files
Minor fixes: More in description (#1968)
* Echo auto-login failure if any * Update help for sync command to use trailing slash on directories
1 parent d7c9d3a commit 4557448

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

cmd/credentialUtil.go

+11-17
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,17 @@ func GetOAuthTokenManagerInstance() (*common.UserOAuthTokenManager, error) {
8080
var err error
8181
autoOAuth.Do(func() {
8282
var lca loginCmdArgs
83-
if glcm.GetEnvironmentVariable(common.EEnvironmentVariable.AutoLoginType()) == "" {
84-
err = errors.New("no login type specified")
83+
autoLoginType := strings.ToUpper(glcm.GetEnvironmentVariable(common.EEnvironmentVariable.AutoLoginType()))
84+
if autoLoginType == "" {
85+
glcm.Info("Autologin not specified.")
8586
return
8687
}
8788

89+
if autoLoginType != "SPN" && autoLoginType != "MSI" && autoLoginType != "DEVICE" {
90+
glcm.Error("Invalid Auto-login type specified.")
91+
return
92+
}
93+
8894
if tenantID := glcm.GetEnvironmentVariable(common.EEnvironmentVariable.TenantID()); tenantID != "" {
8995
lca.tenantID = tenantID
9096
}
@@ -113,7 +119,9 @@ func GetOAuthTokenManagerInstance() (*common.UserOAuthTokenManager, error) {
113119
}
114120

115121
lca.persistToken = false
116-
err = lca.process()
122+
if err = lca.process(); err != nil {
123+
glcm.Error(fmt.Sprintf("Failed to perform Auto-login: %v.", err.Error()))
124+
}
117125
})
118126

119127
if err != nil {
@@ -550,13 +558,6 @@ func doGetCredentialTypeForLocation(ctx context.Context, location common.Locatio
550558
credType = common.ECredentialType.Anonymous()
551559
case common.ELocation.Blob():
552560
credType, isPublic, err = getBlobCredentialType(ctx, resource, isSource, resourceSAS, cpkOptions)
553-
if azErr, ok := err.(common.AzError); ok && azErr.Equals(common.EAzError.LoginCredMissing()) {
554-
_, autoLoginErr := GetOAuthTokenManagerInstance()
555-
if autoLoginErr == nil {
556-
err = nil // Autologin succeeded, reset original error
557-
credType, isPublic = common.ECredentialType.OAuthToken(), false
558-
}
559-
}
560561
if err != nil {
561562
return common.ECredentialType.Unknown(), false, err
562563
}
@@ -566,13 +567,6 @@ func doGetCredentialTypeForLocation(ctx context.Context, location common.Locatio
566567
}
567568
case common.ELocation.BlobFS():
568569
credType, err = getBlobFSCredentialType(ctx, resource, resourceSAS != "")
569-
if azErr, ok := err.(common.AzError); ok && azErr.Equals(common.EAzError.LoginCredMissing()) {
570-
_, autoLoginErr := GetOAuthTokenManagerInstance()
571-
if autoLoginErr == nil {
572-
err = nil // Autologin succeeded, reset original error
573-
credType, isPublic = common.ECredentialType.OAuthToken(), false
574-
}
575-
}
576570
if err != nil {
577571
return common.ECredentialType.Unknown(), false, err
578572
}

cmd/syncEnumerator.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ func (cca *cookedSyncCmdArgs) initEnumerator(ctx context.Context) (enumerator *s
9494
// verify that the traversers are targeting the same type of resources
9595
if sourceTraverser.IsDirectory(true) != destinationTraverser.IsDirectory(true) {
9696
return nil, errors.New("trying to sync between different resource types (either file <-> directory or directory <-> file) which is not allowed." +
97-
"sync must happen between source and destination of the same type, e.g. either file <-> file or directory <-> directory")
97+
"sync must happen between source and destination of the same type, e.g. either file <-> file or directory <-> directory." +
98+
"To make sure target is handled as a directory, add a trailing '/' to the target.")
9899
}
99100

100101
// set up the filters in the right order

0 commit comments

Comments
 (0)