зеркало из https://github.com/microsoft/docker.git
check plugin manifest is correctly formatted before push
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
Родитель
90be7a591d
Коммит
b47711ae92
|
@ -3,7 +3,10 @@
|
||||||
package plugin
|
package plugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -114,11 +117,16 @@ func (pm *Manager) Push(name string, metaHeader http.Header, authConfig *types.A
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dest := filepath.Join(pm.libRoot, p.PluginObj.ID)
|
dest := filepath.Join(pm.libRoot, p.PluginObj.ID)
|
||||||
config, err := os.Open(filepath.Join(dest, "manifest.json"))
|
config, err := ioutil.ReadFile(filepath.Join(dest, "manifest.json"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var dummy types.Plugin
|
||||||
|
err = json.Unmarshal(config, &dummy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer config.Close()
|
|
||||||
|
|
||||||
rootfs, err := archive.Tar(filepath.Join(dest, "rootfs"), archive.Gzip)
|
rootfs, err := archive.Tar(filepath.Join(dest, "rootfs"), archive.Gzip)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -126,7 +134,7 @@ func (pm *Manager) Push(name string, metaHeader http.Header, authConfig *types.A
|
||||||
}
|
}
|
||||||
defer rootfs.Close()
|
defer rootfs.Close()
|
||||||
|
|
||||||
_, err = distribution.Push(name, pm.registryService, metaHeader, authConfig, config, rootfs)
|
_, err = distribution.Push(name, pm.registryService, metaHeader, authConfig, ioutil.NopCloser(bytes.NewReader(config)), rootfs)
|
||||||
// XXX: Ignore returning digest for now.
|
// XXX: Ignore returning digest for now.
|
||||||
// Since digest needs to be written to the ProgressWriter.
|
// Since digest needs to be written to the ProgressWriter.
|
||||||
return err
|
return err
|
||||||
|
|
Загрузка…
Ссылка в новой задаче