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

Totally remove insert feature

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-05-05 15:44:16 -07:00
parent a8ef66d84a
commit 7a145b022a
6 changed files with 3 additions and 161 deletions

View file

@ -534,32 +534,6 @@ func getImagesSearch(eng *engine.Engine, version version.Version, w http.Respons
return job.Run()
}
// FIXME: 'insert' is deprecated as of 0.10, and should be removed in a future version.
func postImagesInsert(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := parseForm(r); err != nil {
return err
}
if vars == nil {
return fmt.Errorf("Missing parameter")
}
job := eng.Job("insert", vars["name"], r.Form.Get("url"), r.Form.Get("path"))
if version.GreaterThan("1.0") {
job.SetenvBool("json", true)
streamJSON(job, w, false)
} else {
job.Stdout.Add(w)
}
if err := job.Run(); err != nil {
if !job.Stdout.Used() {
return err
}
sf := utils.NewStreamFormatter(version.GreaterThan("1.0"))
w.Write(sf.FormatError(err))
}
return nil
}
func postImagesPush(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if vars == nil {
return fmt.Errorf("Missing parameter")
@ -1111,7 +1085,6 @@ func createRouter(eng *engine.Engine, logging, enableCors bool, dockerVersion st
"/commit": postCommit,
"/build": postBuild,
"/images/create": postImagesCreate,
"/images/{name:.*}/insert": postImagesInsert,
"/images/load": postImagesLoad,
"/images/{name:.*}/push": postImagesPush,
"/images/{name:.*}/tag": postImagesTag,

View file

@ -84,42 +84,6 @@ type Container struct {
activeLinks map[string]*links.Link
}
// Inject the io.Reader at the given path. Note: do not close the reader
func (container *Container) Inject(file io.Reader, pth string) error {
if err := container.Mount(); err != nil {
return fmt.Errorf("inject: error mounting container %s: %s", container.ID, err)
}
defer container.Unmount()
// Return error if path exists
destPath := container.getResourcePath(pth)
if _, err := os.Stat(destPath); err == nil {
// Since err is nil, the path could be stat'd and it exists
return fmt.Errorf("%s exists", pth)
} else if !os.IsNotExist(err) {
// Expect err might be that the file doesn't exist, so
// if it's some other error, return that.
return err
}
// Make sure the directory exists
if err := os.MkdirAll(container.getResourcePath(path.Dir(pth)), 0755); err != nil {
return err
}
dest, err := os.Create(destPath)
if err != nil {
return err
}
defer dest.Close()
if _, err := io.Copy(dest, file); err != nil {
return err
}
return nil
}
func (container *Container) FromDisk() error {
data, err := ioutil.ReadFile(container.jsonPath())
if err != nil {

View file

@ -63,6 +63,9 @@ Trusted builds are now Automated Builds - `is_trusted` is now `is_automated`.
**New!**
You can now ping the server via the `_ping` endpoint.
**Removed Insert Endpoint**
The insert endpoint has been removed.
`GET /events`
**New!**

View file

@ -756,31 +756,6 @@ Create an image, either by pull it from the registry or by importing it
- **200** no error
- **500** server error
### Insert a file in an image
`POST /images/(name)/insert`
Insert a file from `url` in the image `name` at `path`
**Example request**:
POST /images/test/insert?path=/usr&url=myurl HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"Inserting..."}
{"status":"Inserting", "progress":"1/? (n/a)", "progressDetail":{"current":1}}
{"error":"Invalid..."}
...
Status Codes:
- **200** no error
- **500** server error
### Inspect an image
`GET /images/(name)/json`

View file

@ -398,28 +398,6 @@ func TestImagesFilter(t *testing.T) {
}
}
// FIXE: 'insert' is deprecated and should be removed in a future version.
func TestImageInsert(t *testing.T) {
eng := NewTestEngine(t)
defer mkDaemonFromEngine(eng, t).Nuke()
srv := mkServerFromEngine(eng, t)
// bad image name fails
if err := srv.Eng.Job("insert", "foo", "https://www.docker.io/static/img/docker-top-logo.png", "/foo").Run(); err == nil {
t.Fatal("expected an error and got none")
}
// bad url fails
if err := srv.Eng.Job("insert", unitTestImageID, "http://bad_host_name_that_will_totally_fail.com/", "/foo").Run(); err == nil {
t.Fatal("expected an error and got none")
}
// success returns nil
if err := srv.Eng.Job("insert", unitTestImageID, "https://www.docker.io/static/img/docker-top-logo.png", "/foo").Run(); err != nil {
t.Fatalf("expected no error, but got %v", err)
}
}
func TestListContainers(t *testing.T) {
eng := NewTestEngine(t)
srv := mkServerFromEngine(eng, t)

View file

@ -138,7 +138,6 @@ func InitServer(job *engine.Job) engine.Status {
"history": srv.ImageHistory,
"viz": srv.ImagesViz,
"container_copy": srv.ContainerCopy,
"insert": srv.ImageInsert,
"attach": srv.ContainerAttach,
"logs": srv.ContainerLogs,
"changes": srv.ContainerChanges,
@ -645,56 +644,6 @@ func (srv *Server) recursiveLoad(eng *engine.Engine, address, tmpImageDir string
return nil
}
// FIXME: 'insert' is deprecated and should be removed in a future version.
func (srv *Server) ImageInsert(job *engine.Job) engine.Status {
fmt.Fprintf(job.Stderr, "Warning: '%s' is deprecated and will be removed in a future version. Please use 'build' and 'ADD' instead.\n", job.Name)
if len(job.Args) != 3 {
return job.Errorf("Usage: %s IMAGE URL PATH\n", job.Name)
}
var (
name = job.Args[0]
url = job.Args[1]
path = job.Args[2]
)
sf := utils.NewStreamFormatter(job.GetenvBool("json"))
out := utils.NewWriteFlusher(job.Stdout)
img, err := srv.daemon.Repositories().LookupImage(name)
if err != nil {
return job.Error(err)
}
file, err := utils.Download(url)
if err != nil {
return job.Error(err)
}
defer file.Body.Close()
config, _, _, err := runconfig.Parse([]string{img.ID, "echo", "insert", url, path}, srv.daemon.SystemConfig())
if err != nil {
return job.Error(err)
}
c, _, err := srv.daemon.Create(config, "")
if err != nil {
return job.Error(err)
}
if err := c.Inject(utils.ProgressReader(file.Body, int(file.ContentLength), out, sf, false, utils.TruncateID(img.ID), "Downloading"), path); err != nil {
return job.Error(err)
}
// FIXME: Handle custom repo, tag comment, author
img, err = srv.daemon.Commit(c, "", "", img.Comment, img.Author, nil)
if err != nil {
out.Write(sf.FormatError(err))
return engine.StatusErr
}
out.Write(sf.FormatStatus("", img.ID))
return engine.StatusOK
}
func (srv *Server) ImagesViz(job *engine.Job) engine.Status {
images, _ := srv.daemon.Graph().Map()
if images == nil {