1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Don't allow images with colons in name and reject pegging versions on pull/import. Addresses #49 and #52

This commit is contained in:
Charles Hooper 2013-03-12 04:31:49 +00:00
parent 63edf8a4a1
commit b8219b5275
2 changed files with 14 additions and 2 deletions

View file

@ -46,6 +46,9 @@ func New(root string) (*Store, error) {
// Import creates a new image from the contents of `archive` and registers it in the store as `name`.
// If `parent` is not nil, it will registered as the parent of the new image.
func (store *Store) Import(name string, archive io.Reader, parent *Image) (*Image, error) {
if strings.Contains(name, ":") {
return nil, errors.New("Invalid image name: " + name)
}
layer, err := store.Layers.AddLayer(archive)
if err != nil {
return nil, err
@ -62,6 +65,9 @@ func (store *Store) Import(name string, archive io.Reader, parent *Image) (*Imag
}
func (store *Store) Create(name string, source string, layers ...string) (*Image, error) {
if strings.Contains(name, ":") {
return nil, errors.New("Invalid image name: " + name)
}
image, err := NewImage(name, layers, source)
if err != nil {
return nil, err

View file

@ -411,6 +411,9 @@ func (srv *Server) CmdPull(stdin io.ReadCloser, stdout io.Writer, args ...string
if name == "" {
return errors.New("Not enough arguments")
}
if strings.Contains(name, ":") {
return errors.New("Invalid image name: " + name)
}
u, err := url.Parse(name)
if err != nil {
return err
@ -828,10 +831,13 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
img = srv.images.Find(name)
if img == nil {
stdin_noclose := ioutil.NopCloser(stdin)
if srv.CmdPull(stdin_noclose, stdout, name) != nil {
return errors.New("Error downloading image: " + name)
if err := srv.CmdPull(stdin_noclose, stdout, name); err != nil {
return err
}
img = srv.images.Find(name)
if img == nil {
return errors.New("Could not find image after downloading: " + name)
}
}
// Create new container