mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
Merge pull request #11154 from cdoern/imagesPull
Libpod images pull changes
This commit is contained in:
@ -33,6 +33,7 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
|
|||||||
TLSVerify bool `schema:"tlsVerify"`
|
TLSVerify bool `schema:"tlsVerify"`
|
||||||
AllTags bool `schema:"allTags"`
|
AllTags bool `schema:"allTags"`
|
||||||
PullPolicy string `schema:"policy"`
|
PullPolicy string `schema:"policy"`
|
||||||
|
Quiet bool `schema:"quiet"`
|
||||||
}{
|
}{
|
||||||
TLSVerify: true,
|
TLSVerify: true,
|
||||||
PullPolicy: "always",
|
PullPolicy: "always",
|
||||||
@ -116,8 +117,10 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
|
|||||||
select {
|
select {
|
||||||
case s := <-writer.Chan():
|
case s := <-writer.Chan():
|
||||||
report.Stream = string(s)
|
report.Stream = string(s)
|
||||||
if err := enc.Encode(report); err != nil {
|
if !query.Quiet {
|
||||||
logrus.Warnf("Failed to encode json: %v", err)
|
if err := enc.Encode(report); err != nil {
|
||||||
|
logrus.Warnf("Failed to encode json: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
flush()
|
flush()
|
||||||
case <-runCtx.Done():
|
case <-runCtx.Done():
|
||||||
|
@ -962,6 +962,15 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
|||||||
// description: "Mandatory reference to the image (e.g., quay.io/image/name:tag)"
|
// description: "Mandatory reference to the image (e.g., quay.io/image/name:tag)"
|
||||||
// type: string
|
// type: string
|
||||||
// - in: query
|
// - in: query
|
||||||
|
// name: quiet
|
||||||
|
// description: "silences extra stream data on pull"
|
||||||
|
// type: boolean
|
||||||
|
// default: false
|
||||||
|
// - in: query
|
||||||
|
// name: credentials
|
||||||
|
// description: "username:password for the registry"
|
||||||
|
// type: string
|
||||||
|
// - in: query
|
||||||
// name: Arch
|
// name: Arch
|
||||||
// description: Pull image for the specified architecture.
|
// description: Pull image for the specified architecture.
|
||||||
// type: string
|
// type: string
|
||||||
|
@ -87,6 +87,27 @@ class ImageTestCase(APITestCase):
|
|||||||
self.assertTrue(keys["images"], "Expected to find images stanza")
|
self.assertTrue(keys["images"], "Expected to find images stanza")
|
||||||
self.assertTrue(keys["stream"], "Expected to find stream progress stanza's")
|
self.assertTrue(keys["stream"], "Expected to find stream progress stanza's")
|
||||||
|
|
||||||
|
r = requests.post(self.uri("/images/pull?reference=alpine&quiet=true"), timeout=15)
|
||||||
|
self.assertEqual(r.status_code, 200, r.status_code)
|
||||||
|
text = r.text
|
||||||
|
keys = {
|
||||||
|
"error": False,
|
||||||
|
"id": False,
|
||||||
|
"images": False,
|
||||||
|
"stream": False,
|
||||||
|
}
|
||||||
|
# Read and record stanza's from pull
|
||||||
|
for line in str.splitlines(text):
|
||||||
|
obj = json.loads(line)
|
||||||
|
key_list = list(obj.keys())
|
||||||
|
for k in key_list:
|
||||||
|
keys[k] = True
|
||||||
|
|
||||||
|
self.assertFalse(keys["error"], "Expected no errors")
|
||||||
|
self.assertTrue(keys["id"], "Expected to find id stanza")
|
||||||
|
self.assertTrue(keys["images"], "Expected to find images stanza")
|
||||||
|
self.assertFalse(keys["stream"], "Expected to find stream progress stanza's")
|
||||||
|
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
r = requests.post(
|
r = requests.post(
|
||||||
self.podman_url + "/v1.40/images/create?fromImage=alpine&platform=linux/amd64/v8",
|
self.podman_url + "/v1.40/images/create?fromImage=alpine&platform=linux/amd64/v8",
|
||||||
|
Reference in New Issue
Block a user