-
Notifications
You must be signed in to change notification settings - Fork 222
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
AzCopy Code Review #1
Conversation
…tadata handling done at the backend
Please consider squashing some of these commits together, so that it's easier to review each concrete change. 😃 |
cmd/cancel.go
Outdated
cancelCmd := &cobra.Command{ | ||
Use: "cancel", | ||
SuggestFor: []string{"cancl", "ancl", "cacl"}, | ||
Short: "cancel cancels the existing job for given JobId", |
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.
cancel cancels an existing job
cmd/cancel.go
Outdated
Use: "cancel", | ||
SuggestFor: []string{"cancl", "ancl", "cacl"}, | ||
Short: "cancel cancels the existing job for given JobId", | ||
Long: `cancel cancels the existing job for given JobId`, |
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.
cancel cancels an existing job
cmd/cancel.go
Outdated
Short: "cancel cancels the existing job for given JobId", | ||
Long: `cancel cancels the existing job for given JobId`, | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
// the cancel command requires necessarily to have an argument |
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.
// the cancel command requires a JobId argument; it then cancels all parts of the specified job.
cmd/cancel.go
Outdated
|
||
// If no argument is passed then it is not valid | ||
if len(args) != 1 { | ||
return errors.New("this command only requires jobId") |
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.
We should talk about how errors are presented to the user. This is fine for now, but we can't ship like this.
SuggestFor: []string{"cpy", "cy", "mv"}, //TODO why does message appear twice on the console | ||
Short: "copy(cp) moves data between two places.", | ||
Short: "copy(cp) moves data between two places.", |
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.
You can't say "copy moves" as this indicates that copy doesn't "copy" and that it "moves" instead. At some point, we should get Sercan and go through all of this. Maybe we also get Roy, the doc guy to work with us on this.
cmd/pause.go
Outdated
pauseCmd := &cobra.Command{ | ||
Use: "pause", | ||
SuggestFor: []string{"pase", "ause", "paue"}, | ||
Short: "pause pauses the existing job for given JobId", |
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.
You're missing an article in these sentences: "pause pauses the existing job for the specified JobId"
cmd/validators.go
Outdated
"github.com/Azure/azure-storage-azcopy/common" | ||
"net/url" | ||
"os" | ||
) | ||
|
||
func determineLocaltionType(stringToParse string) common.LocationType { |
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.
Why is this method lowercase (private) and IsLocalPath & IsURL uppercase (public)?
If the 2 IsXxx methods are only ever called by determineLocationType (spelled wrong, by the way), then define them inside the determineLocationType function itself.
cmd/validators.go
Outdated
@@ -42,14 +42,14 @@ func IsLocalPath(path string) bool { | |||
_, err := os.Stat(path) | |||
// in case the path does not exist yet, an err is returned | |||
// we need to make sure that it is indeed just a local path that does not exist yet, and not a url | |||
if err == nil || (!IsUrl(path) && os.IsNotExist(err)){ | |||
if err == nil || (!IsUrl(path) && os.IsNotExist(err)) { |
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.
You could just "return err = nil || (!IsURL(path) && os.IsNotExist(err)" and then kill the braces and the return true & return false
cmd/validators.go
Outdated
@@ -61,4 +61,4 @@ func IsUrl(givenUrl string) bool{ | |||
return false |
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.
You could just return !(u.Host == "" || u.Scheme == "" || u.Path == "")
common/frontend-ste-models.go
Outdated
) | ||
type JobID string //todo -- to uuid | ||
|
||
type JobID UUID |
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.
Let be consistent everywhere with casing: JobID or JobId -- I think JobID is better (as per http://www.dictionary.com/browse/id?s=t).
common/frontend-ste-models.go
Outdated
|
||
type JobID UUID | ||
|
||
func (j JobID) String() (string){ |
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.
Is this function necessary? Maybe if JobID doesn't have String, it will automatically call String on the UUID type? I'm not sure myself.
common/frontend-ste-models.go
Outdated
type TransferStatus uint32 | ||
|
||
func (status TransferStatus) String() (statusString string) { | ||
switch uint32(status) { |
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.
Get rid of the switch cast and integers in the cases -- use case with constants instead.
If you are defining a data type (like TransferStatus), then use that data type; avoid casting it away. Casting it away defeats the whole purpose.
common/frontend-ste-models.go
Outdated
func (status TransferStatus) String() (statusString string) { | ||
switch uint32(status) { | ||
case 0: | ||
return "InProgress" |
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.
Where do these strings appear? Are they customer facing? logging? Both? If customer facing, then I'm sure we don't want something like "TransferComplete" without a space.
common/frontend-ste-models.go
Outdated
// Transfer has failed due to some error. This status does represent the state when transfer is cancelled | ||
TransferFailed TransferStatus = 2 | ||
|
||
// Transfer is any of the three possible state (InProgress, Completer or Failed) |
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.
When is this used again? It is very strange to me. Also TransferStatus is a uint32 now not a byte so maybe we want a different value here? Maybe we should do this a different way?
common/frontend-ste-models.go
Outdated
TransferAny TransferStatus = TransferStatus(254) | ||
) | ||
|
||
func TransferStatusStringToCode(statusString string) TransferStatus { |
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.
Why do we need this? If we really do need it, then the strings should be defined once as constants and re-used otherwise a spelling change in one place breaks the other place. Another way to go is to initialize a map[status]string and initialize it with number/string pairs. Then, getting the string from number is trivial and getting the number from string requires a for range loop which is slower but probably less commonly done.
common/frontend-ste-models.go
Outdated
} | ||
|
||
type LogLevel pipeline.LogLevel | ||
const ( |
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.
There is no need for any of this; just use pipeline.LogLevel and its constants directly. Also, why have String()?
common/frontend-ste-models.go
Outdated
@@ -37,7 +129,7 @@ type CopyCmdArgsAndFlags struct { | |||
Destination string | |||
|
|||
// inferred from arguments | |||
SourceType LocationType | |||
SourceType LocationType |
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.
I put the comment here because github won't let me put the comment on line 146. I think we want to define a type Metadata string for Metadata when used in a JobPartPlan. Then, you can easily add a method that converts it to an azblob.Metadata type so it can be passed into PutBlob/PutBlock method.
common/frontend-ste-models.go
Outdated
@@ -63,15 +155,16 @@ type CopyCmdArgsAndFlags struct { | |||
|
|||
// ListCmdArgsAndFlags represents the raw list command input from the user | |||
type ListCmdArgsAndFlags struct { | |||
JobId string | |||
TransferStatus string | |||
JobId string |
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.
Should this be a UUID? In the code you want to parse command line strings into specific data types as soon as possible to get the value of type safety in your code base as quickly as possible.
common/frontend-ste-models.go
Outdated
JobId string | ||
TransferStatus string | ||
JobId string | ||
OfStatus string |
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.
This should be a specific data type too, right?
…code; changes in get job summary
…xecuting chunk func. the changes are added only for debug purpose #1
This reverts commit 0046ccd.
No description provided.