Skip to content

Commit

Permalink
modified versions and remove trailing dot version policy
Browse files Browse the repository at this point in the history
  • Loading branch information
gapra-msft committed Oct 3, 2023
1 parent 625f48a commit a1099c1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 48 deletions.
44 changes: 12 additions & 32 deletions common/clientFactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,14 @@ func CreatePageBlobClient(u string, credInfo CredentialInfo, credOpOptions *Cred
///////////////////////////////////////////////// FILE FUNCTIONS /////////////////////////////////////////////////

func CreateFileServiceClient(u string, credInfo CredentialInfo, credOpOptions *CredentialOpOptions, options azcore.ClientOptions, trailingDot *TrailingDotOption, from *Location) *fileservice.Client {
var allowTrailingDot, allowSourceTrailingDot *bool
if trailingDot != nil && *trailingDot == trailingDot.Enable() {
allowTrailingDot = to.Ptr(true)
}
if from != nil && *from == ELocation.File() {
allowSourceTrailingDot = to.Ptr(true)
}
allowTrailingDot := trailingDot != nil && *trailingDot == trailingDot.Enable()
allowSourceTrailingDot := allowTrailingDot && from != nil && *from == ELocation.File()
callbacks := newClientCallbacks[fileservice.Client, sharefile.SharedKeyCredential]{
TokenCredential: func(u string, tc azcore.TokenCredential, options azcore.ClientOptions) (*fileservice.Client, error) {
return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType)
},
NoCredential: func(u string, options azcore.ClientOptions) (*fileservice.Client, error) {
return fileservice.NewClientWithNoCredential(u, &fileservice.ClientOptions{ClientOptions: options, AllowTrailingDot: allowTrailingDot, AllowSourceTrailingDot: allowSourceTrailingDot})
return fileservice.NewClientWithNoCredential(u, &fileservice.ClientOptions{ClientOptions: options, AllowTrailingDot: to.Ptr(allowTrailingDot), AllowSourceTrailingDot: to.Ptr(allowSourceTrailingDot)})
},
SharedKeyCredential: func(u string, sharedKey *sharefile.SharedKeyCredential, options azcore.ClientOptions) (*fileservice.Client, error) {
return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType)
Expand All @@ -248,19 +243,14 @@ func CreateFileServiceClient(u string, credInfo CredentialInfo, credOpOptions *C
}

func CreateShareClient(u string, credInfo CredentialInfo, credOpOptions *CredentialOpOptions, options azcore.ClientOptions, trailingDot *TrailingDotOption, from *Location) *share.Client {
var allowTrailingDot, allowSourceTrailingDot *bool
if trailingDot != nil && *trailingDot == trailingDot.Enable() {
allowTrailingDot = to.Ptr(true)
}
if from != nil && *from == ELocation.File() {
allowSourceTrailingDot = to.Ptr(true)
}
allowTrailingDot := trailingDot != nil && *trailingDot == trailingDot.Enable()
allowSourceTrailingDot := allowTrailingDot && from != nil && *from == ELocation.File()
callbacks := newClientCallbacks[share.Client, sharefile.SharedKeyCredential]{
TokenCredential: func(u string, tc azcore.TokenCredential, options azcore.ClientOptions) (*share.Client, error) {
return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType)
},
NoCredential: func(u string, options azcore.ClientOptions) (*share.Client, error) {
return share.NewClientWithNoCredential(u, &share.ClientOptions{ClientOptions: options, AllowTrailingDot: allowTrailingDot, AllowSourceTrailingDot: allowSourceTrailingDot})
return share.NewClientWithNoCredential(u, &share.ClientOptions{ClientOptions: options, AllowTrailingDot: to.Ptr(allowTrailingDot), AllowSourceTrailingDot: to.Ptr(allowSourceTrailingDot)})
},
SharedKeyCredential: func(u string, sharedKey *sharefile.SharedKeyCredential, options azcore.ClientOptions) (*share.Client, error) {
return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType)
Expand All @@ -274,19 +264,14 @@ func CreateShareClient(u string, credInfo CredentialInfo, credOpOptions *Credent
}

func CreateShareFileClient(u string, credInfo CredentialInfo, credOpOptions *CredentialOpOptions, options azcore.ClientOptions, trailingDot *TrailingDotOption, from *Location) *sharefile.Client {
var allowTrailingDot, allowSourceTrailingDot *bool
if trailingDot != nil && *trailingDot == trailingDot.Enable() {
allowTrailingDot = to.Ptr(true)
}
if from != nil && *from == ELocation.File() {
allowSourceTrailingDot = to.Ptr(true)
}
allowTrailingDot := trailingDot != nil && *trailingDot == trailingDot.Enable()
allowSourceTrailingDot := allowTrailingDot && from != nil && *from == ELocation.File()
callbacks := newClientCallbacks[sharefile.Client, sharefile.SharedKeyCredential]{
TokenCredential: func(u string, tc azcore.TokenCredential, options azcore.ClientOptions) (*sharefile.Client, error) {
return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType)
},
NoCredential: func(u string, options azcore.ClientOptions) (*sharefile.Client, error) {
return sharefile.NewClientWithNoCredential(u, &sharefile.ClientOptions{ClientOptions: options, AllowTrailingDot: allowTrailingDot, AllowSourceTrailingDot: allowSourceTrailingDot})
return sharefile.NewClientWithNoCredential(u, &sharefile.ClientOptions{ClientOptions: options, AllowTrailingDot: to.Ptr(allowTrailingDot), AllowSourceTrailingDot: to.Ptr(allowSourceTrailingDot)})
},
SharedKeyCredential: func(u string, sharedKey *sharefile.SharedKeyCredential, options azcore.ClientOptions) (*sharefile.Client, error) {
return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType)
Expand All @@ -300,19 +285,14 @@ func CreateShareFileClient(u string, credInfo CredentialInfo, credOpOptions *Cre
}

func CreateShareDirectoryClient(u string, credInfo CredentialInfo, credOpOptions *CredentialOpOptions, options azcore.ClientOptions, trailingDot *TrailingDotOption, from *Location) *sharedirectory.Client {
var allowTrailingDot, allowSourceTrailingDot *bool
if trailingDot != nil && *trailingDot == trailingDot.Enable() {
allowTrailingDot = to.Ptr(true)
}
if from != nil && *from == ELocation.File() {
allowSourceTrailingDot = to.Ptr(true)
}
allowTrailingDot := trailingDot != nil && *trailingDot == trailingDot.Enable()
allowSourceTrailingDot := allowTrailingDot && from != nil && *from == ELocation.File()
callbacks := newClientCallbacks[sharedirectory.Client, sharefile.SharedKeyCredential]{
TokenCredential: func(u string, tc azcore.TokenCredential, options azcore.ClientOptions) (*sharedirectory.Client, error) {
return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType)
},
NoCredential: func(u string, options azcore.ClientOptions) (*sharedirectory.Client, error) {
return sharedirectory.NewClientWithNoCredential(u, &sharedirectory.ClientOptions{ClientOptions: options, AllowTrailingDot: allowTrailingDot, AllowSourceTrailingDot: allowSourceTrailingDot})
return sharedirectory.NewClientWithNoCredential(u, &sharedirectory.ClientOptions{ClientOptions: options, AllowTrailingDot: to.Ptr(allowTrailingDot), AllowSourceTrailingDot: to.Ptr(allowSourceTrailingDot)})
},
SharedKeyCredential: func(u string, sharedKey *sharefile.SharedKeyCredential, options azcore.ClientOptions) (*sharedirectory.Client, error) {
return nil, fmt.Errorf("invalid state, credential type %v is not supported", credInfo.CredentialType)
Expand Down
2 changes: 1 addition & 1 deletion common/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (EnvironmentVariable) CredentialType() EnvironmentVariable {
func (EnvironmentVariable) DefaultServiceApiVersion() EnvironmentVariable {
return EnvironmentVariable{
Name: "AZCOPY_DEFAULT_SERVICE_API_VERSION",
DefaultValue: "2020-10-02",
DefaultValue: "2022-11-02",
Description: "Overrides the service API version so that AzCopy could accommodate custom environments such as Azure Stack.",
}
}
Expand Down
2 changes: 1 addition & 1 deletion ste/mgr-JobPartMgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func NewClientOptions(retry policy.RetryOptions, telemetry policy.TelemetryOptio
log.RequestLogOptions.SyslogDisabled = common.IsForceLoggingDisabled()
perCallPolicies := []policy.Policy{azruntime.NewRequestIDPolicy()}
// TODO : Default logging policy is not equivalent to old one. tracing HTTP request
perRetryPolicies := []policy.Policy{newRetryNotificationPolicy(), newVersionPolicy(), newColdTierPolicy(), newTrailingDotPolicy(), newLogPolicy(log), newStatsPolicy(statsAcc)}
perRetryPolicies := []policy.Policy{newRetryNotificationPolicy(), newVersionPolicy(), newColdTierPolicy(), newLogPolicy(log), newStatsPolicy(statsAcc)}

return azcore.ClientOptions{
//APIVersion: ,
Expand Down
14 changes: 0 additions & 14 deletions ste/xferVersionPolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,4 @@ func (r *coldTierPolicy) Do(req *policy.Request) (*http.Response, error) {
req.Raw().Header["x-ms-version"] = []string{"2021-12-02"}
}
return req.Next()
}

type trailingDotPolicy struct {
}

func newTrailingDotPolicy() policy.Policy {
return &trailingDotPolicy{}
}

func (r *trailingDotPolicy) Do(req *policy.Request) (*http.Response, error) {
if len(req.Raw().Header["x-ms-allow-trailing-dot"]) > 0 || len(req.Raw().Header["x-ms-source-allow-trailing-dot"]) > 0 {
req.Raw().Header["x-ms-version"] = []string{"2022-11-02"}
}
return req.Next()
}

0 comments on commit a1099c1

Please sign in to comment.