-
Notifications
You must be signed in to change notification settings - Fork 233
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
Restore missing dryrun values that were removed in 10.27 #2923
Open
adreed-msft
wants to merge
4
commits into
main
Choose a base branch
from
adreed/dryrun-regression
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2da54d1
Map in missing dryrun values after 10.27.0
adreed-msft 030697a
Merge remote-tracking branch 'origin/main' into adreed/dryrun-regression
adreed-msft 7472fce
Merge branch 'main' into adreed/dryrun-regression
wonwuakpa-msft ad3221d
Merge branch 'main' into adreed/dryrun-regression
adreed-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ package cmd | |
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob" | ||
"github.com/Azure/azure-storage-azcopy/v10/jobsAdmin" | ||
"net/url" | ||
"strings" | ||
|
@@ -64,21 +65,42 @@ func newCopyTransferProcessor(copyJobTemplate *common.CopyJobPartOrderRequest, n | |
} | ||
|
||
type DryrunTransfer struct { | ||
EntityType common.EntityType | ||
BlobType common.BlobType | ||
FromTo common.FromTo | ||
Source string | ||
Destination string | ||
EntityType common.EntityType | ||
BlobType common.BlobType | ||
FromTo common.FromTo | ||
Source string | ||
Destination string | ||
SourceSize *int64 | ||
HttpHeaders blob.HTTPHeaders | ||
Metadata common.Metadata | ||
BlobTier *blob.AccessTier | ||
BlobVersion *string | ||
BlobTags common.BlobTags | ||
BlobSnapshot *string | ||
} | ||
|
||
type dryrunTransferSurrogate struct { | ||
EntityType string | ||
BlobType string | ||
FromTo string | ||
Source string | ||
Destination string | ||
SourceSize int64 `json:"SourceSize,omitempty"` | ||
ContentType string `json:"ContentType,omitempty"` | ||
ContentEncoding string `json:"ContentEncoding,omitempty"` | ||
ContentDisposition string `json:"ContentDisposition,omitempty"` | ||
ContentLanguage string `json:"ContentLanguage,omitempty"` | ||
CacheControl string `json:"CacheControl,omitempty"` | ||
ContentMD5 []byte `json:"ContentMD5,omitempty"` | ||
BlobTags common.BlobTags `json:"BlobTags,omitempty"` | ||
Metadata common.Metadata `json:"Metadata,omitempty"` | ||
BlobTier blob.AccessTier `json:"BlobTier,omitempty"` | ||
BlobVersion string `json:"BlobVersion,omitempty"` | ||
BlobSnapshotID string `json:"BlobSnapshotID,omitempty"` | ||
} | ||
|
||
func (d *DryrunTransfer) UnmarshalJSON(bytes []byte) error { | ||
var surrogate struct { | ||
EntityType string | ||
BlobType string | ||
FromTo string | ||
Source string | ||
Destination string | ||
} | ||
var surrogate dryrunTransferSurrogate | ||
|
||
err := json.Unmarshal(bytes, &surrogate) | ||
if err != nil { | ||
|
@@ -103,22 +125,59 @@ func (d *DryrunTransfer) UnmarshalJSON(bytes []byte) error { | |
d.Source = surrogate.Source | ||
d.Destination = surrogate.Destination | ||
|
||
d.SourceSize = &surrogate.SourceSize | ||
d.HttpHeaders.BlobContentType = &surrogate.ContentType | ||
d.HttpHeaders.BlobContentEncoding = &surrogate.ContentEncoding | ||
d.HttpHeaders.BlobCacheControl = &surrogate.CacheControl | ||
d.HttpHeaders.BlobContentDisposition = &surrogate.ContentDisposition | ||
d.HttpHeaders.BlobContentLanguage = &surrogate.ContentLanguage | ||
d.HttpHeaders.BlobContentMD5 = surrogate.ContentMD5 | ||
d.BlobTags = surrogate.BlobTags | ||
d.Metadata = surrogate.Metadata | ||
d.BlobTier = &surrogate.BlobTier | ||
d.BlobVersion = &surrogate.BlobVersion | ||
d.BlobSnapshot = &surrogate.BlobSnapshotID | ||
|
||
return nil | ||
} | ||
|
||
func (d DryrunTransfer) MarshalJSON() ([]byte, error) { | ||
surrogate := struct { | ||
EntityType string | ||
BlobType string | ||
FromTo string | ||
Source string | ||
Destination string | ||
}{ | ||
derefString := func(str *string) string { | ||
if str == nil { | ||
return "" | ||
} | ||
|
||
return *str | ||
} | ||
|
||
var aTier blob.AccessTier | ||
var srcSize int64 | ||
if d.SourceSize != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same for this, I think we can just use common.IffNotNil here and for AccessTier |
||
srcSize = *d.SourceSize | ||
} | ||
|
||
if d.BlobTier != nil { | ||
aTier = *d.BlobTier | ||
} | ||
|
||
surrogate := dryrunTransferSurrogate{ | ||
d.EntityType.String(), | ||
d.BlobType.String(), | ||
d.FromTo.String(), | ||
d.Source, | ||
d.Destination, | ||
srcSize, | ||
derefString(d.HttpHeaders.BlobContentType), | ||
derefString(d.HttpHeaders.BlobContentEncoding), | ||
derefString(d.HttpHeaders.BlobContentDisposition), | ||
derefString(d.HttpHeaders.BlobContentLanguage), | ||
derefString(d.HttpHeaders.BlobCacheControl), | ||
d.HttpHeaders.BlobContentMD5, | ||
d.BlobTags, | ||
d.Metadata, | ||
aTier, | ||
derefString(d.BlobVersion), | ||
derefString(d.BlobSnapshot), | ||
} | ||
|
||
return json.Marshal(surrogate) | ||
|
@@ -185,10 +244,25 @@ func (s *copyTransferProcessor) scheduleCopyTransfer(storedObject StoredObject) | |
|
||
if format == common.EOutputFormat.Json() { | ||
tx := DryrunTransfer{ | ||
BlobType: common.FromBlobType(storedObject.blobType), | ||
EntityType: storedObject.entityType, | ||
FromTo: s.copyJobTemplate.FromTo, | ||
Source: common.GenerateFullPath(s.copyJobTemplate.SourceRoot.Value, prettySrcRelativePath), | ||
EntityType: storedObject.entityType, | ||
BlobType: common.FromBlobType(storedObject.blobType), | ||
FromTo: s.copyJobTemplate.FromTo, | ||
Source: common.GenerateFullPath(s.copyJobTemplate.SourceRoot.Value, prettySrcRelativePath), | ||
Destination: "", | ||
SourceSize: &storedObject.size, | ||
HttpHeaders: blob.HTTPHeaders{ | ||
BlobCacheControl: &storedObject.cacheControl, | ||
BlobContentDisposition: &storedObject.contentDisposition, | ||
BlobContentEncoding: &storedObject.contentEncoding, | ||
BlobContentLanguage: &storedObject.contentLanguage, | ||
BlobContentMD5: storedObject.md5, | ||
BlobContentType: &storedObject.contentType, | ||
}, | ||
Metadata: storedObject.Metadata, | ||
BlobTier: &storedObject.blobAccessTier, | ||
BlobVersion: &storedObject.blobVersionID, | ||
BlobTags: storedObject.blobTags, | ||
BlobSnapshot: &storedObject.blobSnapshotID, | ||
} | ||
|
||
if fromTo.To() != common.ELocation.None() && fromTo.To() != common.ELocation.Unknown() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use common.IffNotNil here instead of this?