-
Notifications
You must be signed in to change notification settings - Fork 873
Add some validation checks #62
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ import ( | |
| func importBuilder(store storage.Store, options ImportOptions) (*Builder, error) { | ||
| manifest := []byte{} | ||
| config := []byte{} | ||
| name := "" | ||
| image := "" | ||
| imageName := "" | ||
|
|
||
|
|
@@ -26,13 +25,13 @@ func importBuilder(store storage.Store, options ImportOptions) (*Builder, error) | |
| systemContext := getSystemContext(options.SignaturePolicyPath) | ||
|
|
||
| if c.ImageID != "" { | ||
| ref, err := is.Transport.ParseStoreReference(store, "@"+c.ImageID) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("no such image %q: %v", "@"+c.ImageID, err) | ||
| ref, err2 := is.Transport.ParseStoreReference(store, "@"+c.ImageID) | ||
| if err2 != nil { | ||
| return nil, fmt.Errorf("no such image %q: %v", "@"+c.ImageID, err2) | ||
| } | ||
| src, err := ref.NewImage(systemContext) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("error instantiating image: %v", err) | ||
| src, err3 := ref.NewImage(systemContext) | ||
| if err3 != nil { | ||
| return nil, fmt.Errorf("error instantiating image: %v", err3) | ||
| } | ||
| defer src.Close() | ||
| config, err = src.ConfigBlob() | ||
|
Member
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. Not an issue, but I'm not getting why you added numbers to some but not all 'err' variables.
Member
Author
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. These avoid shadowing warnings from one of the linters, by removing cases where we declare a variable in a block when a variable with that same name already exists in an enclosing block. https://golang.org/ref/spec#Short_variable_declarations also covers why we don't have to do this when we redeclare a variable from the same block.
Member
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. Ty for the 411! |
||
|
|
@@ -44,14 +43,14 @@ func importBuilder(store storage.Store, options ImportOptions) (*Builder, error) | |
| return nil, fmt.Errorf("error reading image manifest: %v", err) | ||
| } | ||
| image = c.ImageID | ||
| if img, err := store.GetImage(image); err == nil { | ||
| if img, err4 := store.GetImage(image); err4 == nil { | ||
| if len(img.Names) > 0 { | ||
| imageName = img.Names[0] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| name = options.Container | ||
| name := options.Container | ||
|
|
||
| builder := &Builder{ | ||
| store: store, | ||
|
|
||
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.
Neat trick using the ..., will have to try and remember that.
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.
Agreed, it's a very handy language feature.