From 76013089a4b3e9df6eed6e012cca7dae55cc9d58 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 7 Jul 2013 11:46:21 -0700 Subject: [PATCH] Move blobref.ParseMulti to its sole caller, with error checking. Change-Id: I6351591497879ea5a113bc8e8414b751b3d1c812 --- cmd/camput/remove.go | 10 +++++++++- pkg/blobref/blobref.go | 9 --------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/camput/remove.go b/cmd/camput/remove.go index 8d037aa8a..2890d3de0 100644 --- a/cmd/camput/remove.go +++ b/cmd/camput/remove.go @@ -44,5 +44,13 @@ func (c *removeCmd) RunCommand(args []string) error { if len(args) == 0 { return cmdmain.ErrUsage } - return getUploader().RemoveBlobs(blobref.ParseMulti(args)) + refs := make([]*blobref.BlobRef, 0, len(args)) + for _, s := range args { + br := blobref.Parse(s) + if br == nil { + return fmt.Errorf("Invalid blobref %q", s) + } + refs = append(refs, br) + } + return getUploader().RemoveBlobs(refs) } diff --git a/pkg/blobref/blobref.go b/pkg/blobref/blobref.go index ddf1a5b95..0e9634d20 100644 --- a/pkg/blobref/blobref.go +++ b/pkg/blobref/blobref.go @@ -240,12 +240,3 @@ func MustParse(ref string) *BlobRef { } return br } - -// May return nil in list positions where the blobref could not be parsed. -func ParseMulti(refs []string) (parsed []*BlobRef) { - parsed = make([]*BlobRef, 0, len(refs)) - for _, ref := range refs { - parsed = append(parsed, Parse(ref)) - } - return -}