Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes: More in description #1968

Merged
merged 2 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions cmd/credentialUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ func GetOAuthTokenManagerInstance() (*common.UserOAuthTokenManager, error) {
var err error
autoOAuth.Do(func() {
var lca loginCmdArgs
if glcm.GetEnvironmentVariable(common.EEnvironmentVariable.AutoLoginType()) == "" {
err = errors.New("no login type specified")
autoLoginType := strings.ToUpper(glcm.GetEnvironmentVariable(common.EEnvironmentVariable.AutoLoginType()))
if autoLoginType == "" {
glcm.Info("Autologin not specified.")
return
}

if autoLoginType != "SPN" && autoLoginType != "MSI" && autoLoginType != "DEVICE" {
glcm.Error("Invalid Auto-login type specified.")
return
}

if tenantID := glcm.GetEnvironmentVariable(common.EEnvironmentVariable.TenantID()); tenantID != "" {
lca.tenantID = tenantID
}
Expand Down Expand Up @@ -113,7 +119,9 @@ func GetOAuthTokenManagerInstance() (*common.UserOAuthTokenManager, error) {
}

lca.persistToken = false
err = lca.process()
if err = lca.process(); err != nil {
glcm.Error(fmt.Sprintf("Failed to perform Auto-login: %v.", err.Error()))
}
})

if err != nil {
Expand Down Expand Up @@ -550,13 +558,6 @@ func doGetCredentialTypeForLocation(ctx context.Context, location common.Locatio
credType = common.ECredentialType.Anonymous()
case common.ELocation.Blob():
credType, isPublic, err = getBlobCredentialType(ctx, resource, isSource, resourceSAS, cpkOptions)
if azErr, ok := err.(common.AzError); ok && azErr.Equals(common.EAzError.LoginCredMissing()) {
_, autoLoginErr := GetOAuthTokenManagerInstance()
if autoLoginErr == nil {
err = nil // Autologin succeeded, reset original error
credType, isPublic = common.ECredentialType.OAuthToken(), false
}
}
if err != nil {
return common.ECredentialType.Unknown(), false, err
}
Expand All @@ -566,13 +567,6 @@ func doGetCredentialTypeForLocation(ctx context.Context, location common.Locatio
}
case common.ELocation.BlobFS():
credType, err = getBlobFSCredentialType(ctx, resource, resourceSAS != "")
if azErr, ok := err.(common.AzError); ok && azErr.Equals(common.EAzError.LoginCredMissing()) {
_, autoLoginErr := GetOAuthTokenManagerInstance()
if autoLoginErr == nil {
err = nil // Autologin succeeded, reset original error
credType, isPublic = common.ECredentialType.OAuthToken(), false
}
}
if err != nil {
return common.ECredentialType.Unknown(), false, err
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/syncEnumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ func (cca *cookedSyncCmdArgs) initEnumerator(ctx context.Context) (enumerator *s
// verify that the traversers are targeting the same type of resources
if sourceTraverser.IsDirectory(true) != destinationTraverser.IsDirectory(true) {
return nil, errors.New("trying to sync between different resource types (either file <-> directory or directory <-> file) which is not allowed." +
"sync must happen between source and destination of the same type, e.g. either file <-> file or directory <-> directory")
"sync must happen between source and destination of the same type, e.g. either file <-> file or directory <-> directory." +
"To make sure target is handled as a directory, add a trailing '/' to the target.")
}

// set up the filters in the right order
Expand Down