diff --git a/test/integration/go.mod b/test/integration/go.mod index 8011b204c4..6375e9e849 100644 --- a/test/integration/go.mod +++ b/test/integration/go.mod @@ -48,10 +48,10 @@ require ( github.com/distribution/distribution/v3 v3.0.0-20230830064551-b9b19409cf45 // indirect github.com/distribution/reference v0.5.0 // indirect github.com/docker/buildx v0.11.2 // indirect - github.com/docker/cli v24.0.7+incompatible // indirect + github.com/docker/cli v24.0.6+incompatible // indirect github.com/docker/compose/v2 v2.20.3 // indirect github.com/docker/distribution v2.8.3+incompatible // indirect - github.com/docker/docker v25.0.0+incompatible // indirect + github.com/docker/docker v24.0.7+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.1 // indirect github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect github.com/docker/go-connections v0.5.0 // indirect @@ -116,7 +116,6 @@ require ( github.com/moby/sys/sequential v0.5.0 // indirect github.com/moby/sys/signal v0.7.0 // indirect github.com/moby/sys/symlink v0.2.0 // indirect - github.com/moby/sys/user v0.1.0 // indirect github.com/moby/term v0.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect diff --git a/test/integration/go.sum b/test/integration/go.sum index 200a08d20b..0502793e9c 100644 --- a/test/integration/go.sum +++ b/test/integration/go.sum @@ -132,15 +132,15 @@ github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/buildx v0.11.2 h1:R3p9F0gnI4FwvQ0p40UwdX1T4ugap4UWxY3TFHoP4Ws= github.com/docker/buildx v0.11.2/go.mod h1:CWAABt10iIuGpleypA3103mplDfcGu0A2AvT03xfpTc= -github.com/docker/cli v24.0.7+incompatible h1:wa/nIwYFW7BVTGa7SWPVyyXU9lgORqUb1xfI36MSkFg= -github.com/docker/cli v24.0.7+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v24.0.6+incompatible h1:fF+XCQCgJjjQNIMjzaSmiKJSCcfcXb3TWTcc7GAneOY= +github.com/docker/cli v24.0.6+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/compose/v2 v2.20.3 h1:UM6EaYgpjANQBKo7r7S4yNEdOeXr9IhBOpFFhOhqyd4= github.com/docker/compose/v2 v2.20.3/go.mod h1:xbMcMnkNJQfwh1PlMie2DfzIYAcqhtc2ipgcRGUOHfo= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v25.0.0+incompatible h1:g9b6wZTblhMgzOT2tspESstfw6ySZ9kdm94BLDKaZac= -github.com/docker/docker v25.0.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM= +github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= @@ -383,8 +383,6 @@ github.com/moby/sys/signal v0.7.0 h1:25RW3d5TnQEoKvRbEKUGay6DCQ46IxAVTT9CUMgmsSI github.com/moby/sys/signal v0.7.0/go.mod h1:GQ6ObYZfqacOwTtlXvcmh9A26dVRul/hbOZn88Kg8Tg= github.com/moby/sys/symlink v0.2.0 h1:tk1rOM+Ljp0nFmfOIBtlV3rTDlWOwFRhjEeAhZB0nZc= github.com/moby/sys/symlink v0.2.0/go.mod h1:7uZVF2dqJjG/NsClqul95CqKOBRQyYSNnJ6BMgR/gFs= -github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= -github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= diff --git a/test/integration/vendor/github.com/docker/docker/AUTHORS b/test/integration/vendor/github.com/docker/docker/AUTHORS index 48d04f9a98..b314181925 100644 --- a/test/integration/vendor/github.com/docker/docker/AUTHORS +++ b/test/integration/vendor/github.com/docker/docker/AUTHORS @@ -27,7 +27,6 @@ Adam Miller Adam Mills Adam Pointer Adam Singer -Adam Thornton Adam Walz Adam Williams AdamKorcz @@ -174,7 +173,6 @@ Andy Rothfusz Andy Smith Andy Wilson Andy Zhang -Aneesh Kulkarni Anes Hasicic Angel Velazquez Anil Belur @@ -238,7 +236,6 @@ Ben Golub Ben Gould Ben Hall Ben Langfeld -Ben Lovy Ben Sargent Ben Severson Ben Toews @@ -265,7 +262,7 @@ Billy Ridgway Bily Zhang Bin Liu Bingshen Wang -Bjorn Neergaard +Bjorn Neergaard Blake Geno Boaz Shuster bobby abbott @@ -282,7 +279,6 @@ Brandon Liu Brandon Philips Brandon Rhodes Brendan Dixon -Brennan Kinney <5098581+polarathene@users.noreply.github.com> Brent Salisbury Brett Higgins Brett Kochendorfer @@ -367,7 +363,6 @@ chenyuzhu Chetan Birajdar Chewey Chia-liang Kao -Chiranjeevi Tirunagari chli Cholerae Hu Chris Alfonso @@ -438,8 +433,8 @@ Cristian Staretu cristiano balducci Cristina Yenyxe Gonzalez Garcia Cruceru Calin-Cristian -cui fliter CUI Wei +cuishuang Cuong Manh Le Cyprian Gracz Cyril F @@ -518,7 +513,6 @@ David Dooling David Gageot David Gebler David Glasser -David Karlsson <35727626+dvdksn@users.noreply.github.com> David Lawrence David Lechner David M. Karr @@ -608,7 +602,6 @@ Donald Huang Dong Chen Donghwa Kim Donovan Jones -Dorin Geman Doron Podoleanu Doug Davis Doug MacEachern @@ -643,7 +636,6 @@ Emily Rose Emir Ozer Eng Zer Jun Enguerran -Enrico Weigelt, metux IT consult Eohyung Lee epeterso er0k @@ -684,7 +676,6 @@ Evan Allrich Evan Carmi Evan Hazlett Evan Krall -Evan Lezar Evan Phoenix Evan Wies Evelyn Xu @@ -753,7 +744,6 @@ Frank Groeneveld Frank Herrmann Frank Macreery Frank Rosquin -Frank Villaro-Dixon Frank Yang Fred Lifton Frederick F. Kautz IV @@ -993,7 +983,6 @@ Jean Rouge Jean-Baptiste Barth Jean-Baptiste Dalido Jean-Christophe Berthon -Jean-Michel Rouet Jean-Paul Calderone Jean-Pierre Huynh Jean-Tiare Le Bigot @@ -1024,7 +1013,6 @@ Jeroen Jacobs Jesse Dearing Jesse Dubay Jessica Frazelle -Jeyanthinath Muthuram Jezeniel Zapanta Jhon Honce Ji.Zhilong @@ -1153,7 +1141,6 @@ junxu Jussi Nummelin Justas Brazauskas Justen Martin -Justin Chadwell Justin Cormack Justin Force Justin Keller <85903732+jk-vb@users.noreply.github.com> @@ -1196,7 +1183,6 @@ Ke Xu Kei Ohmura Keith Hudgins Keli Hu -Ken Bannister Ken Cochrane Ken Herner Ken ICHIKAWA @@ -1206,7 +1192,7 @@ Kenjiro Nakayama Kent Johnson Kenta Tada Kevin "qwazerty" Houdebert -Kevin Alvarez +Kevin Alvarez Kevin Burke Kevin Clark Kevin Feyrer @@ -1239,7 +1225,6 @@ Konstantin Gribov Konstantin L Konstantin Pelykh Kostadin Plachkov -kpcyrd Krasi Georgiev Krasimir Georgiev Kris-Mikael Krister @@ -1321,7 +1306,6 @@ Lorenzo Fontana Lotus Fenn Louis Delossantos Louis Opter -Luboslav Pivarc Luca Favatella Luca Marturana Luca Orlandi @@ -1360,7 +1344,6 @@ Manuel Meurer Manuel Rüger Manuel Woelker mapk0y -Marat Radchenko Marc Abramowitz Marc Kuo Marc Tamsky @@ -1400,7 +1383,6 @@ Martijn van Oosterhout Martin Braun Martin Dojcak Martin Honermeyer -Martin Jirku Martin Kelly Martin Mosegaard Amdisen Martin Muzatko @@ -1479,7 +1461,6 @@ Michael Holzheu Michael Hudson-Doyle Michael Huettermann Michael Irwin -Michael Kebe Michael Kuehn Michael Käufl Michael Neale @@ -1528,11 +1509,10 @@ Mike Lundy Mike MacCana Mike Naberezny Mike Snitzer -Mike Sul mikelinjie <294893458@qq.com> Mikhail Sobolev Miklos Szegedi -Milas Bowman +Milas Bowman Milind Chawre Miloslav Trmač mingqing @@ -1544,7 +1524,6 @@ mlarcher Mohammad Banikazemi Mohammad Nasirifar Mohammed Aaqib Ansari -Mohd Sadiq Mohit Soni Moorthy RS Morgan Bauer @@ -1627,7 +1606,6 @@ Noah Treuhaft NobodyOnSE noducks Nolan Darilek -Nolan Miles Noriki Nakamura nponeccop Nurahmadie @@ -1683,7 +1661,6 @@ Paul Lietar Paul Liljenberg Paul Morie Paul Nasrat -Paul Seiffert Paul Weaver Paulo Gomes Paulo Ribeiro @@ -1697,7 +1674,6 @@ Pavlos Ratis Pavol Vargovcik Pawel Konczalski Paweł Gronowski -payall4u Peeyush Gupta Peggy Li Pei Su @@ -1727,9 +1703,7 @@ Phil Estes Phil Sphicas Phil Spitler Philip Alexander Etling -Philip K. Warren Philip Monroe -Philipp Fruck Philipp Gillé Philipp Wahala Philipp Weissensteiner @@ -1767,7 +1741,6 @@ Quentin Brossard Quentin Perez Quentin Tayssier r0n22 -Rachit Sharma Radostin Stoyanov Rafal Jeczalik Rafe Colton @@ -1800,7 +1773,6 @@ Rich Horwood Rich Moyse Rich Seymour Richard Burnison -Richard Hansen Richard Harvey Richard Mathie Richard Metzler @@ -1816,7 +1788,6 @@ Ritesh H Shukla Riyaz Faizullabhoy Rob Cowsill <42620235+rcowsill@users.noreply.github.com> Rob Gulewich -Rob Murray Rob Vesse Robert Bachmann Robert Bittle @@ -1898,7 +1869,6 @@ ryancooper7 RyanDeng Ryo Nakao Ryoga Saito -Régis Behmo Rémy Greinhofer s. rannou Sabin Basyal @@ -1915,7 +1885,6 @@ Sam J Sharpe Sam Neirinck Sam Reis Sam Rijs -Sam Thibault Sam Whited Sambuddha Basu Sami Wagiaalla @@ -1939,7 +1908,6 @@ Satoshi Tagomori Scott Bessler Scott Collier Scott Johnston -Scott Moser Scott Percival Scott Stamp Scott Walls @@ -1955,7 +1923,6 @@ Sebastiaan van Steenis Sebastiaan van Stijn Sebastian Höffner Sebastian Radloff -Sebastian Thomschke Sebastien Goasguen Senthil Kumar Selvaraj Senthil Kumaran @@ -2029,7 +1996,6 @@ Stanislav Bondarenko Stanislav Levin Steeve Morin Stefan Berger -Stefan Gehrig Stefan J. Wernli Stefan Praszalowicz Stefan S. @@ -2037,7 +2003,6 @@ Stefan Scherer Stefan Staudenmeyer Stefan Weil Steffen Butzer -Stephan Henningsen Stephan Spindler Stephen Benjamin Stephen Crosby @@ -2239,7 +2204,6 @@ Vinod Kulkarni Vishal Doshi Vishnu Kannan Vitaly Ostrosablin -Vitor Anjos Vitor Monteiro Vivek Agarwal Vivek Dasgupta @@ -2286,7 +2250,6 @@ Wenxuan Zhao Wenyu You <21551128@zju.edu.cn> Wenzhi Liang Wes Morgan -Wesley Pettit Wewang Xiaorenfine Wiktor Kwapisiewicz Will Dietz @@ -2326,7 +2289,7 @@ xiekeyang Ximo Guanter Gonzálbez xin.li Xinbo Weng -Xinfeng Liu +Xinfeng Liu Xinzi Zhou Xiuming Chen Xuecong Liao @@ -2392,7 +2355,6 @@ Zen Lin(Zhinan Lin) Zhang Kun Zhang Wei Zhang Wentao -zhangguanzhang ZhangHang zhangxianwei Zhenan Ye <21551168@zju.edu.cn> @@ -2419,7 +2381,6 @@ Zuhayr Elahi Zunayed Ali Álvaro Lázaro Átila Camurça Alves -吴小白 <296015668@qq.com> 尹吉峰 屈骏 徐俊杰 diff --git a/test/integration/vendor/github.com/docker/docker/api/README.md b/test/integration/vendor/github.com/docker/docker/api/README.md index 381f19881f..f136c3433a 100644 --- a/test/integration/vendor/github.com/docker/docker/api/README.md +++ b/test/integration/vendor/github.com/docker/docker/api/README.md @@ -37,6 +37,6 @@ There is hopefully enough example material in the file for you to copy a similar When you make edits to `swagger.yaml`, you may want to check the generated API documentation to ensure it renders correctly. -Run `make swagger-docs` and a preview will be running at `http://localhost:9000`. Some of the styling may be incorrect, but you'll be able to ensure that it is generating the correct documentation. +Run `make swagger-docs` and a preview will be running at `http://localhost`. Some of the styling may be incorrect, but you'll be able to ensure that it is generating the correct documentation. The production documentation is generated by vendoring `swagger.yaml` into [docker/docker.github.io](https://github.com/docker/docker.github.io). diff --git a/test/integration/vendor/github.com/docker/docker/api/common.go b/test/integration/vendor/github.com/docker/docker/api/common.go index 37e553d418..cba66bc462 100644 --- a/test/integration/vendor/github.com/docker/docker/api/common.go +++ b/test/integration/vendor/github.com/docker/docker/api/common.go @@ -3,7 +3,7 @@ package api // import "github.com/docker/docker/api" // Common constants for daemon and client. const ( // DefaultVersion of Current REST API - DefaultVersion = "1.44" + DefaultVersion = "1.43" // NoBaseImageSpecifier is the symbol used by the FROM // command to specify that no base image is to be used. diff --git a/test/integration/vendor/github.com/docker/docker/api/common_unix.go b/test/integration/vendor/github.com/docker/docker/api/common_unix.go new file mode 100644 index 0000000000..19fc63d658 --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/api/common_unix.go @@ -0,0 +1,7 @@ +//go:build !windows +// +build !windows + +package api // import "github.com/docker/docker/api" + +// MinVersion represents Minimum REST API version supported +const MinVersion = "1.12" diff --git a/test/integration/vendor/github.com/docker/docker/api/common_windows.go b/test/integration/vendor/github.com/docker/docker/api/common_windows.go new file mode 100644 index 0000000000..590ba5479b --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/api/common_windows.go @@ -0,0 +1,8 @@ +package api // import "github.com/docker/docker/api" + +// MinVersion represents Minimum REST API version supported +// Technically the first daemon API version released on Windows is v1.25 in +// engine version 1.13. However, some clients are explicitly using downlevel +// APIs (e.g. docker-compose v2.1 file format) and that is just too restrictive. +// Hence also allowing 1.24 on Windows. +const MinVersion string = "1.24" diff --git a/test/integration/vendor/github.com/docker/docker/api/swagger.yaml b/test/integration/vendor/github.com/docker/docker/api/swagger.yaml index 567939580b..7635b9f665 100644 --- a/test/integration/vendor/github.com/docker/docker/api/swagger.yaml +++ b/test/integration/vendor/github.com/docker/docker/api/swagger.yaml @@ -19,10 +19,10 @@ produces: consumes: - "application/json" - "text/plain" -basePath: "/v1.44" +basePath: "/v1.43" info: title: "Docker Engine API" - version: "1.44" + version: "1.43" x-logo: url: "https://docs.docker.com/assets/images/logo-docker-main.png" description: | @@ -55,8 +55,8 @@ info: the URL is not supported by the daemon, a HTTP `400 Bad Request` error message is returned. - If you omit the version-prefix, the current version of the API (v1.44) is used. - For example, calling `/info` is the same as calling `/v1.44/info`. Using the + If you omit the version-prefix, the current version of the API (v1.43) is used. + For example, calling `/info` is the same as calling `/v1.43/info`. Using the API without a version-prefix is deprecated and will be removed in a future release. Engine releases in the near future should support this version of the API, @@ -388,16 +388,6 @@ definitions: description: "Create mount point on host if missing" type: "boolean" default: false - ReadOnlyNonRecursive: - description: | - Make the mount non-recursively read-only, but still leave the mount recursive - (unless NonRecursive is set to true in conjunction). - type: "boolean" - default: false - ReadOnlyForceRecursive: - description: "Raise an error if the mount cannot be made recursively read-only." - type: "boolean" - default: false VolumeOptions: description: "Optional configuration for the `volume` type." type: "object" @@ -804,12 +794,6 @@ definitions: 1000000 (1 ms). 0 means inherit. type: "integer" format: "int64" - StartInterval: - description: | - The time to wait between checks in nanoseconds during the start period. - It should be 0 or at least 1000000 (1 ms). 0 means inherit. - type: "integer" - format: "int64" Health: description: | @@ -1313,10 +1297,7 @@ definitions: type: "boolean" x-nullable: true MacAddress: - description: | - MAC address of the container. - - Deprecated: this field is deprecated in API v1.44 and up. Use EndpointSettings.MacAddress instead. + description: "MAC address of the container." type: "string" x-nullable: true OnBuild: @@ -1366,16 +1347,16 @@ definitions: EndpointsConfig: description: | A mapping of network name to endpoint configuration for that network. - The endpoint configuration can be left empty to connect to that - network with no particular endpoint configuration. type: "object" additionalProperties: $ref: "#/definitions/EndpointSettings" example: # putting an example here, instead of using the example values from - # /definitions/EndpointSettings, because EndpointSettings contains - # operational data returned when inspecting a container that we don't - # accept here. + # /definitions/EndpointSettings, because containers/create currently + # does not support attaching to multiple networks, so the example request + # would be confusing if it showed that multiple networks can be contained + # in the EndpointsConfig. + # TODO remove once we support multiple networks on container create (see https://github.com/moby/moby/blob/07e6b843594e061f82baa5fa23c2ff7d536c2a05/daemon/create.go#L323) EndpointsConfig: isolated_nw: IPAMConfig: @@ -1384,22 +1365,19 @@ definitions: LinkLocalIPs: - "169.254.34.68" - "fe80::3468" - MacAddress: "02:42:ac:12:05:02" Links: - "container_1" - "container_2" Aliases: - "server_x" - "server_y" - database_nw: {} NetworkSettings: description: "NetworkSettings exposes the network settings in the API" type: "object" properties: Bridge: - description: | - Name of the default bridge interface when dockerd's --bridge flag is set. + description: Name of the network's bridge (for example, `docker0`). type: "string" example: "docker0" SandboxID: @@ -1409,40 +1387,34 @@ definitions: HairpinMode: description: | Indicates if hairpin NAT should be enabled on the virtual interface. - - Deprecated: This field is never set and will be removed in a future release. type: "boolean" example: false LinkLocalIPv6Address: - description: | - IPv6 unicast address using the link-local prefix. - - Deprecated: This field is never set and will be removed in a future release. + description: IPv6 unicast address using the link-local prefix. type: "string" - example: "" + example: "fe80::42:acff:fe11:1" LinkLocalIPv6PrefixLen: - description: | - Prefix length of the IPv6 unicast address. - - Deprecated: This field is never set and will be removed in a future release. + description: Prefix length of the IPv6 unicast address. type: "integer" - example: "" + example: "64" Ports: $ref: "#/definitions/PortMap" SandboxKey: - description: SandboxKey is the full path of the netns handle + description: SandboxKey identifies the sandbox type: "string" example: "/var/run/docker/netns/8ab54b426c38" + # TODO is SecondaryIPAddresses actually used? SecondaryIPAddresses: - description: "Deprecated: This field is never set and will be removed in a future release." + description: "" type: "array" items: $ref: "#/definitions/Address" x-nullable: true + # TODO is SecondaryIPv6Addresses actually used? SecondaryIPv6Addresses: - description: "Deprecated: This field is never set and will be removed in a future release." + description: "" type: "array" items: $ref: "#/definitions/Address" @@ -1751,15 +1723,10 @@ definitions: The ID of the container that was used to create the image. Depending on how the image was created, this field may be empty. - - **Deprecated**: this field is kept for backward compatibility, but - will be removed in API v1.45. type: "string" + x-nullable: false example: "65974bc86f1770ae4bff79f651ebdbce166ae9aada632ee3fa9af3a264911735" ContainerConfig: - description: | - **Deprecated**: this field is kept for backward compatibility, but - will be removed in API v1.45. $ref: "#/definitions/ContainerConfig" DockerVersion: description: | @@ -1814,7 +1781,13 @@ definitions: description: | Total size of the image including all layers it is composed of. - Deprecated: this field is omitted in API v1.44, but kept for backward compatibility. Use Size instead. + In versions of Docker before v1.10, this field was calculated from + the image itself and all of its parent images. Images are now stored + self-contained, and no longer use a parent-chain, making this field + an equivalent of the Size field. + + > **Deprecated**: this field is kept for backward compatibility, but + > will be removed in API v1.44. type: "integer" format: "int64" example: 1239828 @@ -1856,7 +1829,6 @@ definitions: x-nullable: true ImageSummary: type: "object" - x-go-name: "Summary" required: - Id - ParentId @@ -1953,7 +1925,12 @@ definitions: description: |- Total size of the image including all layers it is composed of. - Deprecated: this field is omitted in API v1.44, but kept for backward compatibility. Use Size instead. + In versions of Docker before v1.10, this field was calculated from + the image itself and all of its parent images. Images are now stored + self-contained, and no longer use a parent-chain, making this field + an equivalent of the Size field. + + Deprecated: this field is kept for backward compatibility, and will be removed in API v1.44. type: "integer" format: "int64" example: 172064416 @@ -2471,11 +2448,6 @@ definitions: example: - "container_1" - "container_2" - MacAddress: - description: | - MAC address for the endpoint on this network. The network driver might ignore this parameter. - type: "string" - example: "02:42:ac:11:00:04" Aliases: type: "array" items: @@ -2526,6 +2498,11 @@ definitions: type: "integer" format: "int64" example: 64 + MacAddress: + description: | + MAC address for the endpoint on this network. + type: "string" + example: "02:42:ac:11:00:04" DriverOpts: description: | DriverOpts is a mapping of driver options and values. These options @@ -2537,21 +2514,6 @@ definitions: example: com.example.some-label: "some-value" com.example.some-other-label: "some-other-value" - DNSNames: - description: | - List of all DNS names an endpoint has on a specific network. This - list is based on the container name, network aliases, container short - ID, and hostname. - - These DNS names are non-fully qualified but can contain several dots. - You can get fully qualified DNS names by appending `.`. - For instance, if container name is `my.ctr` and the network is named - `testnet`, `DNSNames` will contain `my.ctr` and the FQDN will be - `my.ctr.testnet`. - type: array - items: - type: string - example: ["foobar", "server_x", "server_y", "my.ctr"] EndpointIPAMConfig: description: | @@ -3049,6 +3011,8 @@ definitions: Name: "journald" - Type: "Log" Name: "json-file" + - Type: "Log" + Name: "logentries" - Type: "Log" Name: "splunk" - Type: "Log" @@ -3583,32 +3547,6 @@ definitions: Level: type: "string" description: "SELinux level label" - Seccomp: - type: "object" - description: "Options for configuring seccomp on the container" - properties: - Mode: - type: "string" - enum: - - "default" - - "unconfined" - - "custom" - Profile: - description: "The custom seccomp profile as a json object" - type: "string" - AppArmor: - type: "object" - description: "Options for configuring AppArmor on the container" - properties: - Mode: - type: "string" - enum: - - "default" - - "disabled" - NoNewPrivileges: - type: "boolean" - description: "Configuration of the no_new_privs bit in the container" - TTY: description: "Whether a pseudo-TTY should be allocated." type: "boolean" @@ -4003,44 +3941,6 @@ definitions: - "remove" - "orphaned" - ContainerStatus: - type: "object" - description: "represents the status of a container." - properties: - ContainerID: - type: "string" - PID: - type: "integer" - ExitCode: - type: "integer" - - PortStatus: - type: "object" - description: "represents the port status of a task's host ports whose service has published host ports" - properties: - Ports: - type: "array" - items: - $ref: "#/definitions/EndpointPortConfig" - - TaskStatus: - type: "object" - description: "represents the status of a task." - properties: - Timestamp: - type: "string" - format: "dateTime" - State: - $ref: "#/definitions/TaskState" - Message: - type: "string" - Err: - type: "string" - ContainerStatus: - $ref: "#/definitions/ContainerStatus" - PortStatus: - $ref: "#/definitions/PortStatus" - Task: type: "object" properties: @@ -4076,7 +3976,26 @@ definitions: AssignedGenericResources: $ref: "#/definitions/GenericResources" Status: - $ref: "#/definitions/TaskStatus" + type: "object" + properties: + Timestamp: + type: "string" + format: "dateTime" + State: + $ref: "#/definitions/TaskState" + Message: + type: "string" + Err: + type: "string" + ContainerStatus: + type: "object" + properties: + ContainerID: + type: "string" + PID: + type: "integer" + ExitCode: + type: "integer" DesiredState: $ref: "#/definitions/TaskState" JobIteration: @@ -4292,10 +4211,7 @@ definitions: - "stop-first" - "start-first" Networks: - description: | - Specifies which networks the service should attach to. - - Deprecated: This field is deprecated since v1.44. The Networks field in TaskSpec should be used instead. + description: "Specifies which networks the service should attach to." type: "array" items: $ref: "#/definitions/NetworkAttachmentConfig" @@ -4529,7 +4445,6 @@ definitions: ImageDeleteResponseItem: type: "object" - x-go-name: "DeleteResponse" properties: Untagged: description: "The image ID of an image that was untagged" @@ -4538,29 +4453,6 @@ definitions: description: "The image ID of an image that was deleted" type: "string" - ServiceCreateResponse: - type: "object" - description: | - contains the information returned to a client on the - creation of a new service. - properties: - ID: - description: "The ID of the created service." - type: "string" - x-nullable: false - example: "ak7w3gjqoa3kuz8xcpnyy0pvl" - Warnings: - description: | - Optional warning message. - - FIXME(thaJeztah): this should have "omitempty" in the generated type. - type: "array" - x-nullable: true - items: - type: "string" - example: - - "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found" - ServiceUpdateResponse: type: "object" properties: @@ -4570,8 +4462,7 @@ definitions: items: type: "string" example: - Warnings: - - "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found" + Warning: "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found" ContainerSummary: type: "object" @@ -5405,25 +5296,7 @@ definitions: - "WARNING: No memory limit support" - "WARNING: bridge-nf-call-iptables is disabled" - "WARNING: bridge-nf-call-ip6tables is disabled" - CDISpecDirs: - description: | - List of directories where (Container Device Interface) CDI - specifications are located. - - These specifications define vendor-specific modifications to an OCI - runtime specification for a container being created. - An empty list indicates that CDI device injection is disabled. - - Note that since using CDI device injection requires the daemon to have - experimental enabled. For non-experimental daemons an empty list will - always be returned. - type: "array" - items: - type: "string" - example: - - "/etc/cdi" - - "/var/run/cdi" # PluginsInfo is a temp struct holding Plugins name # registered with docker daemon. It is used by Info struct @@ -5461,7 +5334,7 @@ definitions: type: "array" items: type: "string" - example: ["awslogs", "fluentd", "gcplogs", "gelf", "journald", "json-file", "splunk", "syslog"] + example: ["awslogs", "fluentd", "gcplogs", "gelf", "journald", "json-file", "logentries", "splunk", "syslog"] RegistryServiceConfig: @@ -5659,28 +5532,6 @@ definitions: items: type: "string" example: ["--debug", "--systemd-cgroup=false"] - status: - description: | - Information specific to the runtime. - - While this API specification does not define data provided by runtimes, - the following well-known properties may be provided by runtimes: - - `org.opencontainers.runtime-spec.features`: features structure as defined - in the [OCI Runtime Specification](https://github.com/opencontainers/runtime-spec/blob/main/features.md), - in a JSON string representation. - -


- - > **Note**: The information returned in this field, including the - > formatting of values and labels, should not be considered stable, - > and may change without notice. - type: "object" - x-nullable: true - additionalProperties: - type: "string" - example: - "org.opencontainers.runtime-spec.features": "{\"ociVersionMin\":\"1.0.0\",\"ociVersionMax\":\"1.1.0\",\"...\":\"...\"}" Commit: description: | @@ -6565,7 +6416,6 @@ paths: Aliases: - "server_x" - "server_y" - database_nw: {} required: true responses: @@ -6713,7 +6563,7 @@ paths: StopSignal: "SIGTERM" StopTimeout: 10 Created: "2015-01-06T15:47:31.485331387Z" - Driver: "overlay2" + Driver: "devicemapper" ExecIDs: - "b35395de42bc8abd327f9dd65d913b9ba28c74d2f0734eeeae84fa1c616a0fca" - "3fc1232e5cd20c8de182ed81178503dc6437f4e7ef12b52cc5e8de020652f1c4" @@ -8144,7 +7994,6 @@ paths: - `label=key` or `label="key=value"` of an image label - `reference`=(`[:]`) - `since`=(`[:]`, `` or ``) - - `until=` type: "string" - name: "shared-size" in: "query" @@ -8396,7 +8245,7 @@ paths: /images/create: post: summary: "Create an image" - description: "Pull or import an image." + description: "Create an image by either pulling it from a registry or importing it." operationId: "ImageCreate" consumes: - "text/plain" @@ -8747,36 +8596,28 @@ paths: is_official: type: "boolean" is_automated: - description: | - Whether this repository has automated builds enabled. - -


- - > **Deprecated**: This field is deprecated and will always - > be "false" in future. type: "boolean" - example: false name: type: "string" star_count: type: "integer" examples: application/json: - - description: "A minimal Docker image based on Alpine Linux with a complete package index and only 5 MB in size!" - is_official: true + - description: "" + is_official: false is_automated: false - name: "alpine" - star_count: 10093 - - description: "Busybox base image." - is_official: true + name: "wma55/u1210sshd" + star_count: 0 + - description: "" + is_official: false is_automated: false - name: "Busybox base image." - star_count: 3037 - - description: "The PostgreSQL object-relational database system provides reliability and data integrity." - is_official: true + name: "jdswinbank/sshd" + star_count: 0 + - description: "" + is_official: false is_automated: false - name: "postgres" - star_count: 12408 + name: "vgauthier/sshd" + star_count: 0 500: description: "Server error" schema: @@ -8796,13 +8637,9 @@ paths: description: | A JSON encoded value of the filters (a `map[string][]string`) to process on the images list. Available filters: - - `is-automated=(true|false)` (deprecated, see below) + - `is-automated=(true|false)` - `is-official=(true|false)` - `stars=` Matches images that has at least 'number' stars. - - The `is-automated` filter is deprecated. The `is_automated` field has - been deprecated by Docker Hub's search API. Consequently, searching - for `is-automated=true` will yield no results. type: "string" tags: ["Image"] /images/prune: @@ -9195,6 +9032,7 @@ paths: Created: 1466724217 Size: 1092588 SharedSize: 0 + VirtualSize: 1092588 Labels: {} Containers: 1 Containers: @@ -10057,10 +9895,6 @@ paths: example: Id: "22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30" Warning: "" - 400: - description: "bad parameter" - schema: - $ref: "#/definitions/ErrorResponse" 403: description: | Forbidden operation. This happens when trying to create a network named after a pre-defined network, @@ -10090,7 +9924,13 @@ paths: type: "string" CheckDuplicate: description: | - Deprecated: CheckDuplicate is now always enabled. + Check for networks with duplicate names. Since Network is + primarily keyed based on a random ID and not on the name, and + network name is strictly a user-friendly alias to the network + which is uniquely identified using ID, there is no guaranteed + way to check for duplicates. CheckDuplicate is there to provide + a best effort checking of any networks which has the same name + but it is not guaranteed to catch all name collisions. type: "boolean" Driver: description: "Name of the network driver plugin to use." @@ -10158,19 +9998,14 @@ paths: /networks/{id}/connect: post: summary: "Connect a container to a network" - description: "The network must be either a local-scoped network or a swarm-scoped network with the `attachable` option set. A network cannot be re-attached to a running container" operationId: "NetworkConnect" consumes: - "application/json" responses: 200: description: "No error" - 400: - description: "bad parameter" - schema: - $ref: "#/definitions/ErrorResponse" 403: - description: "Operation forbidden" + description: "Operation not supported for swarm scoped networks" schema: $ref: "#/definitions/ErrorResponse" 404: @@ -10205,7 +10040,6 @@ paths: IPAMConfig: IPv4Address: "172.24.56.89" IPv6Address: "2001:db8::5689" - MacAddress: "02:42:ac:12:05:02" tags: ["Network"] /networks/{id}/disconnect: @@ -11199,7 +11033,18 @@ paths: 201: description: "no error" schema: - $ref: "#/definitions/ServiceCreateResponse" + type: "object" + title: "ServiceCreateResponse" + properties: + ID: + description: "The ID of the created service." + type: "string" + Warning: + description: "Optional warning message" + type: "string" + example: + ID: "ak7w3gjqoa3kuz8xcpnyy0pvl" + Warning: "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found" 400: description: "bad parameter" schema: diff --git a/test/integration/vendor/github.com/docker/docker/api/types/auth.go b/test/integration/vendor/github.com/docker/docker/api/types/auth.go new file mode 100644 index 0000000000..9ee329a2fb --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/api/types/auth.go @@ -0,0 +1,7 @@ +package types // import "github.com/docker/docker/api/types" +import "github.com/docker/docker/api/types/registry" + +// AuthConfig contains authorization information for connecting to a Registry. +// +// Deprecated: use github.com/docker/docker/api/types/registry.AuthConfig +type AuthConfig = registry.AuthConfig diff --git a/test/integration/vendor/github.com/docker/docker/api/types/checkpoint/list.go b/test/integration/vendor/github.com/docker/docker/api/types/checkpoint/list.go deleted file mode 100644 index 94a9c0a47d..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/checkpoint/list.go +++ /dev/null @@ -1,7 +0,0 @@ -package checkpoint - -// Summary represents the details of a checkpoint when listing endpoints. -type Summary struct { - // Name is the name of the checkpoint. - Name string -} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/checkpoint/options.go b/test/integration/vendor/github.com/docker/docker/api/types/checkpoint/options.go deleted file mode 100644 index 9477458c24..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/checkpoint/options.go +++ /dev/null @@ -1,19 +0,0 @@ -package checkpoint - -// CreateOptions holds parameters to create a checkpoint from a container. -type CreateOptions struct { - CheckpointID string - CheckpointDir string - Exit bool -} - -// ListOptions holds parameters to list checkpoints for a container. -type ListOptions struct { - CheckpointDir string -} - -// DeleteOptions holds parameters to delete a checkpoint from a container. -type DeleteOptions struct { - CheckpointID string - CheckpointDir string -} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/client.go b/test/integration/vendor/github.com/docker/docker/api/types/client.go index 24b00a2759..d8cd306135 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/client.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/client.go @@ -11,6 +11,44 @@ import ( units "github.com/docker/go-units" ) +// CheckpointCreateOptions holds parameters to create a checkpoint from a container +type CheckpointCreateOptions struct { + CheckpointID string + CheckpointDir string + Exit bool +} + +// CheckpointListOptions holds parameters to list checkpoints for a container +type CheckpointListOptions struct { + CheckpointDir string +} + +// CheckpointDeleteOptions holds parameters to delete a checkpoint from a container +type CheckpointDeleteOptions struct { + CheckpointID string + CheckpointDir string +} + +// ContainerAttachOptions holds parameters to attach to a container. +type ContainerAttachOptions struct { + Stream bool + Stdin bool + Stdout bool + Stderr bool + DetachKeys string + Logs bool +} + +// ContainerCommitOptions holds parameters to commit changes into a container. +type ContainerCommitOptions struct { + Reference string + Comment string + Author string + Changes []string + Pause bool + Config *container.Config +} + // ContainerExecInspect holds information returned by exec inspect. type ContainerExecInspect struct { ExecID string `json:"ID"` @@ -20,6 +58,42 @@ type ContainerExecInspect struct { Pid int } +// ContainerListOptions holds parameters to list containers with. +type ContainerListOptions struct { + Size bool + All bool + Latest bool + Since string + Before string + Limit int + Filters filters.Args +} + +// ContainerLogsOptions holds parameters to filter logs with. +type ContainerLogsOptions struct { + ShowStdout bool + ShowStderr bool + Since string + Until string + Timestamps bool + Follow bool + Tail string + Details bool +} + +// ContainerRemoveOptions holds parameters to remove containers. +type ContainerRemoveOptions struct { + RemoveVolumes bool + RemoveLinks bool + Force bool +} + +// ContainerStartOptions holds parameters to start containers. +type ContainerStartOptions struct { + CheckpointID string + CheckpointDir string +} + // CopyToContainerOptions holds information // about files to copy into a container type CopyToContainerOptions struct { @@ -233,6 +307,14 @@ type ImageSearchOptions struct { Limit int } +// ResizeOptions holds parameters to resize a tty. +// It can be used to resize container ttys and +// exec process ttys too. +type ResizeOptions struct { + Height uint + Width uint +} + // NodeListOptions holds parameters to list nodes with. type NodeListOptions struct { Filters filters.Args @@ -258,6 +340,15 @@ type ServiceCreateOptions struct { QueryRegistry bool } +// ServiceCreateResponse contains the information returned to a client +// on the creation of a new service. +type ServiceCreateResponse struct { + // ID is the ID of the created service. + ID string + // Warnings is a set of non-fatal warning messages to pass on to the user. + Warnings []string `json:",omitempty"` +} + // Values for RegistryAuthFrom in ServiceUpdateOptions const ( RegistryAuthFromSpec = "spec" diff --git a/test/integration/vendor/github.com/docker/docker/api/types/configs.go b/test/integration/vendor/github.com/docker/docker/api/types/configs.go index 945b6efadd..7d5930bbeb 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/configs.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/configs.go @@ -1,5 +1,32 @@ package types // import "github.com/docker/docker/api/types" +import ( + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/network" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" +) + +// configs holds structs used for internal communication between the +// frontend (such as an http server) and the backend (such as the +// docker daemon). + +// ContainerCreateConfig is the parameter set to ContainerCreate() +type ContainerCreateConfig struct { + Name string + Config *container.Config + HostConfig *container.HostConfig + NetworkingConfig *network.NetworkingConfig + Platform *ocispec.Platform + AdjustCPUShares bool +} + +// ContainerRmConfig holds arguments for the container remove +// operation. This struct is used to tell the backend what operations +// to perform. +type ContainerRmConfig struct { + ForceRemove, RemoveVolume, RemoveLink bool +} + // ExecConfig is a small subset of the Config struct that holds the configuration // for the exec feature of docker. type ExecConfig struct { @@ -16,3 +43,25 @@ type ExecConfig struct { WorkingDir string // Working directory Cmd []string // Execution commands and args } + +// PluginRmConfig holds arguments for plugin remove. +type PluginRmConfig struct { + ForceRemove bool +} + +// PluginEnableConfig holds arguments for plugin enable +type PluginEnableConfig struct { + Timeout int +} + +// PluginDisableConfig holds arguments for plugin disable. +type PluginDisableConfig struct { + ForceDisable bool +} + +// NetworkListConfig stores the options available for listing networks +type NetworkListConfig struct { + // TODO(@cpuguy83): naming is hard, this is pulled from what was being used in the router before moving here + Detailed bool + Verbose bool +} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/container/change_response_deprecated.go b/test/integration/vendor/github.com/docker/docker/api/types/container/change_response_deprecated.go new file mode 100644 index 0000000000..6b4b47390d --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/api/types/container/change_response_deprecated.go @@ -0,0 +1,6 @@ +package container + +// ContainerChangeResponseItem change item in response to ContainerChanges operation +// +// Deprecated: use [FilesystemChange]. +type ContainerChangeResponseItem = FilesystemChange diff --git a/test/integration/vendor/github.com/docker/docker/api/types/container/config.go b/test/integration/vendor/github.com/docker/docker/api/types/container/config.go index be41d6315e..077583e66c 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/container/config.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/container/config.go @@ -5,7 +5,6 @@ import ( "time" "github.com/docker/docker/api/types/strslice" - dockerspec "github.com/docker/docker/image/spec/specs-go/v1" "github.com/docker/go-connections/nat" ) @@ -34,7 +33,25 @@ type StopOptions struct { } // HealthConfig holds configuration settings for the HEALTHCHECK feature. -type HealthConfig = dockerspec.HealthcheckConfig +type HealthConfig struct { + // Test is the test to perform to check that the container is healthy. + // An empty slice means to inherit the default. + // The options are: + // {} : inherit healthcheck + // {"NONE"} : disable healthcheck + // {"CMD", args...} : exec arguments directly + // {"CMD-SHELL", command} : run command with system's default shell + Test []string `json:",omitempty"` + + // Zero means to inherit. Durations are expressed as integer nanoseconds. + Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks. + Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung. + StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down. + + // Retries is the number of consecutive failures needed to consider a container as unhealthy. + // Zero means inherit. + Retries int `json:",omitempty"` +} // ExecStartOptions holds the options to start container's exec. type ExecStartOptions struct { @@ -70,13 +87,10 @@ type Config struct { WorkingDir string // Current directory (PWD) in the command will be launched Entrypoint strslice.StrSlice // Entrypoint to run when starting the container NetworkDisabled bool `json:",omitempty"` // Is network disabled - // Mac Address of the container. - // - // Deprecated: this field is deprecated since API v1.44. Use EndpointSettings.MacAddress instead. - MacAddress string `json:",omitempty"` - OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile - Labels map[string]string // List of labels set to this container - StopSignal string `json:",omitempty"` // Signal to stop a container - StopTimeout *int `json:",omitempty"` // Timeout (in seconds) to stop a container - Shell strslice.StrSlice `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT + MacAddress string `json:",omitempty"` // Mac Address of the container + OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile + Labels map[string]string // List of labels set to this container + StopSignal string `json:",omitempty"` // Signal to stop a container + StopTimeout *int `json:",omitempty"` // Timeout (in seconds) to stop a container + Shell strslice.StrSlice `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT } diff --git a/test/integration/vendor/github.com/docker/docker/api/types/container/errors.go b/test/integration/vendor/github.com/docker/docker/api/types/container/errors.go deleted file mode 100644 index 32c978037e..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/container/errors.go +++ /dev/null @@ -1,9 +0,0 @@ -package container - -type errInvalidParameter struct{ error } - -func (e *errInvalidParameter) InvalidParameter() {} - -func (e *errInvalidParameter) Unwrap() error { - return e.error -} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig.go b/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig.go index efb96266e8..d4e6f55375 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig.go @@ -1,12 +1,10 @@ package container // import "github.com/docker/docker/api/types/container" import ( - "fmt" "strings" "github.com/docker/docker/api/types/blkiodev" "github.com/docker/docker/api/types/mount" - "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/strslice" "github.com/docker/go-connections/nat" units "github.com/docker/go-units" @@ -134,12 +132,12 @@ type NetworkMode string // IsNone indicates whether container isn't using a network stack. func (n NetworkMode) IsNone() bool { - return n == network.NetworkNone + return n == "none" } // IsDefault indicates whether container uses the default network stack. func (n NetworkMode) IsDefault() bool { - return n == network.NetworkDefault + return n == "default" } // IsPrivate indicates whether container uses its private network stack. @@ -273,42 +271,33 @@ type DeviceMapping struct { // RestartPolicy represents the restart policies of the container. type RestartPolicy struct { - Name RestartPolicyMode + Name string MaximumRetryCount int } -type RestartPolicyMode string - -const ( - RestartPolicyDisabled RestartPolicyMode = "no" - RestartPolicyAlways RestartPolicyMode = "always" - RestartPolicyOnFailure RestartPolicyMode = "on-failure" - RestartPolicyUnlessStopped RestartPolicyMode = "unless-stopped" -) - // IsNone indicates whether the container has the "no" restart policy. // This means the container will not automatically restart when exiting. func (rp *RestartPolicy) IsNone() bool { - return rp.Name == RestartPolicyDisabled || rp.Name == "" + return rp.Name == "no" || rp.Name == "" } // IsAlways indicates whether the container has the "always" restart policy. // This means the container will automatically restart regardless of the exit status. func (rp *RestartPolicy) IsAlways() bool { - return rp.Name == RestartPolicyAlways + return rp.Name == "always" } // IsOnFailure indicates whether the container has the "on-failure" restart policy. // This means the container will automatically restart of exiting with a non-zero exit status. func (rp *RestartPolicy) IsOnFailure() bool { - return rp.Name == RestartPolicyOnFailure + return rp.Name == "on-failure" } // IsUnlessStopped indicates whether the container has the // "unless-stopped" restart policy. This means the container will // automatically restart unless user has put it to stopped state. func (rp *RestartPolicy) IsUnlessStopped() bool { - return rp.Name == RestartPolicyUnlessStopped + return rp.Name == "unless-stopped" } // IsSame compares two RestartPolicy to see if they are the same @@ -316,33 +305,6 @@ func (rp *RestartPolicy) IsSame(tp *RestartPolicy) bool { return rp.Name == tp.Name && rp.MaximumRetryCount == tp.MaximumRetryCount } -// ValidateRestartPolicy validates the given RestartPolicy. -func ValidateRestartPolicy(policy RestartPolicy) error { - switch policy.Name { - case RestartPolicyAlways, RestartPolicyUnlessStopped, RestartPolicyDisabled: - if policy.MaximumRetryCount != 0 { - msg := "invalid restart policy: maximum retry count can only be used with 'on-failure'" - if policy.MaximumRetryCount < 0 { - msg += " and cannot be negative" - } - return &errInvalidParameter{fmt.Errorf(msg)} - } - return nil - case RestartPolicyOnFailure: - if policy.MaximumRetryCount < 0 { - return &errInvalidParameter{fmt.Errorf("invalid restart policy: maximum retry count cannot be negative")} - } - return nil - case "": - // Versions before v25.0.0 created an empty restart-policy "name" as - // default. Allow an empty name with "any" MaximumRetryCount for - // backward-compatibility. - return nil - default: - return &errInvalidParameter{fmt.Errorf("invalid restart policy: unknown policy '%s'; use one of '%s', '%s', '%s', or '%s'", policy.Name, RestartPolicyDisabled, RestartPolicyAlways, RestartPolicyOnFailure, RestartPolicyUnlessStopped)} - } -} - // LogMode is a type to define the available modes for logging // These modes affect how logs are handled when log messages start piling up. type LogMode string diff --git a/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig_unix.go b/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig_unix.go index 4213292378..24c4fa8d90 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig_unix.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig_unix.go @@ -1,9 +1,8 @@ //go:build !windows +// +build !windows package container // import "github.com/docker/docker/api/types/container" -import "github.com/docker/docker/api/types/network" - // IsValid indicates if an isolation technology is valid func (i Isolation) IsValid() bool { return i.IsDefault() @@ -12,15 +11,15 @@ func (i Isolation) IsValid() bool { // NetworkName returns the name of the network stack. func (n NetworkMode) NetworkName() string { if n.IsBridge() { - return network.NetworkBridge + return "bridge" } else if n.IsHost() { - return network.NetworkHost + return "host" } else if n.IsContainer() { return "container" } else if n.IsNone() { - return network.NetworkNone + return "none" } else if n.IsDefault() { - return network.NetworkDefault + return "default" } else if n.IsUserDefined() { return n.UserDefined() } @@ -29,12 +28,12 @@ func (n NetworkMode) NetworkName() string { // IsBridge indicates whether container uses the bridge network stack func (n NetworkMode) IsBridge() bool { - return n == network.NetworkBridge + return n == "bridge" } // IsHost indicates whether container uses the host network stack. func (n NetworkMode) IsHost() bool { - return n == network.NetworkHost + return n == "host" } // IsUserDefined indicates user-created network diff --git a/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig_windows.go b/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig_windows.go index 154667f4f0..99f803a5bb 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig_windows.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/container/hostconfig_windows.go @@ -1,11 +1,9 @@ package container // import "github.com/docker/docker/api/types/container" -import "github.com/docker/docker/api/types/network" - // IsBridge indicates whether container uses the bridge network stack // in windows it is given the name NAT func (n NetworkMode) IsBridge() bool { - return n == network.NetworkNat + return n == "nat" } // IsHost indicates whether container uses the host network stack. @@ -27,11 +25,11 @@ func (i Isolation) IsValid() bool { // NetworkName returns the name of the network stack. func (n NetworkMode) NetworkName() string { if n.IsDefault() { - return network.NetworkDefault + return "default" } else if n.IsBridge() { - return network.NetworkNat + return "nat" } else if n.IsNone() { - return network.NetworkNone + return "none" } else if n.IsContainer() { return "container" } else if n.IsUserDefined() { diff --git a/test/integration/vendor/github.com/docker/docker/api/types/container/options.go b/test/integration/vendor/github.com/docker/docker/api/types/container/options.go deleted file mode 100644 index 7a23005769..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/container/options.go +++ /dev/null @@ -1,67 +0,0 @@ -package container - -import "github.com/docker/docker/api/types/filters" - -// ResizeOptions holds parameters to resize a TTY. -// It can be used to resize container TTYs and -// exec process TTYs too. -type ResizeOptions struct { - Height uint - Width uint -} - -// AttachOptions holds parameters to attach to a container. -type AttachOptions struct { - Stream bool - Stdin bool - Stdout bool - Stderr bool - DetachKeys string - Logs bool -} - -// CommitOptions holds parameters to commit changes into a container. -type CommitOptions struct { - Reference string - Comment string - Author string - Changes []string - Pause bool - Config *Config -} - -// RemoveOptions holds parameters to remove containers. -type RemoveOptions struct { - RemoveVolumes bool - RemoveLinks bool - Force bool -} - -// StartOptions holds parameters to start containers. -type StartOptions struct { - CheckpointID string - CheckpointDir string -} - -// ListOptions holds parameters to list containers with. -type ListOptions struct { - Size bool - All bool - Latest bool - Since string - Before string - Limit int - Filters filters.Args -} - -// LogsOptions holds parameters to filter logs with. -type LogsOptions struct { - ShowStdout bool - ShowStderr bool - Since string - Until string - Timestamps bool - Follow bool - Tail string - Details bool -} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/events/events.go b/test/integration/vendor/github.com/docker/docker/api/types/events/events.go index 6dbcd92235..9fe07e26fd 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/events/events.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/events/events.go @@ -1,7 +1,7 @@ package events // import "github.com/docker/docker/api/types/events" // Type is used for event-types. -type Type string +type Type = string // List of known event types. const ( @@ -18,86 +18,6 @@ const ( VolumeEventType Type = "volume" // VolumeEventType is the event type that volumes generate. ) -// Action is used for event-actions. -type Action string - -const ( - ActionCreate Action = "create" - ActionStart Action = "start" - ActionRestart Action = "restart" - ActionStop Action = "stop" - ActionCheckpoint Action = "checkpoint" - ActionPause Action = "pause" - ActionUnPause Action = "unpause" - ActionAttach Action = "attach" - ActionDetach Action = "detach" - ActionResize Action = "resize" - ActionUpdate Action = "update" - ActionRename Action = "rename" - ActionKill Action = "kill" - ActionDie Action = "die" - ActionOOM Action = "oom" - ActionDestroy Action = "destroy" - ActionRemove Action = "remove" - ActionCommit Action = "commit" - ActionTop Action = "top" - ActionCopy Action = "copy" - ActionArchivePath Action = "archive-path" - ActionExtractToDir Action = "extract-to-dir" - ActionExport Action = "export" - ActionImport Action = "import" - ActionSave Action = "save" - ActionLoad Action = "load" - ActionTag Action = "tag" - ActionUnTag Action = "untag" - ActionPush Action = "push" - ActionPull Action = "pull" - ActionPrune Action = "prune" - ActionDelete Action = "delete" - ActionEnable Action = "enable" - ActionDisable Action = "disable" - ActionConnect Action = "connect" - ActionDisconnect Action = "disconnect" - ActionReload Action = "reload" - ActionMount Action = "mount" - ActionUnmount Action = "unmount" - - // ActionExecCreate is the prefix used for exec_create events. These - // event-actions are commonly followed by a colon and space (": "), - // and the command that's defined for the exec, for example: - // - // exec_create: /bin/sh -c 'echo hello' - // - // This is far from ideal; it's a compromise to allow filtering and - // to preserve backward-compatibility. - ActionExecCreate Action = "exec_create" - // ActionExecStart is the prefix used for exec_create events. These - // event-actions are commonly followed by a colon and space (": "), - // and the command that's defined for the exec, for example: - // - // exec_start: /bin/sh -c 'echo hello' - // - // This is far from ideal; it's a compromise to allow filtering and - // to preserve backward-compatibility. - ActionExecStart Action = "exec_start" - ActionExecDie Action = "exec_die" - ActionExecDetach Action = "exec_detach" - - // ActionHealthStatus is the prefix to use for health_status events. - // - // Health-status events can either have a pre-defined status, in which - // case the "health_status" action is followed by a colon, or can be - // "free-form", in which case they're followed by the output of the - // health-check output. - // - // This is far form ideal, and a compromise to allow filtering, and - // to preserve backward-compatibility. - ActionHealthStatus Action = "health_status" - ActionHealthStatusRunning Action = "health_status: running" - ActionHealthStatusHealthy Action = "health_status: healthy" - ActionHealthStatusUnhealthy Action = "health_status: unhealthy" -) - // Actor describes something that generates events, // like a container, or a network, or a volume. // It has a defined name and a set of attributes. @@ -117,7 +37,7 @@ type Message struct { From string `json:"from,omitempty"` // Deprecated: use Actor.Attributes["image"] instead. Type Type - Action Action + Action string Actor Actor // Engine events are local scope. Cluster events are swarm scope. Scope string `json:"scope,omitempty"` diff --git a/test/integration/vendor/github.com/docker/docker/api/types/image/image.go b/test/integration/vendor/github.com/docker/docker/api/types/image/image.go deleted file mode 100644 index 167df28c7b..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/image/image.go +++ /dev/null @@ -1,9 +0,0 @@ -package image - -import "time" - -// Metadata contains engine-local data about the image. -type Metadata struct { - // LastTagTime is the date and time at which the image was last tagged. - LastTagTime time.Time `json:",omitempty"` -} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/image/delete_response.go b/test/integration/vendor/github.com/docker/docker/api/types/image_delete_response_item.go similarity index 68% rename from test/integration/vendor/github.com/docker/docker/api/types/image/delete_response.go rename to test/integration/vendor/github.com/docker/docker/api/types/image_delete_response_item.go index 998620dc6a..b9a65a0d8e 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/image/delete_response.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/image_delete_response_item.go @@ -1,11 +1,11 @@ -package image +package types // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command -// DeleteResponse delete response -// swagger:model DeleteResponse -type DeleteResponse struct { +// ImageDeleteResponseItem image delete response item +// swagger:model ImageDeleteResponseItem +type ImageDeleteResponseItem struct { // The image ID of an image that was deleted Deleted string `json:"Deleted,omitempty"` diff --git a/test/integration/vendor/github.com/docker/docker/api/types/image/summary.go b/test/integration/vendor/github.com/docker/docker/api/types/image_summary.go similarity index 85% rename from test/integration/vendor/github.com/docker/docker/api/types/image/summary.go rename to test/integration/vendor/github.com/docker/docker/api/types/image_summary.go index f1e3e2ef01..0f6f144840 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/image/summary.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/image_summary.go @@ -1,11 +1,11 @@ -package image +package types // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command -// Summary summary -// swagger:model Summary -type Summary struct { +// ImageSummary image summary +// swagger:model ImageSummary +type ImageSummary struct { // Number of containers using this image. Includes both stopped and running // containers. @@ -84,6 +84,11 @@ type Summary struct { // Total size of the image including all layers it is composed of. // - // Deprecated: this field is omitted in API v1.44, but kept for backward compatibility. Use Size instead. + // In versions of Docker before v1.10, this field was calculated from + // the image itself and all of its parent images. Images are now stored + // self-contained, and no longer use a parent-chain, making this field + // an equivalent of the Size field. + // + // Deprecated: this field is kept for backward compatibility, and will be removed in API v1.44. VirtualSize int64 `json:"VirtualSize,omitempty"` } diff --git a/test/integration/vendor/github.com/docker/docker/api/types/mount/mount.go b/test/integration/vendor/github.com/docker/docker/api/types/mount/mount.go index 57edf2ef18..ac4ce62231 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/mount/mount.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/mount/mount.go @@ -29,7 +29,7 @@ type Mount struct { // Source is not supported for tmpfs (must be an empty value) Source string `json:",omitempty"` Target string `json:",omitempty"` - ReadOnly bool `json:",omitempty"` // attempts recursive read-only if possible + ReadOnly bool `json:",omitempty"` Consistency Consistency `json:",omitempty"` BindOptions *BindOptions `json:",omitempty"` @@ -85,11 +85,6 @@ type BindOptions struct { Propagation Propagation `json:",omitempty"` NonRecursive bool `json:",omitempty"` CreateMountpoint bool `json:",omitempty"` - // ReadOnlyNonRecursive makes the mount non-recursively read-only, but still leaves the mount recursive - // (unless NonRecursive is set to true in conjunction). - ReadOnlyNonRecursive bool `json:",omitempty"` - // ReadOnlyForceRecursive raises an error if the mount cannot be made recursively read-only. - ReadOnlyForceRecursive bool `json:",omitempty"` } // VolumeOptions represents the options for a mount of type volume. diff --git a/test/integration/vendor/github.com/docker/docker/api/types/network/endpoint.go b/test/integration/vendor/github.com/docker/docker/api/types/network/endpoint.go deleted file mode 100644 index 4b3c06a52b..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/network/endpoint.go +++ /dev/null @@ -1,144 +0,0 @@ -package network - -import ( - "errors" - "fmt" - "net" - - "github.com/docker/docker/internal/multierror" -) - -// EndpointSettings stores the network endpoint details -type EndpointSettings struct { - // Configurations - IPAMConfig *EndpointIPAMConfig - Links []string - Aliases []string // Aliases holds the list of extra, user-specified DNS names for this endpoint. - MacAddress string - // Operational data - NetworkID string - EndpointID string - Gateway string - IPAddress string - IPPrefixLen int - IPv6Gateway string - GlobalIPv6Address string - GlobalIPv6PrefixLen int - DriverOpts map[string]string - // DNSNames holds all the (non fully qualified) DNS names associated to this endpoint. First entry is used to - // generate PTR records. - DNSNames []string -} - -// Copy makes a deep copy of `EndpointSettings` -func (es *EndpointSettings) Copy() *EndpointSettings { - epCopy := *es - if es.IPAMConfig != nil { - epCopy.IPAMConfig = es.IPAMConfig.Copy() - } - - if es.Links != nil { - links := make([]string, 0, len(es.Links)) - epCopy.Links = append(links, es.Links...) - } - - if es.Aliases != nil { - aliases := make([]string, 0, len(es.Aliases)) - epCopy.Aliases = append(aliases, es.Aliases...) - } - - if len(es.DNSNames) > 0 { - epCopy.DNSNames = make([]string, len(es.DNSNames)) - copy(epCopy.DNSNames, es.DNSNames) - } - - return &epCopy -} - -// EndpointIPAMConfig represents IPAM configurations for the endpoint -type EndpointIPAMConfig struct { - IPv4Address string `json:",omitempty"` - IPv6Address string `json:",omitempty"` - LinkLocalIPs []string `json:",omitempty"` -} - -// Copy makes a copy of the endpoint ipam config -func (cfg *EndpointIPAMConfig) Copy() *EndpointIPAMConfig { - cfgCopy := *cfg - cfgCopy.LinkLocalIPs = make([]string, 0, len(cfg.LinkLocalIPs)) - cfgCopy.LinkLocalIPs = append(cfgCopy.LinkLocalIPs, cfg.LinkLocalIPs...) - return &cfgCopy -} - -// NetworkSubnet describes a user-defined subnet for a specific network. It's only used to validate if an -// EndpointIPAMConfig is valid for a specific network. -type NetworkSubnet interface { - // Contains checks whether the NetworkSubnet contains [addr]. - Contains(addr net.IP) bool - // IsStatic checks whether the subnet was statically allocated (ie. user-defined). - IsStatic() bool -} - -// IsInRange checks whether static IP addresses are valid in a specific network. -func (cfg *EndpointIPAMConfig) IsInRange(v4Subnets []NetworkSubnet, v6Subnets []NetworkSubnet) error { - var errs []error - - if err := validateEndpointIPAddress(cfg.IPv4Address, v4Subnets); err != nil { - errs = append(errs, err) - } - if err := validateEndpointIPAddress(cfg.IPv6Address, v6Subnets); err != nil { - errs = append(errs, err) - } - - return multierror.Join(errs...) -} - -func validateEndpointIPAddress(epAddr string, ipamSubnets []NetworkSubnet) error { - if epAddr == "" { - return nil - } - - var staticSubnet bool - parsedAddr := net.ParseIP(epAddr) - for _, subnet := range ipamSubnets { - if subnet.IsStatic() { - staticSubnet = true - if subnet.Contains(parsedAddr) { - return nil - } - } - } - - if staticSubnet { - return fmt.Errorf("no configured subnet or ip-range contain the IP address %s", epAddr) - } - - return errors.New("user specified IP address is supported only when connecting to networks with user configured subnets") -} - -// Validate checks whether cfg is valid. -func (cfg *EndpointIPAMConfig) Validate() error { - if cfg == nil { - return nil - } - - var errs []error - - if cfg.IPv4Address != "" { - if addr := net.ParseIP(cfg.IPv4Address); addr == nil || addr.To4() == nil || addr.IsUnspecified() { - errs = append(errs, fmt.Errorf("invalid IPv4 address: %s", cfg.IPv4Address)) - } - } - if cfg.IPv6Address != "" { - if addr := net.ParseIP(cfg.IPv6Address); addr == nil || addr.To4() != nil || addr.IsUnspecified() { - errs = append(errs, fmt.Errorf("invalid IPv6 address: %s", cfg.IPv6Address)) - } - } - for _, addr := range cfg.LinkLocalIPs { - if parsed := net.ParseIP(addr); parsed == nil || parsed.IsUnspecified() { - errs = append(errs, fmt.Errorf("invalid link-local IP address: %s", addr)) - } - } - - return multierror.Join(errs...) -} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/network/ipam.go b/test/integration/vendor/github.com/docker/docker/api/types/network/ipam.go deleted file mode 100644 index 17f370ef7e..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/network/ipam.go +++ /dev/null @@ -1,151 +0,0 @@ -package network - -import ( - "errors" - "fmt" - "net/netip" - - "github.com/docker/docker/internal/multierror" -) - -// IPAM represents IP Address Management -type IPAM struct { - Driver string - Options map[string]string // Per network IPAM driver options - Config []IPAMConfig -} - -// IPAMConfig represents IPAM configurations -type IPAMConfig struct { - Subnet string `json:",omitempty"` - IPRange string `json:",omitempty"` - Gateway string `json:",omitempty"` - AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"` -} - -type ipFamily string - -const ( - ip4 ipFamily = "IPv4" - ip6 ipFamily = "IPv6" -) - -// HasIPv6Subnets checks whether there's any IPv6 subnets in the ipam parameter. It ignores any invalid Subnet and nil -// ipam. -func HasIPv6Subnets(ipam *IPAM) bool { - if ipam == nil { - return false - } - - for _, cfg := range ipam.Config { - subnet, err := netip.ParsePrefix(cfg.Subnet) - if err != nil { - continue - } - - if subnet.Addr().Is6() { - return true - } - } - - return false -} - -// ValidateIPAM checks whether the network's IPAM passed as argument is valid. It returns a joinError of the list of -// errors found. -func ValidateIPAM(ipam *IPAM) error { - if ipam == nil { - return nil - } - - var errs []error - for _, cfg := range ipam.Config { - subnet, err := netip.ParsePrefix(cfg.Subnet) - if err != nil { - errs = append(errs, fmt.Errorf("invalid subnet %s: invalid CIDR block notation", cfg.Subnet)) - continue - } - subnetFamily := ip4 - if subnet.Addr().Is6() { - subnetFamily = ip6 - } - - if subnet != subnet.Masked() { - errs = append(errs, fmt.Errorf("invalid subnet %s: it should be %s", subnet, subnet.Masked())) - } - - if ipRangeErrs := validateIPRange(cfg.IPRange, subnet, subnetFamily); len(ipRangeErrs) > 0 { - errs = append(errs, ipRangeErrs...) - } - - if err := validateAddress(cfg.Gateway, subnet, subnetFamily); err != nil { - errs = append(errs, fmt.Errorf("invalid gateway %s: %w", cfg.Gateway, err)) - } - - for auxName, aux := range cfg.AuxAddress { - if err := validateAddress(aux, subnet, subnetFamily); err != nil { - errs = append(errs, fmt.Errorf("invalid auxiliary address %s: %w", auxName, err)) - } - } - } - - if err := multierror.Join(errs...); err != nil { - return fmt.Errorf("invalid network config:\n%w", err) - } - - return nil -} - -func validateIPRange(ipRange string, subnet netip.Prefix, subnetFamily ipFamily) []error { - if ipRange == "" { - return nil - } - prefix, err := netip.ParsePrefix(ipRange) - if err != nil { - return []error{fmt.Errorf("invalid ip-range %s: invalid CIDR block notation", ipRange)} - } - family := ip4 - if prefix.Addr().Is6() { - family = ip6 - } - - if family != subnetFamily { - return []error{fmt.Errorf("invalid ip-range %s: parent subnet is an %s block", ipRange, subnetFamily)} - } - - var errs []error - if prefix.Bits() < subnet.Bits() { - errs = append(errs, fmt.Errorf("invalid ip-range %s: CIDR block is bigger than its parent subnet %s", ipRange, subnet)) - } - if prefix != prefix.Masked() { - errs = append(errs, fmt.Errorf("invalid ip-range %s: it should be %s", prefix, prefix.Masked())) - } - if !subnet.Overlaps(prefix) { - errs = append(errs, fmt.Errorf("invalid ip-range %s: parent subnet %s doesn't contain ip-range", ipRange, subnet)) - } - - return errs -} - -func validateAddress(address string, subnet netip.Prefix, subnetFamily ipFamily) error { - if address == "" { - return nil - } - addr, err := netip.ParseAddr(address) - if err != nil { - return errors.New("invalid address") - } - family := ip4 - if addr.Is6() { - family = ip6 - } - - if family != subnetFamily { - return fmt.Errorf("parent subnet is an %s block", subnetFamily) - } - if !subnet.Contains(addr) { - return fmt.Errorf("parent subnet %s doesn't contain this address", subnet) - } - - return nil -} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/network/network.go b/test/integration/vendor/github.com/docker/docker/api/types/network/network.go index f1f300f3d7..437b184c67 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/network/network.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/network/network.go @@ -1,34 +1,69 @@ package network // import "github.com/docker/docker/api/types/network" - import ( "github.com/docker/docker/api/types/filters" ) -const ( - // NetworkDefault is a platform-independent alias to choose the platform-specific default network stack. - NetworkDefault = "default" - // NetworkHost is the name of the predefined network used when the NetworkMode host is selected (only available on Linux) - NetworkHost = "host" - // NetworkNone is the name of the predefined network used when the NetworkMode none is selected (available on both Linux and Windows) - NetworkNone = "none" - // NetworkBridge is the name of the default network on Linux - NetworkBridge = "bridge" - // NetworkNat is the name of the default network on Windows - NetworkNat = "nat" -) - // Address represents an IP address type Address struct { Addr string PrefixLen int } +// IPAM represents IP Address Management +type IPAM struct { + Driver string + Options map[string]string // Per network IPAM driver options + Config []IPAMConfig +} + +// IPAMConfig represents IPAM configurations +type IPAMConfig struct { + Subnet string `json:",omitempty"` + IPRange string `json:",omitempty"` + Gateway string `json:",omitempty"` + AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"` +} + +// EndpointIPAMConfig represents IPAM configurations for the endpoint +type EndpointIPAMConfig struct { + IPv4Address string `json:",omitempty"` + IPv6Address string `json:",omitempty"` + LinkLocalIPs []string `json:",omitempty"` +} + +// Copy makes a copy of the endpoint ipam config +func (cfg *EndpointIPAMConfig) Copy() *EndpointIPAMConfig { + cfgCopy := *cfg + cfgCopy.LinkLocalIPs = make([]string, 0, len(cfg.LinkLocalIPs)) + cfgCopy.LinkLocalIPs = append(cfgCopy.LinkLocalIPs, cfg.LinkLocalIPs...) + return &cfgCopy +} + // PeerInfo represents one peer of an overlay network type PeerInfo struct { Name string IP string } +// EndpointSettings stores the network endpoint details +type EndpointSettings struct { + // Configurations + IPAMConfig *EndpointIPAMConfig + Links []string + Aliases []string + // Operational data + NetworkID string + EndpointID string + Gateway string + IPAddress string + IPPrefixLen int + IPv6Gateway string + GlobalIPv6Address string + GlobalIPv6PrefixLen int + MacAddress string + DriverOpts map[string]string +} + // Task carries the information about one backend task type Task struct { Name string @@ -45,6 +80,25 @@ type ServiceInfo struct { Tasks []Task } +// Copy makes a deep copy of `EndpointSettings` +func (es *EndpointSettings) Copy() *EndpointSettings { + epCopy := *es + if es.IPAMConfig != nil { + epCopy.IPAMConfig = es.IPAMConfig.Copy() + } + + if es.Links != nil { + links := make([]string, 0, len(es.Links)) + epCopy.Links = append(links, es.Links...) + } + + if es.Aliases != nil { + aliases := make([]string, 0, len(es.Aliases)) + epCopy.Aliases = append(aliases, es.Aliases...) + } + return &epCopy +} + // NetworkingConfig represents the container's networking configuration for each of its interfaces // Carries the networking configs specified in the `docker run` and `docker network connect` commands type NetworkingConfig struct { diff --git a/test/integration/vendor/github.com/docker/docker/api/types/registry/registry.go b/test/integration/vendor/github.com/docker/docker/api/types/registry/registry.go index 05cb31075f..b83f5d7b2e 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/registry/registry.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/registry/registry.go @@ -92,9 +92,7 @@ type SearchResult struct { IsOfficial bool `json:"is_official"` // Name is the name of the repository Name string `json:"name"` - // IsAutomated indicates whether the result is automated. - // - // Deprecated: the "is_automated" field is deprecated and will always be "false" in the future. + // IsAutomated indicates whether the result is automated IsAutomated bool `json:"is_automated"` // Description is a textual description of the repository Description string `json:"description"` diff --git a/test/integration/vendor/github.com/docker/docker/api/types/swarm/service_update_response.go b/test/integration/vendor/github.com/docker/docker/api/types/service_update_response.go similarity index 95% rename from test/integration/vendor/github.com/docker/docker/api/types/swarm/service_update_response.go rename to test/integration/vendor/github.com/docker/docker/api/types/service_update_response.go index 0417467dae..74ea64b1bb 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/swarm/service_update_response.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/service_update_response.go @@ -1,4 +1,4 @@ -package swarm +package types // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command diff --git a/test/integration/vendor/github.com/docker/docker/api/types/swarm/container.go b/test/integration/vendor/github.com/docker/docker/api/types/swarm/container.go index 65f61d2d20..af5e1c0bc2 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/swarm/container.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/swarm/container.go @@ -32,42 +32,6 @@ type SELinuxContext struct { Level string } -// SeccompMode is the type used for the enumeration of possible seccomp modes -// in SeccompOpts -type SeccompMode string - -const ( - SeccompModeDefault SeccompMode = "default" - SeccompModeUnconfined SeccompMode = "unconfined" - SeccompModeCustom SeccompMode = "custom" -) - -// SeccompOpts defines the options for configuring seccomp on a swarm-managed -// container. -type SeccompOpts struct { - // Mode is the SeccompMode used for the container. - Mode SeccompMode `json:",omitempty"` - // Profile is the custom seccomp profile as a json object to be used with - // the container. Mode should be set to SeccompModeCustom when using a - // custom profile in this manner. - Profile []byte `json:",omitempty"` -} - -// AppArmorMode is type used for the enumeration of possible AppArmor modes in -// AppArmorOpts -type AppArmorMode string - -const ( - AppArmorModeDefault AppArmorMode = "default" - AppArmorModeDisabled AppArmorMode = "disabled" -) - -// AppArmorOpts defines the options for configuring AppArmor on a swarm-managed -// container. Currently, custom AppArmor profiles are not supported. -type AppArmorOpts struct { - Mode AppArmorMode `json:",omitempty"` -} - // CredentialSpec for managed service account (Windows only) type CredentialSpec struct { Config string @@ -77,11 +41,8 @@ type CredentialSpec struct { // Privileges defines the security options for the container. type Privileges struct { - CredentialSpec *CredentialSpec - SELinuxContext *SELinuxContext - Seccomp *SeccompOpts `json:",omitempty"` - AppArmor *AppArmorOpts `json:",omitempty"` - NoNewPrivileges bool + CredentialSpec *CredentialSpec + SELinuxContext *SELinuxContext } // ContainerSpec represents the spec of a container. diff --git a/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/gen.go b/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/gen.go index 292bd7afc8..98c2806c31 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/gen.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/gen.go @@ -1,3 +1,3 @@ -//go:generate protoc --gogofaster_out=import_path=github.com/docker/docker/api/types/swarm/runtime:. plugin.proto +//go:generate protoc -I . --gogofast_out=import_path=github.com/docker/docker/api/types/swarm/runtime:. plugin.proto package runtime // import "github.com/docker/docker/api/types/swarm/runtime" diff --git a/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.pb.go b/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.pb.go index 32aaf0d519..e45045866a 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.pb.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.pb.go @@ -1,15 +1,23 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: plugin.proto +/* + Package runtime is a generated protocol buffer package. + + It is generated from these files: + plugin.proto + + It has these top-level messages: + PluginSpec + PluginPrivilege +*/ package runtime -import ( - fmt "fmt" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import io "io" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -20,50 +28,22 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package // PluginSpec defines the base payload which clients can specify for creating // a service with the plugin runtime. type PluginSpec struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Remote string `protobuf:"bytes,2,opt,name=remote,proto3" json:"remote,omitempty"` - Privileges []*PluginPrivilege `protobuf:"bytes,3,rep,name=privileges,proto3" json:"privileges,omitempty"` + Privileges []*PluginPrivilege `protobuf:"bytes,3,rep,name=privileges" json:"privileges,omitempty"` Disabled bool `protobuf:"varint,4,opt,name=disabled,proto3" json:"disabled,omitempty"` - Env []string `protobuf:"bytes,5,rep,name=env,proto3" json:"env,omitempty"` -} - -func (m *PluginSpec) Reset() { *m = PluginSpec{} } -func (m *PluginSpec) String() string { return proto.CompactTextString(m) } -func (*PluginSpec) ProtoMessage() {} -func (*PluginSpec) Descriptor() ([]byte, []int) { - return fileDescriptor_22a625af4bc1cc87, []int{0} -} -func (m *PluginSpec) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PluginSpec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PluginSpec.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *PluginSpec) XXX_Merge(src proto.Message) { - xxx_messageInfo_PluginSpec.Merge(m, src) -} -func (m *PluginSpec) XXX_Size() int { - return m.Size() -} -func (m *PluginSpec) XXX_DiscardUnknown() { - xxx_messageInfo_PluginSpec.DiscardUnknown(m) + Env []string `protobuf:"bytes,5,rep,name=env" json:"env,omitempty"` } -var xxx_messageInfo_PluginSpec proto.InternalMessageInfo +func (m *PluginSpec) Reset() { *m = PluginSpec{} } +func (m *PluginSpec) String() string { return proto.CompactTextString(m) } +func (*PluginSpec) ProtoMessage() {} +func (*PluginSpec) Descriptor() ([]byte, []int) { return fileDescriptorPlugin, []int{0} } func (m *PluginSpec) GetName() string { if m != nil { @@ -105,41 +85,13 @@ func (m *PluginSpec) GetEnv() []string { type PluginPrivilege struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - Value []string `protobuf:"bytes,3,rep,name=value,proto3" json:"value,omitempty"` + Value []string `protobuf:"bytes,3,rep,name=value" json:"value,omitempty"` } -func (m *PluginPrivilege) Reset() { *m = PluginPrivilege{} } -func (m *PluginPrivilege) String() string { return proto.CompactTextString(m) } -func (*PluginPrivilege) ProtoMessage() {} -func (*PluginPrivilege) Descriptor() ([]byte, []int) { - return fileDescriptor_22a625af4bc1cc87, []int{1} -} -func (m *PluginPrivilege) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PluginPrivilege) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PluginPrivilege.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *PluginPrivilege) XXX_Merge(src proto.Message) { - xxx_messageInfo_PluginPrivilege.Merge(m, src) -} -func (m *PluginPrivilege) XXX_Size() int { - return m.Size() -} -func (m *PluginPrivilege) XXX_DiscardUnknown() { - xxx_messageInfo_PluginPrivilege.DiscardUnknown(m) -} - -var xxx_messageInfo_PluginPrivilege proto.InternalMessageInfo +func (m *PluginPrivilege) Reset() { *m = PluginPrivilege{} } +func (m *PluginPrivilege) String() string { return proto.CompactTextString(m) } +func (*PluginPrivilege) ProtoMessage() {} +func (*PluginPrivilege) Descriptor() ([]byte, []int) { return fileDescriptorPlugin, []int{1} } func (m *PluginPrivilege) GetName() string { if m != nil { @@ -166,32 +118,10 @@ func init() { proto.RegisterType((*PluginSpec)(nil), "PluginSpec") proto.RegisterType((*PluginPrivilege)(nil), "PluginPrivilege") } - -func init() { proto.RegisterFile("plugin.proto", fileDescriptor_22a625af4bc1cc87) } - -var fileDescriptor_22a625af4bc1cc87 = []byte{ - // 225 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0xc8, 0x29, 0x4d, - 0xcf, 0xcc, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x57, 0x9a, 0xc1, 0xc8, 0xc5, 0x15, 0x00, 0x16, - 0x08, 0x2e, 0x48, 0x4d, 0x16, 0x12, 0xe2, 0x62, 0xc9, 0x4b, 0xcc, 0x4d, 0x95, 0x60, 0x54, 0x60, - 0xd4, 0xe0, 0x0c, 0x02, 0xb3, 0x85, 0xc4, 0xb8, 0xd8, 0x8a, 0x52, 0x73, 0xf3, 0x4b, 0x52, 0x25, - 0x98, 0xc0, 0xa2, 0x50, 0x9e, 0x90, 0x01, 0x17, 0x57, 0x41, 0x51, 0x66, 0x59, 0x66, 0x4e, 0x6a, - 0x7a, 0x6a, 0xb1, 0x04, 0xb3, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x80, 0x1e, 0xc4, 0xb0, 0x00, 0x98, - 0x44, 0x10, 0x92, 0x1a, 0x21, 0x29, 0x2e, 0x8e, 0x94, 0xcc, 0xe2, 0xc4, 0xa4, 0x9c, 0xd4, 0x14, - 0x09, 0x16, 0x05, 0x46, 0x0d, 0x8e, 0x20, 0x38, 0x5f, 0x48, 0x80, 0x8b, 0x39, 0x35, 0xaf, 0x4c, - 0x82, 0x55, 0x81, 0x59, 0x83, 0x33, 0x08, 0xc4, 0x54, 0x8a, 0xe5, 0xe2, 0x47, 0x33, 0x0c, 0xab, - 0xf3, 0x14, 0xb8, 0xb8, 0x53, 0x52, 0x8b, 0x93, 0x8b, 0x32, 0x0b, 0x4a, 0x32, 0xf3, 0xf3, 0xa0, - 0x6e, 0x44, 0x16, 0x12, 0x12, 0xe1, 0x62, 0x2d, 0x4b, 0xcc, 0x29, 0x4d, 0x05, 0xbb, 0x91, 0x33, - 0x08, 0xc2, 0x71, 0x92, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, - 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x24, 0x36, - 0x70, 0xd0, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x37, 0xea, 0xe2, 0xca, 0x2a, 0x01, 0x00, - 0x00, -} - func (m *PluginSpec) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) + n, err := m.MarshalTo(dAtA) if err != nil { return nil, err } @@ -199,69 +129,66 @@ func (m *PluginSpec) Marshal() (dAtA []byte, err error) { } func (m *PluginSpec) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PluginSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) + var i int _ = i var l int _ = l - if len(m.Env) > 0 { - for iNdEx := len(m.Env) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Env[iNdEx]) - copy(dAtA[i:], m.Env[iNdEx]) - i = encodeVarintPlugin(dAtA, i, uint64(len(m.Env[iNdEx]))) - i-- - dAtA[i] = 0x2a + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintPlugin(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if len(m.Remote) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintPlugin(dAtA, i, uint64(len(m.Remote))) + i += copy(dAtA[i:], m.Remote) + } + if len(m.Privileges) > 0 { + for _, msg := range m.Privileges { + dAtA[i] = 0x1a + i++ + i = encodeVarintPlugin(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n } } if m.Disabled { - i-- + dAtA[i] = 0x20 + i++ if m.Disabled { dAtA[i] = 1 } else { dAtA[i] = 0 } - i-- - dAtA[i] = 0x20 + i++ } - if len(m.Privileges) > 0 { - for iNdEx := len(m.Privileges) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Privileges[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPlugin(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a + if len(m.Env) > 0 { + for _, s := range m.Env { + dAtA[i] = 0x2a + i++ + l = len(s) + for l >= 1<<7 { + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) + l >>= 7 + i++ + } + dAtA[i] = uint8(l) + i++ + i += copy(dAtA[i:], s) } } - if len(m.Remote) > 0 { - i -= len(m.Remote) - copy(dAtA[i:], m.Remote) - i = encodeVarintPlugin(dAtA, i, uint64(len(m.Remote))) - i-- - dAtA[i] = 0x12 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintPlugin(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil + return i, nil } func (m *PluginPrivilege) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) + n, err := m.MarshalTo(dAtA) if err != nil { return nil, err } @@ -269,56 +196,50 @@ func (m *PluginPrivilege) Marshal() (dAtA []byte, err error) { } func (m *PluginPrivilege) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PluginPrivilege) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) + var i int _ = i var l int _ = l - if len(m.Value) > 0 { - for iNdEx := len(m.Value) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Value[iNdEx]) - copy(dAtA[i:], m.Value[iNdEx]) - i = encodeVarintPlugin(dAtA, i, uint64(len(m.Value[iNdEx]))) - i-- - dAtA[i] = 0x1a - } + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintPlugin(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) } if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintPlugin(dAtA, i, uint64(len(m.Description))) - i-- dAtA[i] = 0x12 + i++ + i = encodeVarintPlugin(dAtA, i, uint64(len(m.Description))) + i += copy(dAtA[i:], m.Description) } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintPlugin(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa + if len(m.Value) > 0 { + for _, s := range m.Value { + dAtA[i] = 0x1a + i++ + l = len(s) + for l >= 1<<7 { + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) + l >>= 7 + i++ + } + dAtA[i] = uint8(l) + i++ + i += copy(dAtA[i:], s) + } } - return len(dAtA) - i, nil + return i, nil } func encodeVarintPlugin(dAtA []byte, offset int, v uint64) int { - offset -= sovPlugin(v) - base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) v >>= 7 offset++ } dAtA[offset] = uint8(v) - return base + return offset + 1 } func (m *PluginSpec) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Name) @@ -348,9 +269,6 @@ func (m *PluginSpec) Size() (n int) { } func (m *PluginPrivilege) Size() (n int) { - if m == nil { - return 0 - } var l int _ = l l = len(m.Name) @@ -371,7 +289,14 @@ func (m *PluginPrivilege) Size() (n int) { } func sovPlugin(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n } func sozPlugin(x uint64) (n int) { return sovPlugin(uint64((x << 1) ^ uint64((int64(x) >> 63)))) @@ -391,7 +316,7 @@ func (m *PluginSpec) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= uint64(b&0x7F) << shift + wire |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } @@ -419,7 +344,7 @@ func (m *PluginSpec) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } @@ -429,9 +354,6 @@ func (m *PluginSpec) Unmarshal(dAtA []byte) error { return ErrInvalidLengthPlugin } postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPlugin - } if postIndex > l { return io.ErrUnexpectedEOF } @@ -451,7 +373,7 @@ func (m *PluginSpec) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } @@ -461,9 +383,6 @@ func (m *PluginSpec) Unmarshal(dAtA []byte) error { return ErrInvalidLengthPlugin } postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPlugin - } if postIndex > l { return io.ErrUnexpectedEOF } @@ -483,7 +402,7 @@ func (m *PluginSpec) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } @@ -492,9 +411,6 @@ func (m *PluginSpec) Unmarshal(dAtA []byte) error { return ErrInvalidLengthPlugin } postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthPlugin - } if postIndex > l { return io.ErrUnexpectedEOF } @@ -517,7 +433,7 @@ func (m *PluginSpec) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + v |= (int(b) & 0x7F) << shift if b < 0x80 { break } @@ -537,7 +453,7 @@ func (m *PluginSpec) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } @@ -547,9 +463,6 @@ func (m *PluginSpec) Unmarshal(dAtA []byte) error { return ErrInvalidLengthPlugin } postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPlugin - } if postIndex > l { return io.ErrUnexpectedEOF } @@ -561,7 +474,7 @@ func (m *PluginSpec) Unmarshal(dAtA []byte) error { if err != nil { return err } - if (skippy < 0) || (iNdEx+skippy) < 0 { + if skippy < 0 { return ErrInvalidLengthPlugin } if (iNdEx + skippy) > l { @@ -591,7 +504,7 @@ func (m *PluginPrivilege) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= uint64(b&0x7F) << shift + wire |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } @@ -619,7 +532,7 @@ func (m *PluginPrivilege) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } @@ -629,9 +542,6 @@ func (m *PluginPrivilege) Unmarshal(dAtA []byte) error { return ErrInvalidLengthPlugin } postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPlugin - } if postIndex > l { return io.ErrUnexpectedEOF } @@ -651,7 +561,7 @@ func (m *PluginPrivilege) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } @@ -661,9 +571,6 @@ func (m *PluginPrivilege) Unmarshal(dAtA []byte) error { return ErrInvalidLengthPlugin } postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPlugin - } if postIndex > l { return io.ErrUnexpectedEOF } @@ -683,7 +590,7 @@ func (m *PluginPrivilege) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } @@ -693,9 +600,6 @@ func (m *PluginPrivilege) Unmarshal(dAtA []byte) error { return ErrInvalidLengthPlugin } postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPlugin - } if postIndex > l { return io.ErrUnexpectedEOF } @@ -707,7 +611,7 @@ func (m *PluginPrivilege) Unmarshal(dAtA []byte) error { if err != nil { return err } - if (skippy < 0) || (iNdEx+skippy) < 0 { + if skippy < 0 { return ErrInvalidLengthPlugin } if (iNdEx + skippy) > l { @@ -725,7 +629,6 @@ func (m *PluginPrivilege) Unmarshal(dAtA []byte) error { func skipPlugin(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 - depth := 0 for iNdEx < l { var wire uint64 for shift := uint(0); ; shift += 7 { @@ -757,8 +660,10 @@ func skipPlugin(dAtA []byte) (n int, err error) { break } } + return iNdEx, nil case 1: iNdEx += 8 + return iNdEx, nil case 2: var length int for shift := uint(0); ; shift += 7 { @@ -775,34 +680,75 @@ func skipPlugin(dAtA []byte) (n int, err error) { break } } + iNdEx += length if length < 0 { return 0, ErrInvalidLengthPlugin } - iNdEx += length + return iNdEx, nil case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupPlugin + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPlugin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipPlugin(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next } - depth-- + return iNdEx, nil + case 4: + return iNdEx, nil case 5: iNdEx += 4 + return iNdEx, nil default: return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } - if iNdEx < 0 { - return 0, ErrInvalidLengthPlugin - } - if depth == 0 { - return iNdEx, nil - } } - return 0, io.ErrUnexpectedEOF + panic("unreachable") } var ( - ErrInvalidLengthPlugin = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowPlugin = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupPlugin = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthPlugin = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPlugin = fmt.Errorf("proto: integer overflow") ) + +func init() { proto.RegisterFile("plugin.proto", fileDescriptorPlugin) } + +var fileDescriptorPlugin = []byte{ + // 256 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x4d, 0x4b, 0xc3, 0x30, + 0x18, 0xc7, 0x89, 0xdd, 0xc6, 0xfa, 0x4c, 0x70, 0x04, 0x91, 0xe2, 0xa1, 0x94, 0x9d, 0x7a, 0x6a, + 0x45, 0x2f, 0x82, 0x37, 0x0f, 0x9e, 0x47, 0xbc, 0x09, 0x1e, 0xd2, 0xf6, 0xa1, 0x06, 0x9b, 0x17, + 0x92, 0xb4, 0xe2, 0x37, 0xf1, 0x23, 0x79, 0xf4, 0x23, 0x48, 0x3f, 0x89, 0x98, 0x75, 0x32, 0x64, + 0xa7, 0xff, 0x4b, 0xc2, 0x9f, 0x1f, 0x0f, 0x9c, 0x9a, 0xae, 0x6f, 0x85, 0x2a, 0x8c, 0xd5, 0x5e, + 0x6f, 0x3e, 0x08, 0xc0, 0x36, 0x14, 0x8f, 0x06, 0x6b, 0x4a, 0x61, 0xa6, 0xb8, 0xc4, 0x84, 0x64, + 0x24, 0x8f, 0x59, 0xf0, 0xf4, 0x02, 0x16, 0x16, 0xa5, 0xf6, 0x98, 0x9c, 0x84, 0x76, 0x4a, 0xf4, + 0x0a, 0xc0, 0x58, 0x31, 0x88, 0x0e, 0x5b, 0x74, 0x49, 0x94, 0x45, 0xf9, 0xea, 0x7a, 0x5d, 0xec, + 0xc6, 0xb6, 0xfb, 0x07, 0x76, 0xf0, 0x87, 0x5e, 0xc2, 0xb2, 0x11, 0x8e, 0x57, 0x1d, 0x36, 0xc9, + 0x2c, 0x23, 0xf9, 0x92, 0xfd, 0x65, 0xba, 0x86, 0x08, 0xd5, 0x90, 0xcc, 0xb3, 0x28, 0x8f, 0xd9, + 0xaf, 0xdd, 0x3c, 0xc3, 0xd9, 0xbf, 0xb1, 0xa3, 0x78, 0x19, 0xac, 0x1a, 0x74, 0xb5, 0x15, 0xc6, + 0x0b, 0xad, 0x26, 0xc6, 0xc3, 0x8a, 0x9e, 0xc3, 0x7c, 0xe0, 0x5d, 0x8f, 0x81, 0x31, 0x66, 0xbb, + 0x70, 0xff, 0xf0, 0x39, 0xa6, 0xe4, 0x6b, 0x4c, 0xc9, 0xf7, 0x98, 0x92, 0xa7, 0xdb, 0x56, 0xf8, + 0x97, 0xbe, 0x2a, 0x6a, 0x2d, 0xcb, 0x46, 0xd7, 0xaf, 0x68, 0xf7, 0xc2, 0x8d, 0x28, 0xfd, 0xbb, + 0x41, 0x57, 0xba, 0x37, 0x6e, 0x65, 0x69, 0x7b, 0xe5, 0x85, 0xc4, 0xbb, 0x49, 0xab, 0x45, 0x38, + 0xe4, 0xcd, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x99, 0xa8, 0xd9, 0x9b, 0x58, 0x01, 0x00, 0x00, +} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.proto b/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.proto index e311b36ba2..9ef169046b 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.proto +++ b/test/integration/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +option go_package = "github.com/docker/docker/api/types/swarm/runtime;runtime"; + // PluginSpec defines the base payload which clients can specify for creating // a service with the plugin runtime. message PluginSpec { diff --git a/test/integration/vendor/github.com/docker/docker/api/types/swarm/service.go b/test/integration/vendor/github.com/docker/docker/api/types/swarm/service.go index 5b6d5ec120..6eb452d24d 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/swarm/service.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/swarm/service.go @@ -34,9 +34,9 @@ type ServiceSpec struct { UpdateConfig *UpdateConfig `json:",omitempty"` RollbackConfig *UpdateConfig `json:",omitempty"` - // Networks specifies which networks the service should attach to. - // - // Deprecated: This field is deprecated since v1.44. The Networks field in TaskSpec should be used instead. + // Networks field in ServiceSpec is deprecated. The + // same field in TaskSpec should be used instead. + // This field will be removed in a future release. Networks []NetworkAttachmentConfig `json:",omitempty"` EndpointSpec *EndpointSpec `json:",omitempty"` } diff --git a/test/integration/vendor/github.com/docker/docker/api/types/swarm/service_create_response.go b/test/integration/vendor/github.com/docker/docker/api/types/swarm/service_create_response.go deleted file mode 100644 index 9a268ff1b9..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/swarm/service_create_response.go +++ /dev/null @@ -1,20 +0,0 @@ -package swarm - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -// ServiceCreateResponse contains the information returned to a client on the -// creation of a new service. -// -// swagger:model ServiceCreateResponse -type ServiceCreateResponse struct { - - // The ID of the created service. - ID string `json:"ID,omitempty"` - - // Optional warning message. - // - // FIXME(thaJeztah): this should have "omitempty" in the generated type. - // - Warnings []string `json:"Warnings"` -} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/system/info.go b/test/integration/vendor/github.com/docker/docker/api/types/system/info.go deleted file mode 100644 index 89d4a0098e..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/system/info.go +++ /dev/null @@ -1,116 +0,0 @@ -package system - -import ( - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/registry" - "github.com/docker/docker/api/types/swarm" -) - -// Info contains response of Engine API: -// GET "/info" -type Info struct { - ID string - Containers int - ContainersRunning int - ContainersPaused int - ContainersStopped int - Images int - Driver string - DriverStatus [][2]string - SystemStatus [][2]string `json:",omitempty"` // SystemStatus is only propagated by the Swarm standalone API - Plugins PluginsInfo - MemoryLimit bool - SwapLimit bool - KernelMemory bool `json:",omitempty"` // Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes - KernelMemoryTCP bool `json:",omitempty"` // KernelMemoryTCP is not supported on cgroups v2. - CPUCfsPeriod bool `json:"CpuCfsPeriod"` - CPUCfsQuota bool `json:"CpuCfsQuota"` - CPUShares bool - CPUSet bool - PidsLimit bool - IPv4Forwarding bool - BridgeNfIptables bool - BridgeNfIP6tables bool `json:"BridgeNfIp6tables"` - Debug bool - NFd int - OomKillDisable bool - NGoroutines int - SystemTime string - LoggingDriver string - CgroupDriver string - CgroupVersion string `json:",omitempty"` - NEventsListener int - KernelVersion string - OperatingSystem string - OSVersion string - OSType string - Architecture string - IndexServerAddress string - RegistryConfig *registry.ServiceConfig - NCPU int - MemTotal int64 - GenericResources []swarm.GenericResource - DockerRootDir string - HTTPProxy string `json:"HttpProxy"` - HTTPSProxy string `json:"HttpsProxy"` - NoProxy string - Name string - Labels []string - ExperimentalBuild bool - ServerVersion string - Runtimes map[string]RuntimeWithStatus - DefaultRuntime string - Swarm swarm.Info - // LiveRestoreEnabled determines whether containers should be kept - // running when the daemon is shutdown or upon daemon start if - // running containers are detected - LiveRestoreEnabled bool - Isolation container.Isolation - InitBinary string - ContainerdCommit Commit - RuncCommit Commit - InitCommit Commit - SecurityOptions []string - ProductLicense string `json:",omitempty"` - DefaultAddressPools []NetworkAddressPool `json:",omitempty"` - CDISpecDirs []string - - // Legacy API fields for older API versions. - legacyFields - - // Warnings contains a slice of warnings that occurred while collecting - // system information. These warnings are intended to be informational - // messages for the user, and are not intended to be parsed / used for - // other purposes, as they do not have a fixed format. - Warnings []string -} - -type legacyFields struct { - ExecutionDriver string `json:",omitempty"` // Deprecated: deprecated since API v1.25, but returned for older versions. -} - -// PluginsInfo is a temp struct holding Plugins name -// registered with docker daemon. It is used by [Info] struct -type PluginsInfo struct { - // List of Volume plugins registered - Volume []string - // List of Network plugins registered - Network []string - // List of Authorization plugins registered - Authorization []string - // List of Log plugins registered - Log []string -} - -// Commit holds the Git-commit (SHA1) that a binary was built from, as reported -// in the version-string of external tools, such as containerd, or runC. -type Commit struct { - ID string // ID is the actual commit ID of external tool. - Expected string // Expected is the commit ID of external tool expected by dockerd as set at build time. -} - -// NetworkAddressPool is a temp struct used by [Info] struct. -type NetworkAddressPool struct { - Base string - Size int -} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/system/runtime.go b/test/integration/vendor/github.com/docker/docker/api/types/system/runtime.go deleted file mode 100644 index d077295a0d..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/system/runtime.go +++ /dev/null @@ -1,20 +0,0 @@ -package system - -// Runtime describes an OCI runtime -type Runtime struct { - // "Legacy" runtime configuration for runc-compatible runtimes. - - Path string `json:"path,omitempty"` - Args []string `json:"runtimeArgs,omitempty"` - - // Shimv2 runtime configuration. Mutually exclusive with the legacy config above. - - Type string `json:"runtimeType,omitempty"` - Options map[string]interface{} `json:"options,omitempty"` -} - -// RuntimeWithStatus extends [Runtime] to hold [RuntimeStatus]. -type RuntimeWithStatus struct { - Runtime - Status map[string]string `json:"status,omitempty"` -} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/system/security_opts.go b/test/integration/vendor/github.com/docker/docker/api/types/system/security_opts.go deleted file mode 100644 index edff3eb1ac..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/system/security_opts.go +++ /dev/null @@ -1,48 +0,0 @@ -package system - -import ( - "errors" - "fmt" - "strings" -) - -// SecurityOpt contains the name and options of a security option -type SecurityOpt struct { - Name string - Options []KeyValue -} - -// DecodeSecurityOptions decodes a security options string slice to a -// type-safe [SecurityOpt]. -func DecodeSecurityOptions(opts []string) ([]SecurityOpt, error) { - so := []SecurityOpt{} - for _, opt := range opts { - // support output from a < 1.13 docker daemon - if !strings.Contains(opt, "=") { - so = append(so, SecurityOpt{Name: opt}) - continue - } - secopt := SecurityOpt{} - for _, s := range strings.Split(opt, ",") { - k, v, ok := strings.Cut(s, "=") - if !ok { - return nil, fmt.Errorf("invalid security option %q", s) - } - if k == "" || v == "" { - return nil, errors.New("invalid empty security option") - } - if k == "name" { - secopt.Name = v - continue - } - secopt.Options = append(secopt.Options, KeyValue{Key: k, Value: v}) - } - so = append(so, secopt) - } - return so, nil -} - -// KeyValue holds a key/value pair. -type KeyValue struct { - Key, Value string -} diff --git a/test/integration/vendor/github.com/docker/docker/api/types/types.go b/test/integration/vendor/github.com/docker/docker/api/types/types.go index 5c56a0cafe..b413e02000 100644 --- a/test/integration/vendor/github.com/docker/docker/api/types/types.go +++ b/test/integration/vendor/github.com/docker/docker/api/types/types.go @@ -1,15 +1,18 @@ package types // import "github.com/docker/docker/api/types" import ( + "errors" + "fmt" "io" "os" + "strings" "time" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/volume" "github.com/docker/go-connections/nat" @@ -77,8 +80,6 @@ type ImageInspect struct { // Container is the ID of the container that was used to create the image. // // Depending on how the image was created, this field may be empty. - // - // Deprecated: this field is omitted in API v1.45, but kept for backward compatibility. Container string // ContainerConfig is an optional field containing the configuration of the @@ -86,8 +87,6 @@ type ImageInspect struct { // // Previous versions of Docker builder used this field to store build cache, // and it is not in active use anymore. - // - // Deprecated: this field is omitted in API v1.45, but kept for backward compatibility. ContainerConfig *container.Config // DockerVersion is the version of Docker that was used to build the image. @@ -119,7 +118,12 @@ type ImageInspect struct { // VirtualSize is the total size of the image including all layers it is // composed of. // - // Deprecated: this field is omitted in API v1.44, but kept for backward compatibility. Use Size instead. + // In versions of Docker before v1.10, this field was calculated from + // the image itself and all of its parent images. Docker v1.10 and up + // store images self-contained, and no longer use a parent-chain, making + // this field an equivalent of the Size field. + // + // Deprecated: Unused in API 1.43 and up, but kept for backward compatibility with older API versions. VirtualSize int64 `json:"VirtualSize,omitempty"` // GraphDriver holds information about the storage driver used to store the @@ -133,7 +137,13 @@ type ImageInspect struct { // Metadata of the image in the local cache. // // This information is local to the daemon, and not part of the image itself. - Metadata image.Metadata + Metadata ImageMetadata +} + +// ImageMetadata contains engine-local data about the image +type ImageMetadata struct { + // LastTagTime is the date and time at which the image was last tagged. + LastTagTime time.Time `json:",omitempty"` } // Container contains response of Engine API: @@ -227,6 +237,148 @@ type Version struct { BuildTime string `json:",omitempty"` } +// Commit holds the Git-commit (SHA1) that a binary was built from, as reported +// in the version-string of external tools, such as containerd, or runC. +type Commit struct { + ID string // ID is the actual commit ID of external tool. + Expected string // Expected is the commit ID of external tool expected by dockerd as set at build time. +} + +// Info contains response of Engine API: +// GET "/info" +type Info struct { + ID string + Containers int + ContainersRunning int + ContainersPaused int + ContainersStopped int + Images int + Driver string + DriverStatus [][2]string + SystemStatus [][2]string `json:",omitempty"` // SystemStatus is only propagated by the Swarm standalone API + Plugins PluginsInfo + MemoryLimit bool + SwapLimit bool + KernelMemory bool `json:",omitempty"` // Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes + KernelMemoryTCP bool `json:",omitempty"` // KernelMemoryTCP is not supported on cgroups v2. + CPUCfsPeriod bool `json:"CpuCfsPeriod"` + CPUCfsQuota bool `json:"CpuCfsQuota"` + CPUShares bool + CPUSet bool + PidsLimit bool + IPv4Forwarding bool + BridgeNfIptables bool + BridgeNfIP6tables bool `json:"BridgeNfIp6tables"` + Debug bool + NFd int + OomKillDisable bool + NGoroutines int + SystemTime string + LoggingDriver string + CgroupDriver string + CgroupVersion string `json:",omitempty"` + NEventsListener int + KernelVersion string + OperatingSystem string + OSVersion string + OSType string + Architecture string + IndexServerAddress string + RegistryConfig *registry.ServiceConfig + NCPU int + MemTotal int64 + GenericResources []swarm.GenericResource + DockerRootDir string + HTTPProxy string `json:"HttpProxy"` + HTTPSProxy string `json:"HttpsProxy"` + NoProxy string + Name string + Labels []string + ExperimentalBuild bool + ServerVersion string + Runtimes map[string]Runtime + DefaultRuntime string + Swarm swarm.Info + // LiveRestoreEnabled determines whether containers should be kept + // running when the daemon is shutdown or upon daemon start if + // running containers are detected + LiveRestoreEnabled bool + Isolation container.Isolation + InitBinary string + ContainerdCommit Commit + RuncCommit Commit + InitCommit Commit + SecurityOptions []string + ProductLicense string `json:",omitempty"` + DefaultAddressPools []NetworkAddressPool `json:",omitempty"` + + // Warnings contains a slice of warnings that occurred while collecting + // system information. These warnings are intended to be informational + // messages for the user, and are not intended to be parsed / used for + // other purposes, as they do not have a fixed format. + Warnings []string +} + +// KeyValue holds a key/value pair +type KeyValue struct { + Key, Value string +} + +// NetworkAddressPool is a temp struct used by Info struct +type NetworkAddressPool struct { + Base string + Size int +} + +// SecurityOpt contains the name and options of a security option +type SecurityOpt struct { + Name string + Options []KeyValue +} + +// DecodeSecurityOptions decodes a security options string slice to a type safe +// SecurityOpt +func DecodeSecurityOptions(opts []string) ([]SecurityOpt, error) { + so := []SecurityOpt{} + for _, opt := range opts { + // support output from a < 1.13 docker daemon + if !strings.Contains(opt, "=") { + so = append(so, SecurityOpt{Name: opt}) + continue + } + secopt := SecurityOpt{} + for _, s := range strings.Split(opt, ",") { + k, v, ok := strings.Cut(s, "=") + if !ok { + return nil, fmt.Errorf("invalid security option %q", s) + } + if k == "" || v == "" { + return nil, errors.New("invalid empty security option") + } + if k == "name" { + secopt.Name = v + continue + } + secopt.Options = append(secopt.Options, KeyValue{Key: k, Value: v}) + } + so = append(so, secopt) + } + return so, nil +} + +// PluginsInfo is a temp struct holding Plugins name +// registered with docker daemon. It is used by Info struct +type PluginsInfo struct { + // List of Volume plugins registered + Volume []string + // List of Network plugins registered + Network []string + // List of Authorization plugins registered + Authorization []string + // List of Log plugins registered + Log []string +} + // ExecStartCheck is a temp struct used by execStart // Config fields is part of ExecConfig in runconfig package type ExecStartCheck struct { @@ -339,27 +491,17 @@ type SummaryNetworkSettings struct { Networks map[string]*network.EndpointSettings } -// NetworkSettingsBase holds networking state for a container when inspecting it. +// NetworkSettingsBase holds basic information about networks type NetworkSettingsBase struct { - Bridge string // Bridge contains the name of the default bridge interface iff it was set through the daemon --bridge flag. - SandboxID string // SandboxID uniquely represents a container's network stack - SandboxKey string // SandboxKey identifies the sandbox - Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port - - // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface - // - // Deprecated: This field is never set and will be removed in a future release. - HairpinMode bool - // LinkLocalIPv6Address is an IPv6 unicast address using the link-local prefix - // - // Deprecated: This field is never set and will be removed in a future release. - LinkLocalIPv6Address string - // LinkLocalIPv6PrefixLen is the prefix length of an IPv6 unicast address - // - // Deprecated: This field is never set and will be removed in a future release. - LinkLocalIPv6PrefixLen int - SecondaryIPAddresses []network.Address // Deprecated: This field is never set and will be removed in a future release. - SecondaryIPv6Addresses []network.Address // Deprecated: This field is never set and will be removed in a future release. + Bridge string // Bridge is the Bridge name the network uses(e.g. `docker0`) + SandboxID string // SandboxID uniquely represents a container's network stack + HairpinMode bool // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface + LinkLocalIPv6Address string // LinkLocalIPv6Address is an IPv6 unicast address using the link-local prefix + LinkLocalIPv6PrefixLen int // LinkLocalIPv6PrefixLen is the prefix length of an IPv6 unicast address + Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port + SandboxKey string // SandboxKey identifies the sandbox + SecondaryIPAddresses []network.Address + SecondaryIPv6Addresses []network.Address } // DefaultNetworkSettings holds network information @@ -452,9 +594,14 @@ type EndpointResource struct { // NetworkCreate is the expected body of the "create network" http request message type NetworkCreate struct { - // Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client - // package to older daemons. - CheckDuplicate bool `json:",omitempty"` + // Check for networks with duplicate names. + // Network is primarily keyed based on a random ID and not on the name. + // Network name is strictly a user-friendly alias to the network + // which is uniquely identified using ID. + // And there is no guaranteed way to check for duplicates. + // Option CheckDuplicate is there to provide a best effort checking of any networks + // which has the same name but it is not guaranteed to catch all name collisions. + CheckDuplicate bool Driver string Scope string EnableIPv6 bool @@ -498,6 +645,33 @@ type NetworkInspectOptions struct { Verbose bool } +// Checkpoint represents the details of a checkpoint +type Checkpoint struct { + Name string // Name is the name of the checkpoint +} + +// Runtime describes an OCI runtime +type Runtime struct { + // "Legacy" runtime configuration for runc-compatible runtimes. + + Path string `json:"path,omitempty"` + Args []string `json:"runtimeArgs,omitempty"` + + // Shimv2 runtime configuration. Mutually exclusive with the legacy config above. + + Type string `json:"runtimeType,omitempty"` + Options map[string]interface{} `json:"options,omitempty"` + + // This is exposed here only for internal use + ShimConfig *ShimConfig `json:"-"` +} + +// ShimConfig is used by runtime to configure containerd shims +type ShimConfig struct { + Binary string + Opts interface{} +} + // DiskUsageObject represents an object type used for disk usage query filtering. type DiskUsageObject string @@ -523,7 +697,7 @@ type DiskUsageOptions struct { // GET "/system/df" type DiskUsage struct { LayersSize int64 - Images []*image.Summary + Images []*ImageSummary Containers []*Container Volumes []*volume.Volume BuildCache []*BuildCache @@ -547,7 +721,7 @@ type VolumesPruneReport struct { // ImagesPruneReport contains the response for Engine API: // POST "/images/prune" type ImagesPruneReport struct { - ImagesDeleted []image.DeleteResponse + ImagesDeleted []ImageDeleteResponseItem SpaceReclaimed uint64 } diff --git a/test/integration/vendor/github.com/docker/docker/api/types/types_deprecated.go b/test/integration/vendor/github.com/docker/docker/api/types/types_deprecated.go deleted file mode 100644 index e332a7bb6d..0000000000 --- a/test/integration/vendor/github.com/docker/docker/api/types/types_deprecated.go +++ /dev/null @@ -1,138 +0,0 @@ -package types - -import ( - "github.com/docker/docker/api/types/checkpoint" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/api/types/system" -) - -// CheckpointCreateOptions holds parameters to create a checkpoint from a container. -// -// Deprecated: use [checkpoint.CreateOptions]. -type CheckpointCreateOptions = checkpoint.CreateOptions - -// CheckpointListOptions holds parameters to list checkpoints for a container -// -// Deprecated: use [checkpoint.ListOptions]. -type CheckpointListOptions = checkpoint.ListOptions - -// CheckpointDeleteOptions holds parameters to delete a checkpoint from a container -// -// Deprecated: use [checkpoint.DeleteOptions]. -type CheckpointDeleteOptions = checkpoint.DeleteOptions - -// Checkpoint represents the details of a checkpoint when listing endpoints. -// -// Deprecated: use [checkpoint.Summary]. -type Checkpoint = checkpoint.Summary - -// Info contains response of Engine API: -// GET "/info" -// -// Deprecated: use [system.Info]. -type Info = system.Info - -// Commit holds the Git-commit (SHA1) that a binary was built from, as reported -// in the version-string of external tools, such as containerd, or runC. -// -// Deprecated: use [system.Commit]. -type Commit = system.Commit - -// PluginsInfo is a temp struct holding Plugins name -// registered with docker daemon. It is used by [system.Info] struct -// -// Deprecated: use [system.PluginsInfo]. -type PluginsInfo = system.PluginsInfo - -// NetworkAddressPool is a temp struct used by [system.Info] struct. -// -// Deprecated: use [system.NetworkAddressPool]. -type NetworkAddressPool = system.NetworkAddressPool - -// Runtime describes an OCI runtime. -// -// Deprecated: use [system.Runtime]. -type Runtime = system.Runtime - -// SecurityOpt contains the name and options of a security option. -// -// Deprecated: use [system.SecurityOpt]. -type SecurityOpt = system.SecurityOpt - -// KeyValue holds a key/value pair. -// -// Deprecated: use [system.KeyValue]. -type KeyValue = system.KeyValue - -// ImageDeleteResponseItem image delete response item. -// -// Deprecated: use [image.DeleteResponse]. -type ImageDeleteResponseItem = image.DeleteResponse - -// ImageSummary image summary. -// -// Deprecated: use [image.Summary]. -type ImageSummary = image.Summary - -// ImageMetadata contains engine-local data about the image. -// -// Deprecated: use [image.Metadata]. -type ImageMetadata = image.Metadata - -// ServiceCreateResponse contains the information returned to a client -// on the creation of a new service. -// -// Deprecated: use [swarm.ServiceCreateResponse]. -type ServiceCreateResponse = swarm.ServiceCreateResponse - -// ServiceUpdateResponse service update response. -// -// Deprecated: use [swarm.ServiceUpdateResponse]. -type ServiceUpdateResponse = swarm.ServiceUpdateResponse - -// ContainerStartOptions holds parameters to start containers. -// -// Deprecated: use [container.StartOptions]. -type ContainerStartOptions = container.StartOptions - -// ResizeOptions holds parameters to resize a TTY. -// It can be used to resize container TTYs and -// exec process TTYs too. -// -// Deprecated: use [container.ResizeOptions]. -type ResizeOptions = container.ResizeOptions - -// ContainerAttachOptions holds parameters to attach to a container. -// -// Deprecated: use [container.AttachOptions]. -type ContainerAttachOptions = container.AttachOptions - -// ContainerCommitOptions holds parameters to commit changes into a container. -// -// Deprecated: use [container.CommitOptions]. -type ContainerCommitOptions = container.CommitOptions - -// ContainerListOptions holds parameters to list containers with. -// -// Deprecated: use [container.ListOptions]. -type ContainerListOptions = container.ListOptions - -// ContainerLogsOptions holds parameters to filter logs with. -// -// Deprecated: use [container.LogsOptions]. -type ContainerLogsOptions = container.LogsOptions - -// ContainerRemoveOptions holds parameters to remove containers. -// -// Deprecated: use [container.RemoveOptions]. -type ContainerRemoveOptions = container.RemoveOptions - -// DecodeSecurityOptions decodes a security options string slice to a type safe -// [system.SecurityOpt]. -// -// Deprecated: use [system.DecodeSecurityOptions]. -func DecodeSecurityOptions(opts []string) ([]system.SecurityOpt, error) { - return system.DecodeSecurityOptions(opts) -} diff --git a/test/integration/vendor/github.com/docker/docker/builder/remotecontext/git/gitutils.go b/test/integration/vendor/github.com/docker/docker/builder/remotecontext/git/gitutils.go index 4270e86ef5..f9b2b4b9c4 100644 --- a/test/integration/vendor/github.com/docker/docker/builder/remotecontext/git/gitutils.go +++ b/test/integration/vendor/github.com/docker/docker/builder/remotecontext/git/gitutils.go @@ -35,6 +35,7 @@ func WithIsolatedConfig(v bool) CloneOption { // will be under "docker-build-git" func Clone(remoteURL string, opts ...CloneOption) (string, error) { repo, err := parseRemoteURL(remoteURL) + if err != nil { return "", err } diff --git a/test/integration/vendor/github.com/docker/docker/client/README.md b/test/integration/vendor/github.com/docker/docker/client/README.md index f8af3ab903..992f18117d 100644 --- a/test/integration/vendor/github.com/docker/docker/client/README.md +++ b/test/integration/vendor/github.com/docker/docker/client/README.md @@ -1,10 +1,8 @@ # Go client for the Docker Engine API -The `docker` command uses this package to communicate with the daemon. It can -also be used by your own Go applications to do anything the command-line -interface does – running containers, pulling images, managing swarms, etc. +The `docker` command uses this package to communicate with the daemon. It can also be used by your own Go applications to do anything the command-line interface does – running containers, pulling images, managing swarms, etc. -For example, to list all containers (the equivalent of `docker ps --all`): +For example, to list running containers (the equivalent of `docker ps`): ```go package main @@ -13,26 +11,25 @@ import ( "context" "fmt" - "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types" "github.com/docker/docker/client" ) func main() { - apiClient, err := client.NewClientWithOpts(client.FromEnv) + cli, err := client.NewClientWithOpts(client.FromEnv) if err != nil { panic(err) } - defer apiClient.Close() - containers, err := apiClient.ContainerList(context.Background(), container.ListOptions{All: true}) + containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{}) if err != nil { panic(err) } - for _, ctr := range containers { - fmt.Printf("%s %s (status: %s)\n", ctr.ID, ctr.Image, ctr.Status) + for _, container := range containers { + fmt.Printf("%s %s\n", container.ID[:10], container.Image) } } ``` -[Full documentation is available on pkg.go.dev.](https://pkg.go.dev/github.com/docker/docker/client) +[Full documentation is available on GoDoc.](https://godoc.org/github.com/docker/docker/client) diff --git a/test/integration/vendor/github.com/docker/docker/client/build_prune.go b/test/integration/vendor/github.com/docker/docker/client/build_prune.go index 1a830f4135..2b6606236e 100644 --- a/test/integration/vendor/github.com/docker/docker/client/build_prune.go +++ b/test/integration/vendor/github.com/docker/docker/client/build_prune.go @@ -13,7 +13,7 @@ import ( // BuildCachePrune requests the daemon to delete unused cache data func (cli *Client) BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) { - if err := cli.NewVersionError(ctx, "1.31", "build prune"); err != nil { + if err := cli.NewVersionError("1.31", "build prune"); err != nil { return nil, err } diff --git a/test/integration/vendor/github.com/docker/docker/client/checkpoint_create.go b/test/integration/vendor/github.com/docker/docker/client/checkpoint_create.go index 9746d288df..921024fe4f 100644 --- a/test/integration/vendor/github.com/docker/docker/client/checkpoint_create.go +++ b/test/integration/vendor/github.com/docker/docker/client/checkpoint_create.go @@ -3,11 +3,11 @@ package client // import "github.com/docker/docker/client" import ( "context" - "github.com/docker/docker/api/types/checkpoint" + "github.com/docker/docker/api/types" ) // CheckpointCreate creates a checkpoint from the given container with the given name -func (cli *Client) CheckpointCreate(ctx context.Context, container string, options checkpoint.CreateOptions) error { +func (cli *Client) CheckpointCreate(ctx context.Context, container string, options types.CheckpointCreateOptions) error { resp, err := cli.post(ctx, "/containers/"+container+"/checkpoints", nil, options, nil) ensureReaderClosed(resp) return err diff --git a/test/integration/vendor/github.com/docker/docker/client/checkpoint_delete.go b/test/integration/vendor/github.com/docker/docker/client/checkpoint_delete.go index b968c2b237..54f55fa76e 100644 --- a/test/integration/vendor/github.com/docker/docker/client/checkpoint_delete.go +++ b/test/integration/vendor/github.com/docker/docker/client/checkpoint_delete.go @@ -4,11 +4,11 @@ import ( "context" "net/url" - "github.com/docker/docker/api/types/checkpoint" + "github.com/docker/docker/api/types" ) // CheckpointDelete deletes the checkpoint with the given name from the given container -func (cli *Client) CheckpointDelete(ctx context.Context, containerID string, options checkpoint.DeleteOptions) error { +func (cli *Client) CheckpointDelete(ctx context.Context, containerID string, options types.CheckpointDeleteOptions) error { query := url.Values{} if options.CheckpointDir != "" { query.Set("dir", options.CheckpointDir) diff --git a/test/integration/vendor/github.com/docker/docker/client/checkpoint_list.go b/test/integration/vendor/github.com/docker/docker/client/checkpoint_list.go index 8feb1f3f7d..39cfb959ff 100644 --- a/test/integration/vendor/github.com/docker/docker/client/checkpoint_list.go +++ b/test/integration/vendor/github.com/docker/docker/client/checkpoint_list.go @@ -5,12 +5,12 @@ import ( "encoding/json" "net/url" - "github.com/docker/docker/api/types/checkpoint" + "github.com/docker/docker/api/types" ) // CheckpointList returns the checkpoints of the given container in the docker host -func (cli *Client) CheckpointList(ctx context.Context, container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) { - var checkpoints []checkpoint.Summary +func (cli *Client) CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) { + var checkpoints []types.Checkpoint query := url.Values{} if options.CheckpointDir != "" { diff --git a/test/integration/vendor/github.com/docker/docker/client/client.go b/test/integration/vendor/github.com/docker/docker/client/client.go index 0b496b0fa6..54fa36cca8 100644 --- a/test/integration/vendor/github.com/docker/docker/client/client.go +++ b/test/integration/vendor/github.com/docker/docker/client/client.go @@ -19,7 +19,7 @@ For example, to list running containers (the equivalent of "docker ps"): "context" "fmt" - "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types" "github.com/docker/docker/client" ) @@ -29,13 +29,13 @@ For example, to list running containers (the equivalent of "docker ps"): panic(err) } - containers, err := cli.ContainerList(context.Background(), container.ListOptions{}) + containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{}) if err != nil { panic(err) } - for _, ctr := range containers { - fmt.Printf("%s %s\n", ctr.ID, ctr.Image) + for _, container := range containers { + fmt.Printf("%s %s\n", container.ID[:10], container.Image) } } */ @@ -43,21 +43,17 @@ package client // import "github.com/docker/docker/client" import ( "context" - "crypto/tls" "net" "net/http" "net/url" "path" "strings" - "time" "github.com/docker/docker/api" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" "github.com/docker/go-connections/sockets" "github.com/pkg/errors" - "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" - "go.opentelemetry.io/otel/trace" ) // DummyHost is a hostname used for local communication. @@ -90,12 +86,8 @@ import ( // [Go stdlib]: https://github.com/golang/go/blob/6244b1946bc2101b01955468f1be502dbadd6807/src/net/http/transport.go#L558-L569 const DummyHost = "api.moby.localhost" -// fallbackAPIVersion is the version to fallback to if API-version negotiation -// fails. This version is the highest version of the API before API-version -// negotiation was introduced. If negotiation fails (or no API version was -// included in the API response), we assume the API server uses the most -// recent version before negotiation was introduced. -const fallbackAPIVersion = "1.24" +// ErrRedirect is the error returned by checkRedirect when the request is non-GET. +var ErrRedirect = errors.New("unexpected redirect in response") // Client is the API client that performs all operations // against a docker server. @@ -114,12 +106,7 @@ type Client struct { client *http.Client // version of the server to talk to. version string - // userAgent is the User-Agent header to use for HTTP requests. It takes - // precedence over User-Agent headers set in customHTTPHeaders, and other - // header variables. When set to an empty string, the User-Agent header - // is removed, and no header is sent. - userAgent *string - // custom HTTP headers configured by users. + // custom http headers configured by users. customHTTPHeaders map[string]string // manualOverride is set to true when the version was set by users. manualOverride bool @@ -132,33 +119,22 @@ type Client struct { // negotiated indicates that API version negotiation took place negotiated bool - - tp trace.TracerProvider - - // When the client transport is an *http.Transport (default) we need to do some extra things (like closing idle connections). - // Store the original transport as the http.Client transport will be wrapped with tracing libs. - baseTransport *http.Transport } -// ErrRedirect is the error returned by checkRedirect when the request is non-GET. -var ErrRedirect = errors.New("unexpected redirect in response") - -// CheckRedirect specifies the policy for dealing with redirect responses. It -// can be set on [http.Client.CheckRedirect] to prevent HTTP redirects for -// non-GET requests. It returns an [ErrRedirect] for non-GET request, otherwise -// returns a [http.ErrUseLastResponse], which is special-cased by http.Client -// to use the last response. +// CheckRedirect specifies the policy for dealing with redirect responses: +// If the request is non-GET return ErrRedirect, otherwise use the last response. // -// Go 1.8 changed behavior for HTTP redirects (specifically 301, 307, and 308) -// in the client. The client (and by extension API client) can be made to send -// a request like "POST /containers//start" where what would normally be in the -// name section of the URL is empty. This triggers an HTTP 301 from the daemon. +// Go 1.8 changes behavior for HTTP redirects (specifically 301, 307, and 308) +// in the client. The Docker client (and by extension docker API client) can be +// made to send a request like POST /containers//start where what would normally +// be in the name section of the URL is empty. This triggers an HTTP 301 from +// the daemon. // -// In go 1.8 this 301 is converted to a GET request, and ends up getting +// In go 1.8 this 301 will be converted to a GET request, and ends up getting // a 404 from the daemon. This behavior change manifests in the client in that // before, the 301 was not followed and the client did not generate an error, -// but now results in a message like "Error response from daemon: page not found". -func CheckRedirect(_ *http.Request, via []*http.Request) error { +// but now results in a message like Error response from daemon: page not found. +func CheckRedirect(req *http.Request, via []*http.Request) error { if via[0].Method == http.MethodGet { return http.ErrUseLastResponse } @@ -169,11 +145,11 @@ func CheckRedirect(_ *http.Request, via []*http.Request) error { // default API host and version. It also initializes the custom HTTP headers to // add to each request. // -// It takes an optional list of [Opt] functional arguments, which are applied in +// It takes an optional list of Opt functional arguments, which are applied in // the order they're provided, which allows modifying the defaults when creating // the client. For example, the following initializes a client that configures -// itself with values from environment variables ([FromEnv]), and has automatic -// API version negotiation enabled ([WithAPIVersionNegotiation]). +// itself with values from environment variables (client.FromEnv), and has +// automatic API version negotiation enabled (client.WithAPIVersionNegotiation()). // // cli, err := client.NewClientWithOpts( // client.FromEnv, @@ -203,43 +179,23 @@ func NewClientWithOpts(ops ...Opt) (*Client, error) { } } - if tr, ok := c.client.Transport.(*http.Transport); ok { - // Store the base transport before we wrap it in tracing libs below - // This is used, as an example, to close idle connections when the client is closed - c.baseTransport = tr - } - if c.scheme == "" { - // TODO(stevvooe): This isn't really the right way to write clients in Go. - // `NewClient` should probably only take an `*http.Client` and work from there. - // Unfortunately, the model of having a host-ish/url-thingy as the connection - // string has us confusing protocol and transport layers. We continue doing - // this to avoid breaking existing clients but this should be addressed. - if c.tlsConfig() != nil { + c.scheme = "http" + + tlsConfig := resolveTLSConfig(c.client.Transport) + if tlsConfig != nil { + // TODO(stevvooe): This isn't really the right way to write clients in Go. + // `NewClient` should probably only take an `*http.Client` and work from there. + // Unfortunately, the model of having a host-ish/url-thingy as the connection + // string has us confusing protocol and transport layers. We continue doing + // this to avoid breaking existing clients but this should be addressed. c.scheme = "https" - } else { - c.scheme = "http" } } - c.client.Transport = otelhttp.NewTransport( - c.client.Transport, - otelhttp.WithTracerProvider(c.tp), - otelhttp.WithSpanNameFormatter(func(_ string, req *http.Request) string { - return req.Method + " " + req.URL.Path - }), - ) - return c, nil } -func (cli *Client) tlsConfig() *tls.Config { - if cli.baseTransport == nil { - return nil - } - return cli.baseTransport.TLSClientConfig -} - func defaultHTTPClient(hostURL *url.URL) (*http.Client, error) { transport := &http.Transport{} err := sockets.ConfigureTransport(transport, hostURL.Scheme, hostURL.Host) @@ -254,28 +210,19 @@ func defaultHTTPClient(hostURL *url.URL) (*http.Client, error) { // Close the transport used by the client func (cli *Client) Close() error { - if cli.baseTransport != nil { - cli.baseTransport.CloseIdleConnections() - return nil + if t, ok := cli.client.Transport.(*http.Transport); ok { + t.CloseIdleConnections() } return nil } -// checkVersion manually triggers API version negotiation (if configured). -// This allows for version-dependent code to use the same version as will -// be negotiated when making the actual requests, and for which cases -// we cannot do the negotiation lazily. -func (cli *Client) checkVersion(ctx context.Context) { - if cli.negotiateVersion && !cli.negotiated { - cli.NegotiateAPIVersion(ctx) - } -} - -// getAPIPath returns the versioned request path to call the API. +// getAPIPath returns the versioned request path to call the api. // It appends the query parameters to the path if they are not empty. func (cli *Client) getAPIPath(ctx context.Context, p string, query url.Values) string { var apiPath string - cli.checkVersion(ctx) + if cli.negotiateVersion && !cli.negotiated { + cli.NegotiateAPIVersion(ctx) + } if cli.version != "" { v := strings.TrimPrefix(cli.version, "v") apiPath = path.Join(cli.basePath, "/v"+v, p) @@ -297,8 +244,8 @@ func (cli *Client) ClientVersion() string { // by the client, it uses the client's maximum version. // // If a manual override is in place, either through the "DOCKER_API_VERSION" -// ([EnvOverrideAPIVersion]) environment variable, or if the client is initialized -// with a fixed version ([WithVersion]), no negotiation is performed. +// (EnvOverrideAPIVersion) environment variable, or if the client is initialized +// with a fixed version (WithVersion(xx)), no negotiation is performed. // // If the API server's ping response does not contain an API version, or if the // client did not get a successful ping response, it assumes it is connected with @@ -318,8 +265,8 @@ func (cli *Client) NegotiateAPIVersion(ctx context.Context) { // version. // // If a manual override is in place, either through the "DOCKER_API_VERSION" -// ([EnvOverrideAPIVersion]) environment variable, or if the client is initialized -// with a fixed version ([WithVersion]), no negotiation is performed. +// (EnvOverrideAPIVersion) environment variable, or if the client is initialized +// with a fixed version (WithVersion(xx)), no negotiation is performed. // // If the API server's ping response does not contain an API version, we assume // we are connected with an old daemon without API version negotiation support, @@ -336,7 +283,7 @@ func (cli *Client) NegotiateAPIVersionPing(pingResponse types.Ping) { func (cli *Client) negotiateAPIVersionPing(pingResponse types.Ping) { // default to the latest version before versioning headers existed if pingResponse.APIVersion == "" { - pingResponse.APIVersion = fallbackAPIVersion + pingResponse.APIVersion = "1.24" } // if the client is not initialized with a version, start with the latest supported version @@ -391,40 +338,17 @@ func ParseHostURL(host string) (*url.URL, error) { }, nil } -func (cli *Client) dialerFromTransport() func(context.Context, string, string) (net.Conn, error) { - if cli.baseTransport == nil || cli.baseTransport.DialContext == nil { - return nil - } - - if cli.baseTransport.TLSClientConfig != nil { - // When using a tls config we don't use the configured dialer but instead a fallback dialer... - // Note: It seems like this should use the normal dialer and wrap the returned net.Conn in a tls.Conn - // I honestly don't know why it doesn't do that, but it doesn't and such a change is entirely unrelated to the change in this commit. - return nil - } - return cli.baseTransport.DialContext -} - // Dialer returns a dialer for a raw stream connection, with an HTTP/1.1 header, -// that can be used for proxying the daemon connection. It is used by -// ["docker dial-stdio"]. +// that can be used for proxying the daemon connection. // -// ["docker dial-stdio"]: https://github.com/docker/cli/pull/1014 +// Used by `docker dial-stdio` (docker/cli#889). func (cli *Client) Dialer() func(context.Context) (net.Conn, error) { return func(ctx context.Context) (net.Conn, error) { - if dialFn := cli.dialerFromTransport(); dialFn != nil { - return dialFn(ctx, cli.proto, cli.addr) - } - switch cli.proto { - case "unix": - return net.Dial(cli.proto, cli.addr) - case "npipe": - return sockets.DialPipe(cli.addr, 32*time.Second) - default: - if tlsConfig := cli.tlsConfig(); tlsConfig != nil { - return tls.Dial(cli.proto, cli.addr, tlsConfig) + if transport, ok := cli.client.Transport.(*http.Transport); ok { + if transport.DialContext != nil && transport.TLSClientConfig == nil { + return transport.DialContext(ctx, cli.proto, cli.addr) } - return net.Dial(cli.proto, cli.addr) } + return fallbackDial(cli.proto, cli.addr, resolveTLSConfig(cli.client.Transport)) } } diff --git a/test/integration/vendor/github.com/docker/docker/client/client_unix.go b/test/integration/vendor/github.com/docker/docker/client/client_unix.go index 9fe78ea43a..319b738d3e 100644 --- a/test/integration/vendor/github.com/docker/docker/client/client_unix.go +++ b/test/integration/vendor/github.com/docker/docker/client/client_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package client // import "github.com/docker/docker/client" diff --git a/test/integration/vendor/github.com/docker/docker/client/config_create.go b/test/integration/vendor/github.com/docker/docker/client/config_create.go index 3deb4a8e2a..f6b1881fc3 100644 --- a/test/integration/vendor/github.com/docker/docker/client/config_create.go +++ b/test/integration/vendor/github.com/docker/docker/client/config_create.go @@ -11,7 +11,7 @@ import ( // ConfigCreate creates a new config. func (cli *Client) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error) { var response types.ConfigCreateResponse - if err := cli.NewVersionError(ctx, "1.30", "config create"); err != nil { + if err := cli.NewVersionError("1.30", "config create"); err != nil { return response, err } resp, err := cli.post(ctx, "/configs/create", nil, config, nil) diff --git a/test/integration/vendor/github.com/docker/docker/client/config_inspect.go b/test/integration/vendor/github.com/docker/docker/client/config_inspect.go index 2c6c7cb36f..9be7882c3d 100644 --- a/test/integration/vendor/github.com/docker/docker/client/config_inspect.go +++ b/test/integration/vendor/github.com/docker/docker/client/config_inspect.go @@ -14,7 +14,7 @@ func (cli *Client) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.C if id == "" { return swarm.Config{}, nil, objectNotFoundError{object: "config", id: id} } - if err := cli.NewVersionError(ctx, "1.30", "config inspect"); err != nil { + if err := cli.NewVersionError("1.30", "config inspect"); err != nil { return swarm.Config{}, nil, err } resp, err := cli.get(ctx, "/configs/"+id, nil, nil) diff --git a/test/integration/vendor/github.com/docker/docker/client/config_list.go b/test/integration/vendor/github.com/docker/docker/client/config_list.go index 14dd3813e3..565acc6e27 100644 --- a/test/integration/vendor/github.com/docker/docker/client/config_list.go +++ b/test/integration/vendor/github.com/docker/docker/client/config_list.go @@ -12,7 +12,7 @@ import ( // ConfigList returns the list of configs. func (cli *Client) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { - if err := cli.NewVersionError(ctx, "1.30", "config list"); err != nil { + if err := cli.NewVersionError("1.30", "config list"); err != nil { return nil, err } query := url.Values{} diff --git a/test/integration/vendor/github.com/docker/docker/client/config_remove.go b/test/integration/vendor/github.com/docker/docker/client/config_remove.go index d05b0113aa..24b94e9c18 100644 --- a/test/integration/vendor/github.com/docker/docker/client/config_remove.go +++ b/test/integration/vendor/github.com/docker/docker/client/config_remove.go @@ -4,7 +4,7 @@ import "context" // ConfigRemove removes a config. func (cli *Client) ConfigRemove(ctx context.Context, id string) error { - if err := cli.NewVersionError(ctx, "1.30", "config remove"); err != nil { + if err := cli.NewVersionError("1.30", "config remove"); err != nil { return err } resp, err := cli.delete(ctx, "/configs/"+id, nil, nil) diff --git a/test/integration/vendor/github.com/docker/docker/client/config_update.go b/test/integration/vendor/github.com/docker/docker/client/config_update.go index 6995861df0..1ac2985435 100644 --- a/test/integration/vendor/github.com/docker/docker/client/config_update.go +++ b/test/integration/vendor/github.com/docker/docker/client/config_update.go @@ -9,7 +9,7 @@ import ( // ConfigUpdate attempts to update a config func (cli *Client) ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error { - if err := cli.NewVersionError(ctx, "1.30", "config update"); err != nil { + if err := cli.NewVersionError("1.30", "config update"); err != nil { return err } query := url.Values{} diff --git a/test/integration/vendor/github.com/docker/docker/client/container_attach.go b/test/integration/vendor/github.com/docker/docker/client/container_attach.go index 6a32e5f664..ba92117d3e 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_attach.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_attach.go @@ -2,11 +2,9 @@ package client // import "github.com/docker/docker/client" import ( "context" - "net/http" "net/url" "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" ) // ContainerAttach attaches a connection to a container in the server. @@ -33,7 +31,7 @@ import ( // // You can use github.com/docker/docker/pkg/stdcopy.StdCopy to demultiplex this // stream. -func (cli *Client) ContainerAttach(ctx context.Context, container string, options container.AttachOptions) (types.HijackedResponse, error) { +func (cli *Client) ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) { query := url.Values{} if options.Stream { query.Set("stream", "1") @@ -54,7 +52,8 @@ func (cli *Client) ContainerAttach(ctx context.Context, container string, option query.Set("logs", "1") } - return cli.postHijacked(ctx, "/containers/"+container+"/attach", query, nil, http.Header{ + headers := map[string][]string{ "Content-Type": {"text/plain"}, - }) + } + return cli.postHijacked(ctx, "/containers/"+container+"/attach", query, nil, headers) } diff --git a/test/integration/vendor/github.com/docker/docker/client/container_commit.go b/test/integration/vendor/github.com/docker/docker/client/container_commit.go index 26b3f09158..cd7f763464 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_commit.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_commit.go @@ -6,13 +6,12 @@ import ( "errors" "net/url" - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" ) // ContainerCommit applies changes to a container and creates a new tagged image. -func (cli *Client) ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (types.IDResponse, error) { +func (cli *Client) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) { var repository, tag string if options.Reference != "" { ref, err := reference.ParseNormalizedNamed(options.Reference) diff --git a/test/integration/vendor/github.com/docker/docker/client/container_create.go b/test/integration/vendor/github.com/docker/docker/client/container_create.go index 409f5b492a..193a2bb562 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_create.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_create.go @@ -23,23 +23,10 @@ type configWrapper struct { func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) { var response container.CreateResponse - // Make sure we negotiated (if the client is configured to do so), - // as code below contains API-version specific handling of options. - // - // Normally, version-negotiation (if enabled) would not happen until - // the API request is made. - cli.checkVersion(ctx) - - if err := cli.NewVersionError(ctx, "1.25", "stop timeout"); config != nil && config.StopTimeout != nil && err != nil { - return response, err - } - if err := cli.NewVersionError(ctx, "1.41", "specify container image platform"); platform != nil && err != nil { + if err := cli.NewVersionError("1.25", "stop timeout"); config != nil && config.StopTimeout != nil && err != nil { return response, err } - if err := cli.NewVersionError(ctx, "1.44", "specify health-check start interval"); config != nil && config.Healthcheck != nil && config.Healthcheck.StartInterval != 0 && err != nil { - return response, err - } - if err := cli.NewVersionError(ctx, "1.44", "specify mac-address per network"); hasEndpointSpecificMacAddress(networkingConfig) && err != nil { + if err := cli.NewVersionError("1.41", "specify container image platform"); platform != nil && err != nil { return response, err } @@ -58,11 +45,6 @@ func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config } } - // Since API 1.44, the container-wide MacAddress is deprecated and will trigger a WARNING if it's specified. - if versions.GreaterThanOrEqualTo(cli.ClientVersion(), "1.44") { - config.MacAddress = "" //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44. - } - query := url.Values{} if p := formatPlatform(platform); p != "" { query.Set("platform", p) @@ -99,16 +81,3 @@ func formatPlatform(platform *ocispec.Platform) string { } return path.Join(platform.OS, platform.Architecture, platform.Variant) } - -// hasEndpointSpecificMacAddress checks whether one of the endpoint in networkingConfig has a MacAddress defined. -func hasEndpointSpecificMacAddress(networkingConfig *network.NetworkingConfig) bool { - if networkingConfig == nil { - return false - } - for _, endpoint := range networkingConfig.EndpointsConfig { - if endpoint.MacAddress != "" { - return true - } - } - return false -} diff --git a/test/integration/vendor/github.com/docker/docker/client/container_exec.go b/test/integration/vendor/github.com/docker/docker/client/container_exec.go index 3fff0c8288..6a2cb006f8 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_exec.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_exec.go @@ -3,7 +3,6 @@ package client // import "github.com/docker/docker/client" import ( "context" "encoding/json" - "net/http" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" @@ -13,14 +12,7 @@ import ( func (cli *Client) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) { var response types.IDResponse - // Make sure we negotiated (if the client is configured to do so), - // as code below contains API-version specific handling of options. - // - // Normally, version-negotiation (if enabled) would not happen until - // the API request is made. - cli.checkVersion(ctx) - - if err := cli.NewVersionError(ctx, "1.25", "env"); len(config.Env) != 0 && err != nil { + if err := cli.NewVersionError("1.25", "env"); len(config.Env) != 0 && err != nil { return response, err } if versions.LessThan(cli.ClientVersion(), "1.42") { @@ -54,9 +46,10 @@ func (cli *Client) ContainerExecAttach(ctx context.Context, execID string, confi if versions.LessThan(cli.ClientVersion(), "1.42") { config.ConsoleSize = nil } - return cli.postHijacked(ctx, "/exec/"+execID+"/start", nil, config, http.Header{ + headers := map[string][]string{ "Content-Type": {"application/json"}, - }) + } + return cli.postHijacked(ctx, "/exec/"+execID+"/start", nil, config, headers) } // ContainerExecInspect returns information about a specific exec process on the docker host. diff --git a/test/integration/vendor/github.com/docker/docker/client/container_list.go b/test/integration/vendor/github.com/docker/docker/client/container_list.go index 782e1b3c62..bd491b3db9 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_list.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_list.go @@ -7,12 +7,11 @@ import ( "strconv" "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" ) // ContainerList returns the list of containers in the docker host. -func (cli *Client) ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error) { +func (cli *Client) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) { query := url.Values{} if options.All { @@ -38,6 +37,7 @@ func (cli *Client) ContainerList(ctx context.Context, options container.ListOpti if options.Filters.Len() > 0 { //nolint:staticcheck // ignore SA1019 for old code filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters) + if err != nil { return nil, err } diff --git a/test/integration/vendor/github.com/docker/docker/client/container_logs.go b/test/integration/vendor/github.com/docker/docker/client/container_logs.go index 61197d8407..9bdf2b0fa6 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_logs.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_logs.go @@ -6,7 +6,7 @@ import ( "net/url" "time" - "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types" timetypes "github.com/docker/docker/api/types/time" "github.com/pkg/errors" ) @@ -33,7 +33,7 @@ import ( // // You can use github.com/docker/docker/pkg/stdcopy.StdCopy to demultiplex this // stream. -func (cli *Client) ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error) { +func (cli *Client) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) { query := url.Values{} if options.ShowStdout { query.Set("stdout", "1") diff --git a/test/integration/vendor/github.com/docker/docker/client/container_prune.go b/test/integration/vendor/github.com/docker/docker/client/container_prune.go index ca50923844..04383deaaf 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_prune.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_prune.go @@ -13,7 +13,7 @@ import ( func (cli *Client) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error) { var report types.ContainersPruneReport - if err := cli.NewVersionError(ctx, "1.25", "container prune"); err != nil { + if err := cli.NewVersionError("1.25", "container prune"); err != nil { return report, err } diff --git a/test/integration/vendor/github.com/docker/docker/client/container_remove.go b/test/integration/vendor/github.com/docker/docker/client/container_remove.go index 39f7b106a1..c21de609b0 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_remove.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_remove.go @@ -4,11 +4,11 @@ import ( "context" "net/url" - "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types" ) // ContainerRemove kills and removes a container from the docker host. -func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error { +func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error { query := url.Values{} if options.RemoveVolumes { query.Set("v", "1") diff --git a/test/integration/vendor/github.com/docker/docker/client/container_resize.go b/test/integration/vendor/github.com/docker/docker/client/container_resize.go index 5cfd01d479..a9d4c0c79a 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_resize.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_resize.go @@ -5,16 +5,16 @@ import ( "net/url" "strconv" - "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types" ) // ContainerResize changes the size of the tty for a container. -func (cli *Client) ContainerResize(ctx context.Context, containerID string, options container.ResizeOptions) error { +func (cli *Client) ContainerResize(ctx context.Context, containerID string, options types.ResizeOptions) error { return cli.resize(ctx, "/containers/"+containerID, options.Height, options.Width) } // ContainerExecResize changes the size of the tty for an exec process running inside a container. -func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error { +func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error { return cli.resize(ctx, "/exec/"+execID, options.Height, options.Width) } diff --git a/test/integration/vendor/github.com/docker/docker/client/container_restart.go b/test/integration/vendor/github.com/docker/docker/client/container_restart.go index 825d3e4e9d..1e0ad99981 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_restart.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_restart.go @@ -17,16 +17,8 @@ func (cli *Client) ContainerRestart(ctx context.Context, containerID string, opt if options.Timeout != nil { query.Set("t", strconv.Itoa(*options.Timeout)) } - if options.Signal != "" { - // Make sure we negotiated (if the client is configured to do so), - // as code below contains API-version specific handling of options. - // - // Normally, version-negotiation (if enabled) would not happen until - // the API request is made. - cli.checkVersion(ctx) - if versions.GreaterThanOrEqualTo(cli.version, "1.42") { - query.Set("signal", options.Signal) - } + if options.Signal != "" && versions.GreaterThanOrEqualTo(cli.version, "1.42") { + query.Set("signal", options.Signal) } resp, err := cli.post(ctx, "/containers/"+containerID+"/restart", query, nil, nil) ensureReaderClosed(resp) diff --git a/test/integration/vendor/github.com/docker/docker/client/container_start.go b/test/integration/vendor/github.com/docker/docker/client/container_start.go index 33ba85f248..c2e0b15dca 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_start.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_start.go @@ -4,11 +4,11 @@ import ( "context" "net/url" - "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types" ) // ContainerStart sends a request to the docker daemon to start a container. -func (cli *Client) ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error { +func (cli *Client) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error { query := url.Values{} if len(options.CheckpointID) != 0 { query.Set("checkpoint", options.CheckpointID) diff --git a/test/integration/vendor/github.com/docker/docker/client/container_stats.go b/test/integration/vendor/github.com/docker/docker/client/container_stats.go index 3fabb75f32..0a6488dde8 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_stats.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_stats.go @@ -21,10 +21,8 @@ func (cli *Client) ContainerStats(ctx context.Context, containerID string, strea return types.ContainerStats{}, err } - return types.ContainerStats{ - Body: resp.body, - OSType: getDockerOS(resp.header.Get("Server")), - }, nil + osType := getDockerOS(resp.header.Get("Server")) + return types.ContainerStats{Body: resp.body, OSType: osType}, err } // ContainerStatsOneShot gets a single stat entry from a container. @@ -39,8 +37,6 @@ func (cli *Client) ContainerStatsOneShot(ctx context.Context, containerID string return types.ContainerStats{}, err } - return types.ContainerStats{ - Body: resp.body, - OSType: getDockerOS(resp.header.Get("Server")), - }, nil + osType := getDockerOS(resp.header.Get("Server")) + return types.ContainerStats{Body: resp.body, OSType: osType}, err } diff --git a/test/integration/vendor/github.com/docker/docker/client/container_stop.go b/test/integration/vendor/github.com/docker/docker/client/container_stop.go index ac0cab69de..2a43ce2274 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_stop.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_stop.go @@ -21,16 +21,8 @@ func (cli *Client) ContainerStop(ctx context.Context, containerID string, option if options.Timeout != nil { query.Set("t", strconv.Itoa(*options.Timeout)) } - if options.Signal != "" { - // Make sure we negotiated (if the client is configured to do so), - // as code below contains API-version specific handling of options. - // - // Normally, version-negotiation (if enabled) would not happen until - // the API request is made. - cli.checkVersion(ctx) - if versions.GreaterThanOrEqualTo(cli.version, "1.42") { - query.Set("signal", options.Signal) - } + if options.Signal != "" && versions.GreaterThanOrEqualTo(cli.version, "1.42") { + query.Set("signal", options.Signal) } resp, err := cli.post(ctx, "/containers/"+containerID+"/stop", query, nil, nil) ensureReaderClosed(resp) diff --git a/test/integration/vendor/github.com/docker/docker/client/container_wait.go b/test/integration/vendor/github.com/docker/docker/client/container_wait.go index b8d3bdef0d..2375eb1e80 100644 --- a/test/integration/vendor/github.com/docker/docker/client/container_wait.go +++ b/test/integration/vendor/github.com/docker/docker/client/container_wait.go @@ -30,12 +30,6 @@ const containerWaitErrorMsgLimit = 2 * 1024 /* Max: 2KiB */ // synchronize ContainerWait with other calls, such as specifying a // "next-exit" condition before issuing a ContainerStart request. func (cli *Client) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) { - // Make sure we negotiated (if the client is configured to do so), - // as code below contains API-version specific handling of options. - // - // Normally, version-negotiation (if enabled) would not happen until - // the API request is made. - cli.checkVersion(ctx) if versions.LessThan(cli.ClientVersion(), "1.30") { return cli.legacyContainerWait(ctx, containerID) } @@ -72,12 +66,8 @@ func (cli *Client) ContainerWait(ctx context.Context, containerID string, condit // // If there's a JSON parsing error, read the real error message // off the body and send it to the client. - if errors.As(err, new(*json.SyntaxError)) { - _, _ = io.ReadAll(io.LimitReader(stream, containerWaitErrorMsgLimit)) - errC <- errors.New(responseText.String()) - } else { - errC <- err - } + _, _ = io.ReadAll(io.LimitReader(stream, containerWaitErrorMsgLimit)) + errC <- errors.New(responseText.String()) return } diff --git a/test/integration/vendor/github.com/docker/docker/client/distribution_inspect.go b/test/integration/vendor/github.com/docker/docker/client/distribution_inspect.go index 68ef31b78b..efab066d3b 100644 --- a/test/integration/vendor/github.com/docker/docker/client/distribution_inspect.go +++ b/test/integration/vendor/github.com/docker/docker/client/distribution_inspect.go @@ -3,7 +3,6 @@ package client // import "github.com/docker/docker/client" import ( "context" "encoding/json" - "net/http" "net/url" "github.com/docker/docker/api/types/registry" @@ -17,13 +16,13 @@ func (cli *Client) DistributionInspect(ctx context.Context, image, encodedRegist return distributionInspect, objectNotFoundError{object: "distribution", id: image} } - if err := cli.NewVersionError(ctx, "1.30", "distribution inspect"); err != nil { + if err := cli.NewVersionError("1.30", "distribution inspect"); err != nil { return distributionInspect, err } + var headers map[string][]string - var headers http.Header if encodedRegistryAuth != "" { - headers = http.Header{ + headers = map[string][]string{ registry.AuthHeader: {encodedRegistryAuth}, } } diff --git a/test/integration/vendor/github.com/docker/docker/client/errors.go b/test/integration/vendor/github.com/docker/docker/client/errors.go index 4b96b02085..6878144c41 100644 --- a/test/integration/vendor/github.com/docker/docker/client/errors.go +++ b/test/integration/vendor/github.com/docker/docker/client/errors.go @@ -1,7 +1,6 @@ package client // import "github.com/docker/docker/client" import ( - "context" "fmt" "github.com/docker/docker/api/types/versions" @@ -32,10 +31,20 @@ func ErrorConnectionFailed(host string) error { return errConnectionFailed{host: host} } +// Deprecated: use the errdefs.NotFound() interface instead. Kept for backward compatibility +type notFound interface { + error + NotFound() bool +} + // IsErrNotFound returns true if the error is a NotFound error, which is returned -// by the API when some object is not found. It is an alias for [errdefs.IsNotFound]. +// by the API when some object is not found. func IsErrNotFound(err error) bool { - return errdefs.IsNotFound(err) + if errdefs.IsNotFound(err) { + return true + } + var e notFound + return errors.As(err, &e) } type objectNotFoundError struct { @@ -49,18 +58,9 @@ func (e objectNotFoundError) Error() string { return fmt.Sprintf("Error: No such %s: %s", e.object, e.id) } -// NewVersionError returns an error if the APIVersion required is less than the -// current supported version. -// -// It performs API-version negotiation if the Client is configured with this -// option, otherwise it assumes the latest API version is used. -func (cli *Client) NewVersionError(ctx context.Context, APIrequired, feature string) error { - // Make sure we negotiated (if the client is configured to do so), - // as code below contains API-version specific handling of options. - // - // Normally, version-negotiation (if enabled) would not happen until - // the API request is made. - cli.checkVersion(ctx) +// NewVersionError returns an error if the APIVersion required +// if less than the current supported version +func (cli *Client) NewVersionError(APIrequired, feature string) error { if cli.version != "" && versions.LessThan(cli.version, APIrequired) { return fmt.Errorf("%q requires API version %s, but the Docker daemon API version is %s", feature, APIrequired, cli.version) } diff --git a/test/integration/vendor/github.com/docker/docker/client/hijack.go b/test/integration/vendor/github.com/docker/docker/client/hijack.go index 839d4c5cd6..7e84865f69 100644 --- a/test/integration/vendor/github.com/docker/docker/client/hijack.go +++ b/test/integration/vendor/github.com/docker/docker/client/hijack.go @@ -3,16 +3,18 @@ package client // import "github.com/docker/docker/client" import ( "bufio" "context" + "crypto/tls" "fmt" "net" "net/http" + "net/http/httputil" "net/url" "time" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" + "github.com/docker/go-connections/sockets" "github.com/pkg/errors" - "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ) // postHijacked sends a POST request and hijacks the connection. @@ -21,11 +23,11 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu if err != nil { return types.HijackedResponse{}, err } - req, err := cli.buildRequest(ctx, http.MethodPost, cli.getAPIPath(ctx, path, query), bodyEncoded, headers) + req, err := cli.buildRequest(http.MethodPost, cli.getAPIPath(ctx, path, query), bodyEncoded, headers) if err != nil { return types.HijackedResponse{}, err } - conn, mediaType, err := cli.setupHijackConn(req, "tcp") + conn, mediaType, err := cli.setupHijackConn(ctx, req, "tcp") if err != nil { return types.HijackedResponse{}, err } @@ -35,18 +37,29 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu // DialHijack returns a hijacked connection with negotiated protocol proto. func (cli *Client) DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error) { - req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, nil) + req, err := http.NewRequest(http.MethodPost, url, nil) if err != nil { return nil, err } req = cli.addHeaders(req, meta) - conn, _, err := cli.setupHijackConn(req, proto) + conn, _, err := cli.setupHijackConn(ctx, req, proto) return conn, err } -func (cli *Client) setupHijackConn(req *http.Request, proto string) (_ net.Conn, _ string, retErr error) { - ctx := req.Context() +// fallbackDial is used when WithDialer() was not called. +// See cli.Dialer(). +func fallbackDial(proto, addr string, tlsConfig *tls.Config) (net.Conn, error) { + if tlsConfig != nil && proto != "unix" && proto != "npipe" { + return tls.Dial(proto, addr, tlsConfig) + } + if proto == "npipe" { + return sockets.DialPipe(addr, 32*time.Second) + } + return net.Dial(proto, addr) +} + +func (cli *Client) setupHijackConn(ctx context.Context, req *http.Request, proto string) (net.Conn, string, error) { req.Header.Set("Connection", "Upgrade") req.Header.Set("Upgrade", proto) @@ -55,11 +68,6 @@ func (cli *Client) setupHijackConn(req *http.Request, proto string) (_ net.Conn, if err != nil { return nil, "", errors.Wrap(err, "cannot connect to the Docker daemon. Is 'docker daemon' running on this host?") } - defer func() { - if retErr != nil { - conn.Close() - } - }() // When we set up a TCP connection for hijack, there could be long periods // of inactivity (a long running command with no output) that in certain @@ -71,29 +79,35 @@ func (cli *Client) setupHijackConn(req *http.Request, proto string) (_ net.Conn, _ = tcpConn.SetKeepAlivePeriod(30 * time.Second) } - hc := &hijackedConn{conn, bufio.NewReader(conn)} + clientconn := httputil.NewClientConn(conn, nil) + defer clientconn.Close() // Server hijacks the connection, error 'connection closed' expected - resp, err := otelhttp.NewTransport(hc).RoundTrip(req) - if err != nil { - return nil, "", err - } - if resp.StatusCode != http.StatusSwitchingProtocols { - _ = resp.Body.Close() - return nil, "", fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode) + resp, err := clientconn.Do(req) + + //nolint:staticcheck // ignore SA1019 for connecting to old (pre go1.8) daemons + if err != httputil.ErrPersistEOF { + if err != nil { + return nil, "", err + } + if resp.StatusCode != http.StatusSwitchingProtocols { + _ = resp.Body.Close() + return nil, "", fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode) + } } - if hc.r.Buffered() > 0 { + c, br := clientconn.Hijack() + if br.Buffered() > 0 { // If there is buffered content, wrap the connection. We return an // object that implements CloseWrite if the underlying connection // implements it. - if _, ok := hc.Conn.(types.CloseWriter); ok { - conn = &hijackedConnCloseWriter{hc} + if _, ok := c.(types.CloseWriter); ok { + c = &hijackedConnCloseWriter{&hijackedConn{c, br}} } else { - conn = hc + c = &hijackedConn{c, br} } } else { - hc.r.Reset(nil) + br.Reset(nil) } var mediaType string @@ -102,7 +116,7 @@ func (cli *Client) setupHijackConn(req *http.Request, proto string) (_ net.Conn, mediaType = resp.Header.Get("Content-Type") } - return conn, mediaType, nil + return c, mediaType, nil } // hijackedConn wraps a net.Conn and is returned by setupHijackConn in the case @@ -114,13 +128,6 @@ type hijackedConn struct { r *bufio.Reader } -func (c *hijackedConn) RoundTrip(req *http.Request) (*http.Response, error) { - if err := req.Write(c.Conn); err != nil { - return nil, err - } - return http.ReadResponse(c.r, req) -} - func (c *hijackedConn) Read(b []byte) (int, error) { return c.r.Read(b) } diff --git a/test/integration/vendor/github.com/docker/docker/client/image_build.go b/test/integration/vendor/github.com/docker/docker/client/image_build.go index d294ddc8b2..d16e1d8ea9 100644 --- a/test/integration/vendor/github.com/docker/docker/client/image_build.go +++ b/test/integration/vendor/github.com/docker/docker/client/image_build.go @@ -18,18 +18,18 @@ import ( // The Body in the response implements an io.ReadCloser and it's up to the caller to // close it. func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) { - query, err := cli.imageBuildOptionsToQuery(ctx, options) + query, err := cli.imageBuildOptionsToQuery(options) if err != nil { return types.ImageBuildResponse{}, err } + headers := http.Header(make(map[string][]string)) buf, err := json.Marshal(options.AuthConfigs) if err != nil { return types.ImageBuildResponse{}, err } - - headers := http.Header{} headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf)) + headers.Set("Content-Type", "application/x-tar") serverResp, err := cli.postRaw(ctx, "/build", query, buildContext, headers) @@ -37,13 +37,15 @@ func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, optio return types.ImageBuildResponse{}, err } + osType := getDockerOS(serverResp.header.Get("Server")) + return types.ImageBuildResponse{ Body: serverResp.body, - OSType: getDockerOS(serverResp.header.Get("Server")), + OSType: osType, }, nil } -func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options types.ImageBuildOptions) (url.Values, error) { +func (cli *Client) imageBuildOptionsToQuery(options types.ImageBuildOptions) (url.Values, error) { query := url.Values{ "t": options.Tags, "securityopt": options.SecurityOpt, @@ -73,7 +75,7 @@ func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options types.I } if options.Squash { - if err := cli.NewVersionError(ctx, "1.25", "squash"); err != nil { + if err := cli.NewVersionError("1.25", "squash"); err != nil { return query, err } query.Set("squash", "1") @@ -123,7 +125,7 @@ func (cli *Client) imageBuildOptionsToQuery(ctx context.Context, options types.I query.Set("session", options.SessionID) } if options.Platform != "" { - if err := cli.NewVersionError(ctx, "1.32", "platform"); err != nil { + if err := cli.NewVersionError("1.32", "platform"); err != nil { return query, err } query.Set("platform", strings.ToLower(options.Platform)) diff --git a/test/integration/vendor/github.com/docker/docker/client/image_create.go b/test/integration/vendor/github.com/docker/docker/client/image_create.go index 29cd0b4373..6a9b708f7d 100644 --- a/test/integration/vendor/github.com/docker/docker/client/image_create.go +++ b/test/integration/vendor/github.com/docker/docker/client/image_create.go @@ -3,11 +3,10 @@ package client // import "github.com/docker/docker/client" import ( "context" "io" - "net/http" "net/url" "strings" - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/registry" ) @@ -34,7 +33,6 @@ func (cli *Client) ImageCreate(ctx context.Context, parentReference string, opti } func (cli *Client) tryImageCreate(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) { - return cli.post(ctx, "/images/create", query, nil, http.Header{ - registry.AuthHeader: {registryAuth}, - }) + headers := map[string][]string{registry.AuthHeader: {registryAuth}} + return cli.post(ctx, "/images/create", query, nil, headers) } diff --git a/test/integration/vendor/github.com/docker/docker/client/image_import.go b/test/integration/vendor/github.com/docker/docker/client/image_import.go index cd376a14e5..c5de42cb79 100644 --- a/test/integration/vendor/github.com/docker/docker/client/image_import.go +++ b/test/integration/vendor/github.com/docker/docker/client/image_import.go @@ -6,7 +6,7 @@ import ( "net/url" "strings" - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" ) diff --git a/test/integration/vendor/github.com/docker/docker/client/image_list.go b/test/integration/vendor/github.com/docker/docker/client/image_list.go index f3f2280e32..950d513334 100644 --- a/test/integration/vendor/github.com/docker/docker/client/image_list.go +++ b/test/integration/vendor/github.com/docker/docker/client/image_list.go @@ -7,20 +7,12 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/versions" ) // ImageList returns a list of images in the docker host. -func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]image.Summary, error) { - // Make sure we negotiated (if the client is configured to do so), - // as code below contains API-version specific handling of options. - // - // Normally, version-negotiation (if enabled) would not happen until - // the API request is made. - cli.checkVersion(ctx) - - var images []image.Summary +func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) { + var images []types.ImageSummary query := url.Values{} optionFilters := options.Filters diff --git a/test/integration/vendor/github.com/docker/docker/client/image_load.go b/test/integration/vendor/github.com/docker/docker/client/image_load.go index c825206ea5..91016e493c 100644 --- a/test/integration/vendor/github.com/docker/docker/client/image_load.go +++ b/test/integration/vendor/github.com/docker/docker/client/image_load.go @@ -3,7 +3,6 @@ package client // import "github.com/docker/docker/client" import ( "context" "io" - "net/http" "net/url" "github.com/docker/docker/api/types" @@ -18,9 +17,8 @@ func (cli *Client) ImageLoad(ctx context.Context, input io.Reader, quiet bool) ( if quiet { v.Set("quiet", "1") } - resp, err := cli.postRaw(ctx, "/images/load", v, input, http.Header{ - "Content-Type": {"application/x-tar"}, - }) + headers := map[string][]string{"Content-Type": {"application/x-tar"}} + resp, err := cli.postRaw(ctx, "/images/load", v, input, headers) if err != nil { return types.ImageLoadResponse{}, err } diff --git a/test/integration/vendor/github.com/docker/docker/client/image_prune.go b/test/integration/vendor/github.com/docker/docker/client/image_prune.go index 6b82d6ab6c..56af6d7f98 100644 --- a/test/integration/vendor/github.com/docker/docker/client/image_prune.go +++ b/test/integration/vendor/github.com/docker/docker/client/image_prune.go @@ -13,7 +13,7 @@ import ( func (cli *Client) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (types.ImagesPruneReport, error) { var report types.ImagesPruneReport - if err := cli.NewVersionError(ctx, "1.25", "image prune"); err != nil { + if err := cli.NewVersionError("1.25", "image prune"); err != nil { return report, err } diff --git a/test/integration/vendor/github.com/docker/docker/client/image_pull.go b/test/integration/vendor/github.com/docker/docker/client/image_pull.go index d92049d588..a23975591b 100644 --- a/test/integration/vendor/github.com/docker/docker/client/image_pull.go +++ b/test/integration/vendor/github.com/docker/docker/client/image_pull.go @@ -6,7 +6,7 @@ import ( "net/url" "strings" - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/errdefs" ) diff --git a/test/integration/vendor/github.com/docker/docker/client/image_push.go b/test/integration/vendor/github.com/docker/docker/client/image_push.go index 6839a89e07..dd1b8f3471 100644 --- a/test/integration/vendor/github.com/docker/docker/client/image_push.go +++ b/test/integration/vendor/github.com/docker/docker/client/image_push.go @@ -4,10 +4,9 @@ import ( "context" "errors" "io" - "net/http" "net/url" - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/errdefs" @@ -51,7 +50,6 @@ func (cli *Client) ImagePush(ctx context.Context, image string, options types.Im } func (cli *Client) tryImagePush(ctx context.Context, imageID string, query url.Values, registryAuth string) (serverResponse, error) { - return cli.post(ctx, "/images/"+imageID+"/push", query, nil, http.Header{ - registry.AuthHeader: {registryAuth}, - }) + headers := map[string][]string{registry.AuthHeader: {registryAuth}} + return cli.post(ctx, "/images/"+imageID+"/push", query, nil, headers) } diff --git a/test/integration/vendor/github.com/docker/docker/client/image_remove.go b/test/integration/vendor/github.com/docker/docker/client/image_remove.go index b936d20830..6a9fb3f41f 100644 --- a/test/integration/vendor/github.com/docker/docker/client/image_remove.go +++ b/test/integration/vendor/github.com/docker/docker/client/image_remove.go @@ -6,11 +6,10 @@ import ( "net/url" "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/image" ) // ImageRemove removes an image from the docker host. -func (cli *Client) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) { +func (cli *Client) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) { query := url.Values{} if options.Force { @@ -20,7 +19,7 @@ func (cli *Client) ImageRemove(ctx context.Context, imageID string, options type query.Set("noprune", "1") } - var dels []image.DeleteResponse + var dels []types.ImageDeleteResponseItem resp, err := cli.delete(ctx, "/images/"+imageID, query, nil) defer ensureReaderClosed(resp) if err != nil { diff --git a/test/integration/vendor/github.com/docker/docker/client/image_search.go b/test/integration/vendor/github.com/docker/docker/client/image_search.go index 8971b139ae..5f0c49ed30 100644 --- a/test/integration/vendor/github.com/docker/docker/client/image_search.go +++ b/test/integration/vendor/github.com/docker/docker/client/image_search.go @@ -3,7 +3,6 @@ package client // import "github.com/docker/docker/client" import ( "context" "encoding/json" - "net/http" "net/url" "strconv" @@ -49,7 +48,6 @@ func (cli *Client) ImageSearch(ctx context.Context, term string, options types.I } func (cli *Client) tryImageSearch(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) { - return cli.get(ctx, "/images/search", query, http.Header{ - registry.AuthHeader: {registryAuth}, - }) + headers := map[string][]string{registry.AuthHeader: {registryAuth}} + return cli.get(ctx, "/images/search", query, headers) } diff --git a/test/integration/vendor/github.com/docker/docker/client/image_tag.go b/test/integration/vendor/github.com/docker/docker/client/image_tag.go index ea6b4a1e65..5652bfc252 100644 --- a/test/integration/vendor/github.com/docker/docker/client/image_tag.go +++ b/test/integration/vendor/github.com/docker/docker/client/image_tag.go @@ -4,7 +4,7 @@ import ( "context" "net/url" - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/pkg/errors" ) diff --git a/test/integration/vendor/github.com/docker/docker/client/info.go b/test/integration/vendor/github.com/docker/docker/client/info.go index cc3fcc4670..c856704e23 100644 --- a/test/integration/vendor/github.com/docker/docker/client/info.go +++ b/test/integration/vendor/github.com/docker/docker/client/info.go @@ -6,12 +6,12 @@ import ( "fmt" "net/url" - "github.com/docker/docker/api/types/system" + "github.com/docker/docker/api/types" ) // Info returns information about the docker server. -func (cli *Client) Info(ctx context.Context) (system.Info, error) { - var info system.Info +func (cli *Client) Info(ctx context.Context) (types.Info, error) { + var info types.Info serverResp, err := cli.get(ctx, "/info", url.Values{}, nil) defer ensureReaderClosed(serverResp) if err != nil { diff --git a/test/integration/vendor/github.com/docker/docker/client/interface.go b/test/integration/vendor/github.com/docker/docker/client/interface.go index 302f5fb13e..7993c5a48f 100644 --- a/test/integration/vendor/github.com/docker/docker/client/interface.go +++ b/test/integration/vendor/github.com/docker/docker/client/interface.go @@ -14,7 +14,6 @@ import ( "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/api/types/system" "github.com/docker/docker/api/types/volume" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) @@ -46,30 +45,30 @@ type CommonAPIClient interface { // ContainerAPIClient defines API client methods for the containers type ContainerAPIClient interface { - ContainerAttach(ctx context.Context, container string, options container.AttachOptions) (types.HijackedResponse, error) - ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (types.IDResponse, error) + ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) + ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) ContainerDiff(ctx context.Context, container string) ([]container.FilesystemChange, error) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) - ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error + ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error ContainerExport(ctx context.Context, container string) (io.ReadCloser, error) ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error) ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error) ContainerKill(ctx context.Context, container, signal string) error - ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error) - ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error) + ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) + ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) ContainerPause(ctx context.Context, container string) error - ContainerRemove(ctx context.Context, container string, options container.RemoveOptions) error + ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error ContainerRename(ctx context.Context, container, newContainerName string) error - ContainerResize(ctx context.Context, container string, options container.ResizeOptions) error + ContainerResize(ctx context.Context, container string, options types.ResizeOptions) error ContainerRestart(ctx context.Context, container string, options container.StopOptions) error ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error) ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error) ContainerStatsOneShot(ctx context.Context, container string) (types.ContainerStats, error) - ContainerStart(ctx context.Context, container string, options container.StartOptions) error + ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error ContainerStop(ctx context.Context, container string, options container.StopOptions) error ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error) ContainerUnpause(ctx context.Context, container string) error @@ -94,11 +93,11 @@ type ImageAPIClient interface { ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error) ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error) - ImageList(ctx context.Context, options types.ImageListOptions) ([]image.Summary, error) + ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error) ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error) ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) - ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) + ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error) ImageSave(ctx context.Context, images []string) (io.ReadCloser, error) ImageTag(ctx context.Context, image, ref string) error @@ -141,13 +140,13 @@ type PluginAPIClient interface { // ServiceAPIClient defines API client methods for the services type ServiceAPIClient interface { - ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) + ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) ServiceRemove(ctx context.Context, serviceID string) error - ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) - ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error) - TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error) + ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) + ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error) + TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) } @@ -166,7 +165,7 @@ type SwarmAPIClient interface { // SystemAPIClient defines API client methods for the system type SystemAPIClient interface { Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) - Info(ctx context.Context) (system.Info, error) + Info(ctx context.Context) (types.Info, error) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) Ping(ctx context.Context) (types.Ping, error) diff --git a/test/integration/vendor/github.com/docker/docker/client/interface_experimental.go b/test/integration/vendor/github.com/docker/docker/client/interface_experimental.go index c585c10459..402ffb512c 100644 --- a/test/integration/vendor/github.com/docker/docker/client/interface_experimental.go +++ b/test/integration/vendor/github.com/docker/docker/client/interface_experimental.go @@ -3,7 +3,7 @@ package client // import "github.com/docker/docker/client" import ( "context" - "github.com/docker/docker/api/types/checkpoint" + "github.com/docker/docker/api/types" ) type apiClientExperimental interface { @@ -12,7 +12,7 @@ type apiClientExperimental interface { // CheckpointAPIClient defines API client methods for the checkpoints type CheckpointAPIClient interface { - CheckpointCreate(ctx context.Context, container string, options checkpoint.CreateOptions) error - CheckpointDelete(ctx context.Context, container string, options checkpoint.DeleteOptions) error - CheckpointList(ctx context.Context, container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) + CheckpointCreate(ctx context.Context, container string, options types.CheckpointCreateOptions) error + CheckpointDelete(ctx context.Context, container string, options types.CheckpointDeleteOptions) error + CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) } diff --git a/test/integration/vendor/github.com/docker/docker/client/network_create.go b/test/integration/vendor/github.com/docker/docker/client/network_create.go index 668e87d653..278d9383a8 100644 --- a/test/integration/vendor/github.com/docker/docker/client/network_create.go +++ b/test/integration/vendor/github.com/docker/docker/client/network_create.go @@ -5,26 +5,14 @@ import ( "encoding/json" "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/versions" ) // NetworkCreate creates a new network in the docker host. func (cli *Client) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) { - // Make sure we negotiated (if the client is configured to do so), - // as code below contains API-version specific handling of options. - // - // Normally, version-negotiation (if enabled) would not happen until - // the API request is made. - cli.checkVersion(ctx) - networkCreateRequest := types.NetworkCreateRequest{ NetworkCreate: options, Name: name, } - if versions.LessThan(cli.version, "1.44") { - networkCreateRequest.CheckDuplicate = true //nolint:staticcheck // ignore SA1019: CheckDuplicate is deprecated since API v1.44. - } - var response types.NetworkCreateResponse serverResp, err := cli.post(ctx, "/networks/create", nil, networkCreateRequest, nil) defer ensureReaderClosed(serverResp) diff --git a/test/integration/vendor/github.com/docker/docker/client/network_prune.go b/test/integration/vendor/github.com/docker/docker/client/network_prune.go index 7b5f831ef7..cebb188219 100644 --- a/test/integration/vendor/github.com/docker/docker/client/network_prune.go +++ b/test/integration/vendor/github.com/docker/docker/client/network_prune.go @@ -13,7 +13,7 @@ import ( func (cli *Client) NetworksPrune(ctx context.Context, pruneFilters filters.Args) (types.NetworksPruneReport, error) { var report types.NetworksPruneReport - if err := cli.NewVersionError(ctx, "1.25", "network prune"); err != nil { + if err := cli.NewVersionError("1.25", "network prune"); err != nil { return report, err } diff --git a/test/integration/vendor/github.com/docker/docker/client/node_list.go b/test/integration/vendor/github.com/docker/docker/client/node_list.go index 1a9e6bfb1b..c212906bc7 100644 --- a/test/integration/vendor/github.com/docker/docker/client/node_list.go +++ b/test/integration/vendor/github.com/docker/docker/client/node_list.go @@ -16,6 +16,7 @@ func (cli *Client) NodeList(ctx context.Context, options types.NodeListOptions) if options.Filters.Len() > 0 { filterJSON, err := filters.ToJSON(options.Filters) + if err != nil { return nil, err } diff --git a/test/integration/vendor/github.com/docker/docker/client/options.go b/test/integration/vendor/github.com/docker/docker/client/options.go index ddb0ca3991..099ad41846 100644 --- a/test/integration/vendor/github.com/docker/docker/client/options.go +++ b/test/integration/vendor/github.com/docker/docker/client/options.go @@ -11,25 +11,25 @@ import ( "github.com/docker/go-connections/sockets" "github.com/docker/go-connections/tlsconfig" "github.com/pkg/errors" - "go.opentelemetry.io/otel/trace" ) -// Opt is a configuration option to initialize a [Client]. +// Opt is a configuration option to initialize a client type Opt func(*Client) error -// FromEnv configures the client with values from environment variables. It -// is the equivalent of using the [WithTLSClientConfigFromEnv], [WithHostFromEnv], -// and [WithVersionFromEnv] options. +// FromEnv configures the client with values from environment variables. // // FromEnv uses the following environment variables: // -// - DOCKER_HOST ([EnvOverrideHost]) to set the URL to the docker server. -// - DOCKER_API_VERSION ([EnvOverrideAPIVersion]) to set the version of the -// API to use, leave empty for latest. -// - DOCKER_CERT_PATH ([EnvOverrideCertPath]) to specify the directory from -// which to load the TLS certificates ("ca.pem", "cert.pem", "key.pem'). -// - DOCKER_TLS_VERIFY ([EnvTLSVerify]) to enable or disable TLS verification -// (off by default). +// DOCKER_HOST (EnvOverrideHost) to set the URL to the docker server. +// +// DOCKER_API_VERSION (EnvOverrideAPIVersion) to set the version of the API to +// use, leave empty for latest. +// +// DOCKER_CERT_PATH (EnvOverrideCertPath) to specify the directory from which to +// load the TLS certificates (ca.pem, cert.pem, key.pem). +// +// DOCKER_TLS_VERIFY (EnvTLSVerify) to enable or disable TLS verification (off by +// default). func FromEnv(c *Client) error { ops := []Opt{ WithTLSClientConfigFromEnv(), @@ -45,8 +45,7 @@ func FromEnv(c *Client) error { } // WithDialContext applies the dialer to the client transport. This can be -// used to set the Timeout and KeepAlive settings of the client. It returns -// an error if the client does not have a [http.Transport] configured. +// used to set the Timeout and KeepAlive settings of the client. func WithDialContext(dialContext func(ctx context.Context, network, addr string) (net.Conn, error)) Opt { return func(c *Client) error { if transport, ok := c.client.Transport.(*http.Transport); ok { @@ -76,7 +75,7 @@ func WithHost(host string) Opt { } // WithHostFromEnv overrides the client host with the host specified in the -// DOCKER_HOST ([EnvOverrideHost]) environment variable. If DOCKER_HOST is not set, +// DOCKER_HOST (EnvOverrideHost) environment variable. If DOCKER_HOST is not set, // or set to an empty value, the host is not modified. func WithHostFromEnv() Opt { return func(c *Client) error { @@ -87,7 +86,7 @@ func WithHostFromEnv() Opt { } } -// WithHTTPClient overrides the client's HTTP client with the specified one. +// WithHTTPClient overrides the client http client with the specified one func WithHTTPClient(client *http.Client) Opt { return func(c *Client) error { if client != nil { @@ -97,7 +96,7 @@ func WithHTTPClient(client *http.Client) Opt { } } -// WithTimeout configures the time limit for requests made by the HTTP client. +// WithTimeout configures the time limit for requests made by the HTTP client func WithTimeout(timeout time.Duration) Opt { return func(c *Client) error { c.client.Timeout = timeout @@ -105,19 +104,7 @@ func WithTimeout(timeout time.Duration) Opt { } } -// WithUserAgent configures the User-Agent header to use for HTTP requests. -// It overrides any User-Agent set in headers. When set to an empty string, -// the User-Agent header is removed, and no header is sent. -func WithUserAgent(ua string) Opt { - return func(c *Client) error { - c.userAgent = &ua - return nil - } -} - -// WithHTTPHeaders appends custom HTTP headers to the client's default headers. -// It does not allow for built-in headers (such as "User-Agent", if set) to -// be overridden. Also see [WithUserAgent]. +// WithHTTPHeaders overrides the client default http headers func WithHTTPHeaders(headers map[string]string) Opt { return func(c *Client) error { c.customHTTPHeaders = headers @@ -125,7 +112,7 @@ func WithHTTPHeaders(headers map[string]string) Opt { } } -// WithScheme overrides the client scheme with the specified one. +// WithScheme overrides the client scheme with the specified one func WithScheme(scheme string) Opt { return func(c *Client) error { c.scheme = scheme @@ -133,50 +120,51 @@ func WithScheme(scheme string) Opt { } } -// WithTLSClientConfig applies a TLS config to the client transport. +// WithTLSClientConfig applies a tls config to the client transport. func WithTLSClientConfig(cacertPath, certPath, keyPath string) Opt { return func(c *Client) error { - transport, ok := c.client.Transport.(*http.Transport) - if !ok { - return errors.Errorf("cannot apply tls config to transport: %T", c.client.Transport) - } - config, err := tlsconfig.Client(tlsconfig.Options{ + opts := tlsconfig.Options{ CAFile: cacertPath, CertFile: certPath, KeyFile: keyPath, ExclusiveRootPools: true, - }) + } + config, err := tlsconfig.Client(opts) if err != nil { return errors.Wrap(err, "failed to create tls config") } - transport.TLSClientConfig = config - return nil + if transport, ok := c.client.Transport.(*http.Transport); ok { + transport.TLSClientConfig = config + return nil + } + return errors.Errorf("cannot apply tls config to transport: %T", c.client.Transport) } } // WithTLSClientConfigFromEnv configures the client's TLS settings with the -// settings in the DOCKER_CERT_PATH ([EnvOverrideCertPath]) and DOCKER_TLS_VERIFY -// ([EnvTLSVerify]) environment variables. If DOCKER_CERT_PATH is not set or empty, -// TLS configuration is not modified. +// settings in the DOCKER_CERT_PATH and DOCKER_TLS_VERIFY environment variables. +// If DOCKER_CERT_PATH is not set or empty, TLS configuration is not modified. // // WithTLSClientConfigFromEnv uses the following environment variables: // -// - DOCKER_CERT_PATH ([EnvOverrideCertPath]) to specify the directory from -// which to load the TLS certificates ("ca.pem", "cert.pem", "key.pem"). -// - DOCKER_TLS_VERIFY ([EnvTLSVerify]) to enable or disable TLS verification -// (off by default). +// DOCKER_CERT_PATH (EnvOverrideCertPath) to specify the directory from which to +// load the TLS certificates (ca.pem, cert.pem, key.pem). +// +// DOCKER_TLS_VERIFY (EnvTLSVerify) to enable or disable TLS verification (off by +// default). func WithTLSClientConfigFromEnv() Opt { return func(c *Client) error { dockerCertPath := os.Getenv(EnvOverrideCertPath) if dockerCertPath == "" { return nil } - tlsc, err := tlsconfig.Client(tlsconfig.Options{ + options := tlsconfig.Options{ CAFile: filepath.Join(dockerCertPath, "ca.pem"), CertFile: filepath.Join(dockerCertPath, "cert.pem"), KeyFile: filepath.Join(dockerCertPath, "key.pem"), InsecureSkipVerify: os.Getenv(EnvTLSVerify) == "", - }) + } + tlsc, err := tlsconfig.Client(options) if err != nil { return err } @@ -190,8 +178,7 @@ func WithTLSClientConfigFromEnv() Opt { } // WithVersion overrides the client version with the specified one. If an empty -// version is provided, the value is ignored to allow version negotiation -// (see [WithAPIVersionNegotiation]). +// version is specified, the value will be ignored to allow version negotiation. func WithVersion(version string) Opt { return func(c *Client) error { if version != "" { @@ -203,9 +190,8 @@ func WithVersion(version string) Opt { } // WithVersionFromEnv overrides the client version with the version specified in -// the DOCKER_API_VERSION ([EnvOverrideAPIVersion]) environment variable. -// If DOCKER_API_VERSION is not set, or set to an empty value, the version -// is not modified. +// the DOCKER_API_VERSION environment variable. If DOCKER_API_VERSION is not set, +// the version is not modified. func WithVersionFromEnv() Opt { return func(c *Client) error { return WithVersion(os.Getenv(EnvOverrideAPIVersion))(c) @@ -215,19 +201,10 @@ func WithVersionFromEnv() Opt { // WithAPIVersionNegotiation enables automatic API version negotiation for the client. // With this option enabled, the client automatically negotiates the API version // to use when making requests. API version negotiation is performed on the first -// request; subsequent requests do not re-negotiate. +// request; subsequent requests will not re-negotiate. func WithAPIVersionNegotiation() Opt { return func(c *Client) error { c.negotiateVersion = true return nil } } - -// WithTraceProvider sets the trace provider for the client. -// If this is not set then the global trace provider will be used. -func WithTraceProvider(provider trace.TracerProvider) Opt { - return func(c *Client) error { - c.tp = provider - return nil - } -} diff --git a/test/integration/vendor/github.com/docker/docker/client/ping.go b/test/integration/vendor/github.com/docker/docker/client/ping.go index dfd1042fab..347ae71e02 100644 --- a/test/integration/vendor/github.com/docker/docker/client/ping.go +++ b/test/integration/vendor/github.com/docker/docker/client/ping.go @@ -21,11 +21,11 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) { // Using cli.buildRequest() + cli.doRequest() instead of cli.sendRequest() // because ping requests are used during API version negotiation, so we want // to hit the non-versioned /_ping endpoint, not /v1.xx/_ping - req, err := cli.buildRequest(ctx, http.MethodHead, path.Join(cli.basePath, "/_ping"), nil, nil) + req, err := cli.buildRequest(http.MethodHead, path.Join(cli.basePath, "/_ping"), nil, nil) if err != nil { return ping, err } - serverResp, err := cli.doRequest(req) + serverResp, err := cli.doRequest(ctx, req) if err == nil { defer ensureReaderClosed(serverResp) switch serverResp.statusCode { @@ -37,9 +37,11 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) { return ping, err } - // HEAD failed; fallback to GET. - req.Method = http.MethodGet - serverResp, err = cli.doRequest(req) + req, err = cli.buildRequest(http.MethodGet, path.Join(cli.basePath, "/_ping"), nil, nil) + if err != nil { + return ping, err + } + serverResp, err = cli.doRequest(ctx, req) defer ensureReaderClosed(serverResp) if err != nil { return ping, err diff --git a/test/integration/vendor/github.com/docker/docker/client/plugin_install.go b/test/integration/vendor/github.com/docker/docker/client/plugin_install.go index 69184619a2..3a740ec4f6 100644 --- a/test/integration/vendor/github.com/docker/docker/client/plugin_install.go +++ b/test/integration/vendor/github.com/docker/docker/client/plugin_install.go @@ -4,10 +4,9 @@ import ( "context" "encoding/json" "io" - "net/http" "net/url" - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/errdefs" @@ -69,15 +68,13 @@ func (cli *Client) PluginInstall(ctx context.Context, name string, options types } func (cli *Client) tryPluginPrivileges(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) { - return cli.get(ctx, "/plugins/privileges", query, http.Header{ - registry.AuthHeader: {registryAuth}, - }) + headers := map[string][]string{registry.AuthHeader: {registryAuth}} + return cli.get(ctx, "/plugins/privileges", query, headers) } func (cli *Client) tryPluginPull(ctx context.Context, query url.Values, privileges types.PluginPrivileges, registryAuth string) (serverResponse, error) { - return cli.post(ctx, "/plugins/pull", query, privileges, http.Header{ - registry.AuthHeader: {registryAuth}, - }) + headers := map[string][]string{registry.AuthHeader: {registryAuth}} + return cli.post(ctx, "/plugins/pull", query, privileges, headers) } func (cli *Client) checkPluginPermissions(ctx context.Context, query url.Values, options types.PluginInstallOptions) (types.PluginPrivileges, error) { diff --git a/test/integration/vendor/github.com/docker/docker/client/plugin_push.go b/test/integration/vendor/github.com/docker/docker/client/plugin_push.go index 8f68a86eee..18f9754c4c 100644 --- a/test/integration/vendor/github.com/docker/docker/client/plugin_push.go +++ b/test/integration/vendor/github.com/docker/docker/client/plugin_push.go @@ -3,16 +3,14 @@ package client // import "github.com/docker/docker/client" import ( "context" "io" - "net/http" "github.com/docker/docker/api/types/registry" ) // PluginPush pushes a plugin to a registry func (cli *Client) PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error) { - resp, err := cli.post(ctx, "/plugins/"+name+"/push", nil, nil, http.Header{ - registry.AuthHeader: {registryAuth}, - }) + headers := map[string][]string{registry.AuthHeader: {registryAuth}} + resp, err := cli.post(ctx, "/plugins/"+name+"/push", nil, nil, headers) if err != nil { return nil, err } diff --git a/test/integration/vendor/github.com/docker/docker/client/plugin_upgrade.go b/test/integration/vendor/github.com/docker/docker/client/plugin_upgrade.go index 5cade450f4..995d1fd2ca 100644 --- a/test/integration/vendor/github.com/docker/docker/client/plugin_upgrade.go +++ b/test/integration/vendor/github.com/docker/docker/client/plugin_upgrade.go @@ -3,10 +3,9 @@ package client // import "github.com/docker/docker/client" import ( "context" "io" - "net/http" "net/url" - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/registry" "github.com/pkg/errors" @@ -14,7 +13,7 @@ import ( // PluginUpgrade upgrades a plugin func (cli *Client) PluginUpgrade(ctx context.Context, name string, options types.PluginInstallOptions) (rc io.ReadCloser, err error) { - if err := cli.NewVersionError(ctx, "1.26", "plugin upgrade"); err != nil { + if err := cli.NewVersionError("1.26", "plugin upgrade"); err != nil { return nil, err } query := url.Values{} @@ -36,7 +35,6 @@ func (cli *Client) PluginUpgrade(ctx context.Context, name string, options types } func (cli *Client) tryPluginUpgrade(ctx context.Context, query url.Values, privileges types.PluginPrivileges, name, registryAuth string) (serverResponse, error) { - return cli.post(ctx, "/plugins/"+name+"/upgrade", query, privileges, http.Header{ - registry.AuthHeader: {registryAuth}, - }) + headers := map[string][]string{registry.AuthHeader: {registryAuth}} + return cli.post(ctx, "/plugins/"+name+"/upgrade", query, privileges, headers) } diff --git a/test/integration/vendor/github.com/docker/docker/client/request.go b/test/integration/vendor/github.com/docker/docker/client/request.go index efe07bb9ea..bcedcf3bd9 100644 --- a/test/integration/vendor/github.com/docker/docker/client/request.go +++ b/test/integration/vendor/github.com/docker/docker/client/request.go @@ -10,7 +10,6 @@ import ( "net/http" "net/url" "os" - "reflect" "strings" "github.com/docker/docker/api/types" @@ -28,17 +27,17 @@ type serverResponse struct { } // head sends an http request to the docker API using the method HEAD. -func (cli *Client) head(ctx context.Context, path string, query url.Values, headers http.Header) (serverResponse, error) { +func (cli *Client) head(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) { return cli.sendRequest(ctx, http.MethodHead, path, query, nil, headers) } // get sends an http request to the docker API using the method GET with a specific Go context. -func (cli *Client) get(ctx context.Context, path string, query url.Values, headers http.Header) (serverResponse, error) { +func (cli *Client) get(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) { return cli.sendRequest(ctx, http.MethodGet, path, query, nil, headers) } // post sends an http request to the docker API using the method POST with a specific Go context. -func (cli *Client) post(ctx context.Context, path string, query url.Values, obj interface{}, headers http.Header) (serverResponse, error) { +func (cli *Client) post(ctx context.Context, path string, query url.Values, obj interface{}, headers map[string][]string) (serverResponse, error) { body, headers, err := encodeBody(obj, headers) if err != nil { return serverResponse{}, err @@ -46,44 +45,34 @@ func (cli *Client) post(ctx context.Context, path string, query url.Values, obj return cli.sendRequest(ctx, http.MethodPost, path, query, body, headers) } -func (cli *Client) postRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers http.Header) (serverResponse, error) { +func (cli *Client) postRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) { return cli.sendRequest(ctx, http.MethodPost, path, query, body, headers) } -func (cli *Client) put(ctx context.Context, path string, query url.Values, obj interface{}, headers http.Header) (serverResponse, error) { +func (cli *Client) put(ctx context.Context, path string, query url.Values, obj interface{}, headers map[string][]string) (serverResponse, error) { body, headers, err := encodeBody(obj, headers) if err != nil { return serverResponse{}, err } - return cli.putRaw(ctx, path, query, body, headers) + return cli.sendRequest(ctx, http.MethodPut, path, query, body, headers) } // putRaw sends an http request to the docker API using the method PUT. -func (cli *Client) putRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers http.Header) (serverResponse, error) { - // PUT requests are expected to always have a body (apparently) - // so explicitly pass an empty body to sendRequest to signal that - // it should set the Content-Type header if not already present. - if body == nil { - body = http.NoBody - } +func (cli *Client) putRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) { return cli.sendRequest(ctx, http.MethodPut, path, query, body, headers) } // delete sends an http request to the docker API using the method DELETE. -func (cli *Client) delete(ctx context.Context, path string, query url.Values, headers http.Header) (serverResponse, error) { +func (cli *Client) delete(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) { return cli.sendRequest(ctx, http.MethodDelete, path, query, nil, headers) } -func encodeBody(obj interface{}, headers http.Header) (io.Reader, http.Header, error) { +type headers map[string][]string + +func encodeBody(obj interface{}, headers headers) (io.Reader, headers, error) { if obj == nil { return nil, headers, nil } - // encoding/json encodes a nil pointer as the JSON document `null`, - // irrespective of whether the type implements json.Marshaler or encoding.TextMarshaler. - // That is almost certainly not what the caller intended as the request body. - if reflect.TypeOf(obj).Kind() == reflect.Ptr && reflect.ValueOf(obj).IsNil() { - return nil, headers, nil - } body, err := encodeData(obj) if err != nil { @@ -96,8 +85,13 @@ func encodeBody(obj interface{}, headers http.Header) (io.Reader, http.Header, e return body, headers, nil } -func (cli *Client) buildRequest(ctx context.Context, method, path string, body io.Reader, headers http.Header) (*http.Request, error) { - req, err := http.NewRequestWithContext(ctx, method, path, body) +func (cli *Client) buildRequest(method, path string, body io.Reader, headers headers) (*http.Request, error) { + expectedPayload := (method == http.MethodPost || method == http.MethodPut) + if expectedPayload && body == nil { + body = bytes.NewReader([]byte{}) + } + + req, err := http.NewRequest(method, path, body) if err != nil { return nil, err } @@ -110,19 +104,19 @@ func (cli *Client) buildRequest(ctx context.Context, method, path string, body i req.Host = DummyHost } - if body != nil && req.Header.Get("Content-Type") == "" { + if expectedPayload && req.Header.Get("Content-Type") == "" { req.Header.Set("Content-Type", "text/plain") } return req, nil } -func (cli *Client) sendRequest(ctx context.Context, method, path string, query url.Values, body io.Reader, headers http.Header) (serverResponse, error) { - req, err := cli.buildRequest(ctx, method, cli.getAPIPath(ctx, path, query), body, headers) +func (cli *Client) sendRequest(ctx context.Context, method, path string, query url.Values, body io.Reader, headers headers) (serverResponse, error) { + req, err := cli.buildRequest(method, cli.getAPIPath(ctx, path, query), body, headers) if err != nil { return serverResponse{}, err } - resp, err := cli.doRequest(req) + resp, err := cli.doRequest(ctx, req) switch { case errors.Is(err, context.Canceled): return serverResponse{}, errdefs.Cancelled(err) @@ -134,9 +128,10 @@ func (cli *Client) sendRequest(ctx context.Context, method, path string, query u return resp, errdefs.FromStatusCode(err, resp.statusCode) } -func (cli *Client) doRequest(req *http.Request) (serverResponse, error) { +func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResponse, error) { serverResp := serverResponse{statusCode: -1, reqURL: req.URL} + req = req.WithContext(ctx) resp, err := cli.client.Do(req) if err != nil { if cli.scheme != "https" && strings.Contains(err.Error(), "malformed HTTP response") { @@ -153,19 +148,19 @@ func (cli *Client) doRequest(req *http.Request) (serverResponse, error) { return serverResp, err } - if uErr, ok := err.(*url.Error); ok { - if nErr, ok := uErr.Err.(*net.OpError); ok { + if nErr, ok := err.(*url.Error); ok { + if nErr, ok := nErr.Err.(*net.OpError); ok { if os.IsPermission(nErr.Err) { return serverResp, errors.Wrapf(err, "permission denied while trying to connect to the Docker daemon socket at %v", cli.host) } } } - if nErr, ok := err.(net.Error); ok { - if nErr.Timeout() { + if err, ok := err.(net.Error); ok { + if err.Timeout() { return serverResp, ErrorConnectionFailed(cli.host) } - if strings.Contains(nErr.Error(), "connection refused") || strings.Contains(nErr.Error(), "dial unix") { + if strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "dial unix") { return serverResp, ErrorConnectionFailed(cli.host) } } @@ -226,20 +221,26 @@ func (cli *Client) checkResponseErr(serverResp serverResponse) error { return fmt.Errorf("request returned %s for API route and version %s, check if the server supports the requested API version", http.StatusText(serverResp.statusCode), serverResp.reqURL) } - var daemonErr error - if serverResp.header.Get("Content-Type") == "application/json" && (cli.version == "" || versions.GreaterThan(cli.version, "1.23")) { + var ct string + if serverResp.header != nil { + ct = serverResp.header.Get("Content-Type") + } + + var errorMessage string + if (cli.version == "" || versions.GreaterThan(cli.version, "1.23")) && ct == "application/json" { var errorResponse types.ErrorResponse if err := json.Unmarshal(body, &errorResponse); err != nil { return errors.Wrap(err, "Error reading JSON") } - daemonErr = errors.New(strings.TrimSpace(errorResponse.Message)) + errorMessage = strings.TrimSpace(errorResponse.Message) } else { - daemonErr = errors.New(strings.TrimSpace(string(body))) + errorMessage = strings.TrimSpace(string(body)) } - return errors.Wrap(daemonErr, "Error response from daemon") + + return errors.Wrap(errors.New(errorMessage), "Error response from daemon") } -func (cli *Client) addHeaders(req *http.Request, headers http.Header) *http.Request { +func (cli *Client) addHeaders(req *http.Request, headers headers) *http.Request { // Add CLI Config's HTTP Headers BEFORE we set the Docker headers // then the user can't change OUR headers for k, v := range cli.customHTTPHeaders { @@ -252,14 +253,6 @@ func (cli *Client) addHeaders(req *http.Request, headers http.Header) *http.Requ for k, v := range headers { req.Header[http.CanonicalHeaderKey(k)] = v } - - if cli.userAgent != nil { - if *cli.userAgent == "" { - req.Header.Del("User-Agent") - } else { - req.Header.Set("User-Agent", *cli.userAgent) - } - } return req } diff --git a/test/integration/vendor/github.com/docker/docker/client/secret_create.go b/test/integration/vendor/github.com/docker/docker/client/secret_create.go index 7b7f1ba740..c65d38a191 100644 --- a/test/integration/vendor/github.com/docker/docker/client/secret_create.go +++ b/test/integration/vendor/github.com/docker/docker/client/secret_create.go @@ -11,7 +11,7 @@ import ( // SecretCreate creates a new secret. func (cli *Client) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error) { var response types.SecretCreateResponse - if err := cli.NewVersionError(ctx, "1.25", "secret create"); err != nil { + if err := cli.NewVersionError("1.25", "secret create"); err != nil { return response, err } resp, err := cli.post(ctx, "/secrets/create", nil, secret, nil) diff --git a/test/integration/vendor/github.com/docker/docker/client/secret_inspect.go b/test/integration/vendor/github.com/docker/docker/client/secret_inspect.go index a9cb59889b..5906874b15 100644 --- a/test/integration/vendor/github.com/docker/docker/client/secret_inspect.go +++ b/test/integration/vendor/github.com/docker/docker/client/secret_inspect.go @@ -11,7 +11,7 @@ import ( // SecretInspectWithRaw returns the secret information with raw data func (cli *Client) SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error) { - if err := cli.NewVersionError(ctx, "1.25", "secret inspect"); err != nil { + if err := cli.NewVersionError("1.25", "secret inspect"); err != nil { return swarm.Secret{}, nil, err } if id == "" { diff --git a/test/integration/vendor/github.com/docker/docker/client/secret_list.go b/test/integration/vendor/github.com/docker/docker/client/secret_list.go index 4d21639ef6..a0289c9f44 100644 --- a/test/integration/vendor/github.com/docker/docker/client/secret_list.go +++ b/test/integration/vendor/github.com/docker/docker/client/secret_list.go @@ -12,7 +12,7 @@ import ( // SecretList returns the list of secrets. func (cli *Client) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { - if err := cli.NewVersionError(ctx, "1.25", "secret list"); err != nil { + if err := cli.NewVersionError("1.25", "secret list"); err != nil { return nil, err } query := url.Values{} diff --git a/test/integration/vendor/github.com/docker/docker/client/secret_remove.go b/test/integration/vendor/github.com/docker/docker/client/secret_remove.go index 079ed67394..f47f68b6e0 100644 --- a/test/integration/vendor/github.com/docker/docker/client/secret_remove.go +++ b/test/integration/vendor/github.com/docker/docker/client/secret_remove.go @@ -4,7 +4,7 @@ import "context" // SecretRemove removes a secret. func (cli *Client) SecretRemove(ctx context.Context, id string) error { - if err := cli.NewVersionError(ctx, "1.25", "secret remove"); err != nil { + if err := cli.NewVersionError("1.25", "secret remove"); err != nil { return err } resp, err := cli.delete(ctx, "/secrets/"+id, nil, nil) diff --git a/test/integration/vendor/github.com/docker/docker/client/secret_update.go b/test/integration/vendor/github.com/docker/docker/client/secret_update.go index 9dfe67198b..2e939e8ced 100644 --- a/test/integration/vendor/github.com/docker/docker/client/secret_update.go +++ b/test/integration/vendor/github.com/docker/docker/client/secret_update.go @@ -9,7 +9,7 @@ import ( // SecretUpdate attempts to update a secret. func (cli *Client) SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error { - if err := cli.NewVersionError(ctx, "1.25", "secret update"); err != nil { + if err := cli.NewVersionError("1.25", "secret update"); err != nil { return err } query := url.Values{} diff --git a/test/integration/vendor/github.com/docker/docker/client/service_create.go b/test/integration/vendor/github.com/docker/docker/client/service_create.go index 2ebb5ee3a5..b6065b8eef 100644 --- a/test/integration/vendor/github.com/docker/docker/client/service_create.go +++ b/test/integration/vendor/github.com/docker/docker/client/service_create.go @@ -4,28 +4,26 @@ import ( "context" "encoding/json" "fmt" - "net/http" "strings" - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/api/types/versions" "github.com/opencontainers/go-digest" "github.com/pkg/errors" ) // ServiceCreate creates a new service. -func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) { - var response swarm.ServiceCreateResponse +func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) { + var response types.ServiceCreateResponse + headers := map[string][]string{ + "version": {cli.version}, + } - // Make sure we negotiated (if the client is configured to do so), - // as code below contains API-version specific handling of options. - // - // Normally, version-negotiation (if enabled) would not happen until - // the API request is made. - cli.checkVersion(ctx) + if options.EncodedRegistryAuth != "" { + headers[registry.AuthHeader] = []string{options.EncodedRegistryAuth} + } // Make sure containerSpec is not nil when no runtime is set or the runtime is set to container if service.TaskTemplate.ContainerSpec == nil && (service.TaskTemplate.Runtime == "" || service.TaskTemplate.Runtime == swarm.RuntimeContainer) { @@ -55,16 +53,6 @@ func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, } } - headers := http.Header{} - if versions.LessThan(cli.version, "1.30") { - // the custom "version" header was used by engine API before 20.10 - // (API 1.30) to switch between client- and server-side lookup of - // image digests. - headers["version"] = []string{cli.version} - } - if options.EncodedRegistryAuth != "" { - headers[registry.AuthHeader] = []string{options.EncodedRegistryAuth} - } resp, err := cli.post(ctx, "/services/create", nil, service, headers) defer ensureReaderClosed(resp) if err != nil { diff --git a/test/integration/vendor/github.com/docker/docker/client/service_logs.go b/test/integration/vendor/github.com/docker/docker/client/service_logs.go index e9e30a2ab4..906fd4059e 100644 --- a/test/integration/vendor/github.com/docker/docker/client/service_logs.go +++ b/test/integration/vendor/github.com/docker/docker/client/service_logs.go @@ -6,14 +6,14 @@ import ( "net/url" "time" - "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types" timetypes "github.com/docker/docker/api/types/time" "github.com/pkg/errors" ) // ServiceLogs returns the logs generated by a service in an io.ReadCloser. // It's up to the caller to close the stream. -func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error) { +func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error) { query := url.Values{} if options.ShowStdout { query.Set("stdout", "1") diff --git a/test/integration/vendor/github.com/docker/docker/client/service_update.go b/test/integration/vendor/github.com/docker/docker/client/service_update.go index e05eebf566..ff8cded8be 100644 --- a/test/integration/vendor/github.com/docker/docker/client/service_update.go +++ b/test/integration/vendor/github.com/docker/docker/client/service_update.go @@ -3,31 +3,30 @@ package client // import "github.com/docker/docker/client" import ( "context" "encoding/json" - "net/http" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/api/types/versions" ) // ServiceUpdate updates a Service. The version number is required to avoid conflicting writes. // It should be the value as set *before* the update. You can find this value in the Meta field // of swarm.Service, which can be found using ServiceInspectWithRaw. -func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) { - // Make sure we negotiated (if the client is configured to do so), - // as code below contains API-version specific handling of options. - // - // Normally, version-negotiation (if enabled) would not happen until - // the API request is made. - cli.checkVersion(ctx) - +func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) { var ( query = url.Values{} - response = swarm.ServiceUpdateResponse{} + response = types.ServiceUpdateResponse{} ) + headers := map[string][]string{ + "version": {cli.version}, + } + + if options.EncodedRegistryAuth != "" { + headers[registry.AuthHeader] = []string{options.EncodedRegistryAuth} + } + if options.RegistryAuthFrom != "" { query.Set("registryAuthFrom", options.RegistryAuthFrom) } @@ -61,16 +60,6 @@ func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version } } - headers := http.Header{} - if versions.LessThan(cli.version, "1.30") { - // the custom "version" header was used by engine API before 20.10 - // (API 1.30) to switch between client- and server-side lookup of - // image digests. - headers["version"] = []string{cli.version} - } - if options.EncodedRegistryAuth != "" { - headers[registry.AuthHeader] = []string{options.EncodedRegistryAuth} - } resp, err := cli.post(ctx, "/services/"+serviceID+"/update", query, service, headers) defer ensureReaderClosed(resp) if err != nil { diff --git a/test/integration/vendor/github.com/docker/docker/client/task_logs.go b/test/integration/vendor/github.com/docker/docker/client/task_logs.go index b8c20e71da..6222fab577 100644 --- a/test/integration/vendor/github.com/docker/docker/client/task_logs.go +++ b/test/integration/vendor/github.com/docker/docker/client/task_logs.go @@ -6,13 +6,13 @@ import ( "net/url" "time" - "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types" timetypes "github.com/docker/docker/api/types/time" ) // TaskLogs returns the logs generated by a task in an io.ReadCloser. // It's up to the caller to close the stream. -func (cli *Client) TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error) { +func (cli *Client) TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error) { query := url.Values{} if options.ShowStdout { query.Set("stdout", "1") diff --git a/test/integration/vendor/github.com/docker/docker/client/transport.go b/test/integration/vendor/github.com/docker/docker/client/transport.go new file mode 100644 index 0000000000..5541344366 --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/client/transport.go @@ -0,0 +1,17 @@ +package client // import "github.com/docker/docker/client" + +import ( + "crypto/tls" + "net/http" +) + +// resolveTLSConfig attempts to resolve the TLS configuration from the +// RoundTripper. +func resolveTLSConfig(transport http.RoundTripper) *tls.Config { + switch tr := transport.(type) { + case *http.Transport: + return tr.TLSClientConfig + default: + return nil + } +} diff --git a/test/integration/vendor/github.com/docker/docker/client/volume_prune.go b/test/integration/vendor/github.com/docker/docker/client/volume_prune.go index 9333f6ee78..6e324708f2 100644 --- a/test/integration/vendor/github.com/docker/docker/client/volume_prune.go +++ b/test/integration/vendor/github.com/docker/docker/client/volume_prune.go @@ -13,7 +13,7 @@ import ( func (cli *Client) VolumesPrune(ctx context.Context, pruneFilters filters.Args) (types.VolumesPruneReport, error) { var report types.VolumesPruneReport - if err := cli.NewVersionError(ctx, "1.25", "volume prune"); err != nil { + if err := cli.NewVersionError("1.25", "volume prune"); err != nil { return report, err } diff --git a/test/integration/vendor/github.com/docker/docker/client/volume_remove.go b/test/integration/vendor/github.com/docker/docker/client/volume_remove.go index 31e08cb975..1f26438360 100644 --- a/test/integration/vendor/github.com/docker/docker/client/volume_remove.go +++ b/test/integration/vendor/github.com/docker/docker/client/volume_remove.go @@ -10,14 +10,8 @@ import ( // VolumeRemove removes a volume from the docker host. func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, force bool) error { query := url.Values{} - if force { - // Make sure we negotiated (if the client is configured to do so), - // as code below contains API-version specific handling of options. - // - // Normally, version-negotiation (if enabled) would not happen until - // the API request is made. - cli.checkVersion(ctx) - if versions.GreaterThanOrEqualTo(cli.version, "1.25") { + if versions.GreaterThanOrEqualTo(cli.version, "1.25") { + if force { query.Set("force", "1") } } diff --git a/test/integration/vendor/github.com/docker/docker/client/volume_update.go b/test/integration/vendor/github.com/docker/docker/client/volume_update.go index 151863f07a..33bd31e531 100644 --- a/test/integration/vendor/github.com/docker/docker/client/volume_update.go +++ b/test/integration/vendor/github.com/docker/docker/client/volume_update.go @@ -11,7 +11,7 @@ import ( // VolumeUpdate updates a volume. This only works for Cluster Volumes, and // only some fields can be updated. func (cli *Client) VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error { - if err := cli.NewVersionError(ctx, "1.42", "volume update"); err != nil { + if err := cli.NewVersionError("1.42", "volume update"); err != nil { return err } diff --git a/test/integration/vendor/github.com/docker/docker/errdefs/defs.go b/test/integration/vendor/github.com/docker/docker/errdefs/defs.go index a5523c3e95..61e7456b4e 100644 --- a/test/integration/vendor/github.com/docker/docker/errdefs/defs.go +++ b/test/integration/vendor/github.com/docker/docker/errdefs/defs.go @@ -1,4 +1,4 @@ -package errdefs +package errdefs // import "github.com/docker/docker/errdefs" // ErrNotFound signals that the requested object doesn't exist type ErrNotFound interface { diff --git a/test/integration/vendor/github.com/docker/docker/errdefs/helpers.go b/test/integration/vendor/github.com/docker/docker/errdefs/helpers.go index 042de4b7b8..fe06fb6f70 100644 --- a/test/integration/vendor/github.com/docker/docker/errdefs/helpers.go +++ b/test/integration/vendor/github.com/docker/docker/errdefs/helpers.go @@ -1,4 +1,4 @@ -package errdefs +package errdefs // import "github.com/docker/docker/errdefs" import "context" diff --git a/test/integration/vendor/github.com/docker/docker/errdefs/http_helpers.go b/test/integration/vendor/github.com/docker/docker/errdefs/http_helpers.go index ebcd789302..77bda389d1 100644 --- a/test/integration/vendor/github.com/docker/docker/errdefs/http_helpers.go +++ b/test/integration/vendor/github.com/docker/docker/errdefs/http_helpers.go @@ -1,4 +1,4 @@ -package errdefs +package errdefs // import "github.com/docker/docker/errdefs" import ( "net/http" diff --git a/test/integration/vendor/github.com/docker/docker/errdefs/is.go b/test/integration/vendor/github.com/docker/docker/errdefs/is.go index f94034cbd7..3abf07d0c3 100644 --- a/test/integration/vendor/github.com/docker/docker/errdefs/is.go +++ b/test/integration/vendor/github.com/docker/docker/errdefs/is.go @@ -1,18 +1,9 @@ -package errdefs - -import ( - "context" - "errors" -) +package errdefs // import "github.com/docker/docker/errdefs" type causer interface { Cause() error } -type wrapErr interface { - Unwrap() error -} - func getImplementer(err error) error { switch e := err.(type) { case @@ -32,8 +23,6 @@ func getImplementer(err error) error { return err case causer: return getImplementer(e.Cause()) - case wrapErr: - return getImplementer(e.Unwrap()) default: return err } @@ -116,8 +105,3 @@ func IsDataLoss(err error) bool { _, ok := getImplementer(err).(ErrDataLoss) return ok } - -// IsContext returns if the passed in error is due to context cancellation or deadline exceeded. -func IsContext(err error) bool { - return errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) -} diff --git a/test/integration/vendor/github.com/docker/docker/image/spec/specs-go/v1/image.go b/test/integration/vendor/github.com/docker/docker/image/spec/specs-go/v1/image.go deleted file mode 100644 index 1672617635..0000000000 --- a/test/integration/vendor/github.com/docker/docker/image/spec/specs-go/v1/image.go +++ /dev/null @@ -1,54 +0,0 @@ -package v1 - -import ( - "time" - - ocispec "github.com/opencontainers/image-spec/specs-go/v1" -) - -const DockerOCIImageMediaType = "application/vnd.docker.container.image.v1+json" - -// DockerOCIImage is a ocispec.Image extended with Docker specific Config. -type DockerOCIImage struct { - ocispec.Image - - // Shadow ocispec.Image.Config - Config DockerOCIImageConfig `json:"config,omitempty"` -} - -// DockerOCIImageConfig is a ocispec.ImageConfig extended with Docker specific fields. -type DockerOCIImageConfig struct { - ocispec.ImageConfig - - DockerOCIImageConfigExt -} - -// DockerOCIImageConfigExt contains Docker-specific fields in DockerImageConfig. -type DockerOCIImageConfigExt struct { - Healthcheck *HealthcheckConfig `json:",omitempty"` // Healthcheck describes how to check the container is healthy - - OnBuild []string `json:",omitempty"` // ONBUILD metadata that were defined on the image Dockerfile - Shell []string `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT -} - -// HealthcheckConfig holds configuration settings for the HEALTHCHECK feature. -type HealthcheckConfig struct { - // Test is the test to perform to check that the container is healthy. - // An empty slice means to inherit the default. - // The options are: - // {} : inherit healthcheck - // {"NONE"} : disable healthcheck - // {"CMD", args...} : exec arguments directly - // {"CMD-SHELL", command} : run command with system's default shell - Test []string `json:",omitempty"` - - // Zero means to inherit. Durations are expressed as integer nanoseconds. - Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks. - Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung. - StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down. - StartInterval time.Duration `json:",omitempty"` // The interval to attempt healthchecks at during the start period - - // Retries is the number of consecutive failures needed to consider a container as unhealthy. - // Zero means inherit. - Retries int `json:",omitempty"` -} diff --git a/test/integration/vendor/github.com/docker/docker/internal/multierror/multierror.go b/test/integration/vendor/github.com/docker/docker/internal/multierror/multierror.go deleted file mode 100644 index cf4d6a5957..0000000000 --- a/test/integration/vendor/github.com/docker/docker/internal/multierror/multierror.go +++ /dev/null @@ -1,46 +0,0 @@ -package multierror - -import ( - "strings" -) - -// Join is a drop-in replacement for errors.Join with better formatting. -func Join(errs ...error) error { - n := 0 - for _, err := range errs { - if err != nil { - n++ - } - } - if n == 0 { - return nil - } - e := &joinError{ - errs: make([]error, 0, n), - } - for _, err := range errs { - if err != nil { - e.errs = append(e.errs, err) - } - } - return e -} - -type joinError struct { - errs []error -} - -func (e *joinError) Error() string { - if len(e.errs) == 1 { - return strings.TrimSpace(e.errs[0].Error()) - } - stringErrs := make([]string, 0, len(e.errs)) - for _, subErr := range e.errs { - stringErrs = append(stringErrs, strings.Replace(subErr.Error(), "\n", "\n\t", -1)) - } - return "* " + strings.Join(stringErrs, "\n* ") -} - -func (e *joinError) Unwrap() []error { - return e.errs -} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/archive.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/archive.go index 43133a0950..34361a24ac 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/archive.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/archive.go @@ -21,7 +21,6 @@ import ( "time" "github.com/containerd/containerd/pkg/userns" - "github.com/containerd/log" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/pools" @@ -30,6 +29,7 @@ import ( "github.com/moby/patternmatcher" "github.com/moby/sys/sequential" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) // ImpliedDirectoryMode represents the mode (Unix permissions) applied to directories that are implied by files in a @@ -42,7 +42,7 @@ import ( // This value is currently implementation-defined, and not captured in any cross-runtime specification. Thus, it is // subject to change in Moby at any time -- image authors who require consistent or known directory permissions // should explicitly control them by ensuring that header entries exist for any applicable path. -const ImpliedDirectoryMode = 0o755 +const ImpliedDirectoryMode = 0755 type ( // Compression is the state represents if compressed or not. @@ -70,12 +70,6 @@ type ( // replaced with the matching name from this map. RebaseNames map[string]string InUserNS bool - // Allow unpacking to succeed in spite of failures to set extended - // attributes on the unpacked files due to the destination filesystem - // not supporting them or a lack of permissions. Extended attributes - // were probably in the archive for a reason, so set this option at - // your own peril. - BestEffortXattrs bool } ) @@ -205,21 +199,21 @@ func gzDecompress(ctx context.Context, buf io.Reader) (io.ReadCloser, error) { if noPigzEnv := os.Getenv("MOBY_DISABLE_PIGZ"); noPigzEnv != "" { noPigz, err := strconv.ParseBool(noPigzEnv) if err != nil { - log.G(ctx).WithError(err).Warn("invalid value in MOBY_DISABLE_PIGZ env var") + logrus.WithError(err).Warn("invalid value in MOBY_DISABLE_PIGZ env var") } if noPigz { - log.G(ctx).Debugf("Use of pigz is disabled due to MOBY_DISABLE_PIGZ=%s", noPigzEnv) + logrus.Debugf("Use of pigz is disabled due to MOBY_DISABLE_PIGZ=%s", noPigzEnv) return gzip.NewReader(buf) } } unpigzPath, err := exec.LookPath("unpigz") if err != nil { - log.G(ctx).Debugf("unpigz binary not found, falling back to go gzip library") + logrus.Debugf("unpigz binary not found, falling back to go gzip library") return gzip.NewReader(buf) } - log.G(ctx).Debugf("Using %s to decompress", unpigzPath) + logrus.Debugf("Using %s to decompress", unpigzPath) return cmdStream(exec.CommandContext(ctx, unpigzPath, "-d", "-c"), buf) } @@ -481,8 +475,6 @@ func FileInfoHeader(name string, fi os.FileInfo, link string) (*tar.Header, erro return hdr, nil } -const paxSchilyXattr = "SCHILY.xattr." - // ReadSecurityXattrToTarHeader reads security.capability xattr from filesystem // to a tar header func ReadSecurityXattrToTarHeader(path string, hdr *tar.Header) error { @@ -495,16 +487,15 @@ func ReadSecurityXattrToTarHeader(path string, hdr *tar.Header) error { ) capability, _ := system.Lgetxattr(path, "security.capability") if capability != nil { + length := len(capability) if capability[versionOffset] == vfsCapRevision3 { // Convert VFS_CAP_REVISION_3 to VFS_CAP_REVISION_2 as root UID makes no // sense outside the user namespace the archive is built in. capability[versionOffset] = vfsCapRevision2 - capability = capability[:xattrCapsSz2] - } - if hdr.PAXRecords == nil { - hdr.PAXRecords = make(map[string]string) + length = xattrCapsSz2 } - hdr.PAXRecords[paxSchilyXattr+"security.capability"] = string(capability) + hdr.Xattrs = make(map[string]string) + hdr.Xattrs["security.capability"] = string(capability[:length]) } return nil } @@ -675,19 +666,7 @@ func (ta *tarAppender) addTarFile(path, name string) error { return nil } -func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, opts *TarOptions) error { - var ( - Lchown = true - inUserns, bestEffortXattrs bool - chownOpts *idtools.Identity - ) - if opts != nil { - Lchown = !opts.NoLchown - inUserns = opts.InUserNS - chownOpts = opts.ChownOpts - bestEffortXattrs = opts.BestEffortXattrs - } - +func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, Lchown bool, chownOpts *idtools.Identity, inUserns bool) error { // hdr.Mode is in linux format, which we can use for sycalls, // but for os.Foo() calls we need the mode converted to os.FileMode, // so use hdrInfo.Mode() (they differ for e.g. setuid bits) @@ -757,7 +736,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, o } case tar.TypeXGlobalHeader: - log.G(context.TODO()).Debug("PAX Global Extended Headers found and ignored") + logrus.Debug("PAX Global Extended Headers found and ignored") return nil default: @@ -778,26 +757,26 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, o } } - var xattrErrs []string - for key, value := range hdr.PAXRecords { - xattr, ok := strings.CutPrefix(key, paxSchilyXattr) - if !ok { - continue - } - if err := system.Lsetxattr(path, xattr, []byte(value), 0); err != nil { - if bestEffortXattrs && errors.Is(err, syscall.ENOTSUP) || errors.Is(err, syscall.EPERM) { + var errors []string + for key, value := range hdr.Xattrs { + if err := system.Lsetxattr(path, key, []byte(value), 0); err != nil { + if err == syscall.ENOTSUP || err == syscall.EPERM { + // We ignore errors here because not all graphdrivers support + // xattrs *cough* old versions of AUFS *cough*. However only + // ENOTSUP should be emitted in that case, otherwise we still + // bail. // EPERM occurs if modifying xattrs is not allowed. This can // happen when running in userns with restrictions (ChromeOS). - xattrErrs = append(xattrErrs, err.Error()) + errors = append(errors, err.Error()) continue } return err } } - if len(xattrErrs) > 0 { - log.G(context.TODO()).WithFields(log.Fields{ - "errors": xattrErrs, + if len(errors) > 0 { + logrus.WithFields(logrus.Fields{ + "errors": errors, }).Warn("ignored xattrs in archive: underlying filesystem doesn't support them") } @@ -914,13 +893,13 @@ func (t *Tarballer) Do() { defer func() { // Make sure to check the error on Close. if err := ta.TarWriter.Close(); err != nil { - log.G(context.TODO()).Errorf("Can't close tar writer: %s", err) + logrus.Errorf("Can't close tar writer: %s", err) } if err := t.compressWriter.Close(); err != nil { - log.G(context.TODO()).Errorf("Can't close compress writer: %s", err) + logrus.Errorf("Can't close compress writer: %s", err) } if err := t.pipeWriter.Close(); err != nil { - log.G(context.TODO()).Errorf("Can't close pipe writer: %s", err) + logrus.Errorf("Can't close pipe writer: %s", err) } }() @@ -943,7 +922,7 @@ func (t *Tarballer) Do() { // directory. So, we must split the source path and use the // basename as the include. if len(t.options.IncludeFiles) > 0 { - log.G(context.TODO()).Warn("Tar: Can't archive a file with includes") + logrus.Warn("Tar: Can't archive a file with includes") } dir, base := SplitPathDirEntry(t.srcPath) @@ -968,7 +947,7 @@ func (t *Tarballer) Do() { walkRoot := getWalkRoot(t.srcPath, include) filepath.WalkDir(walkRoot, func(filePath string, f os.DirEntry, err error) error { if err != nil { - log.G(context.TODO()).Errorf("Tar: Can't stat file %s to tar: %s", t.srcPath, err) + logrus.Errorf("Tar: Can't stat file %s to tar: %s", t.srcPath, err) return nil } @@ -1007,7 +986,7 @@ func (t *Tarballer) Do() { skip, matchInfo, err = t.pm.MatchesUsingParentResults(relFilePath, patternmatcher.MatchInfo{}) } if err != nil { - log.G(context.TODO()).Errorf("Error matching %s: %v", relFilePath, err) + logrus.Errorf("Error matching %s: %v", relFilePath, err) return err } @@ -1068,7 +1047,7 @@ func (t *Tarballer) Do() { } if err := ta.addTarFile(filePath, relFilePath); err != nil { - log.G(context.TODO()).Errorf("Can't add file %s to tar: %s", filePath, err) + logrus.Errorf("Can't add file %s to tar: %s", filePath, err) // if pipe is broken, stop writing tar stream to it if err == io.ErrClosedPipe { return err @@ -1105,7 +1084,7 @@ loop: // ignore XGlobalHeader early to avoid creating parent directories for them if hdr.Typeflag == tar.TypeXGlobalHeader { - log.G(context.TODO()).Debugf("PAX Global Extended Headers found for %s and ignored", hdr.Name) + logrus.Debugf("PAX Global Extended Headers found for %s and ignored", hdr.Name) continue } @@ -1179,7 +1158,7 @@ loop: } } - if err := createTarFile(path, dest, hdr, trBuf, options); err != nil { + if err := createTarFile(path, dest, hdr, trBuf, !options.NoLchown, options.ChownOpts, options.InUserNS); err != nil { return err } @@ -1318,7 +1297,7 @@ func (archiver *Archiver) CopyWithTar(src, dst string) error { // as owner rootIDs := archiver.IDMapping.RootPair() // Create dst, copy src's content into it - if err := idtools.MkdirAllAndChownNew(dst, 0o755, rootIDs); err != nil { + if err := idtools.MkdirAllAndChownNew(dst, 0755, rootIDs); err != nil { return err } return archiver.TarUntar(src, dst) @@ -1343,7 +1322,7 @@ func (archiver *Archiver) CopyFileWithTar(src, dst string) (err error) { dst = filepath.Join(dst, filepath.Base(src)) } // Create the holding directory if necessary - if err := system.MkdirAll(filepath.Dir(dst), 0o700); err != nil { + if err := system.MkdirAll(filepath.Dir(dst), 0700); err != nil { return err } diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_linux.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_linux.go index 2c3786cd50..76321a35e3 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_linux.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_linux.go @@ -21,7 +21,8 @@ func getWhiteoutConverter(format WhiteoutFormat, inUserNS bool) (tarWhiteoutConv return nil, nil } -type overlayWhiteoutConverter struct{} +type overlayWhiteoutConverter struct { +} func (overlayWhiteoutConverter) ConvertWrite(hdr *tar.Header, path string, fi os.FileInfo) (wo *tar.Header, err error) { // convert whiteouts to AUFS format @@ -29,7 +30,7 @@ func (overlayWhiteoutConverter) ConvertWrite(hdr *tar.Header, path string, fi os // we just rename the file and make it normal dir, filename := filepath.Split(hdr.Name) hdr.Name = filepath.Join(dir, WhiteoutPrefix+filename) - hdr.Mode = 0o600 + hdr.Mode = 0600 hdr.Typeflag = tar.TypeReg hdr.Size = 0 } @@ -41,7 +42,9 @@ func (overlayWhiteoutConverter) ConvertWrite(hdr *tar.Header, path string, fi os return nil, err } if len(opaque) == 1 && opaque[0] == 'y' { - delete(hdr.PAXRecords, paxSchilyXattr+"trusted.overlay.opaque") + if hdr.Xattrs != nil { + delete(hdr.Xattrs, "trusted.overlay.opaque") + } // create a header for the whiteout file // it should inherit some properties from the parent, but be a regular file diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_other.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_other.go index 3de1d64c80..28ae2769c5 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_other.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_other.go @@ -1,4 +1,5 @@ //go:build !linux +// +build !linux package archive // import "github.com/docker/docker/pkg/archive" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_unix.go index ff59d01975..92d8e23dd0 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/archive_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package archive // import "github.com/docker/docker/pkg/archive" @@ -7,7 +8,6 @@ import ( "errors" "os" "path/filepath" - "runtime" "strings" "syscall" @@ -44,20 +44,6 @@ func chmodTarEntry(perm os.FileMode) os.FileMode { // statUnix populates hdr from system-dependent fields of fi without performing // any OS lookups. func statUnix(fi os.FileInfo, hdr *tar.Header) error { - // Devmajor and Devminor are only needed for special devices. - - // In FreeBSD, RDev for regular files is -1 (unless overridden by FS): - // https://cgit.freebsd.org/src/tree/sys/kern/vfs_default.c?h=stable/13#n1531 - // (NODEV is -1: https://cgit.freebsd.org/src/tree/sys/sys/param.h?h=stable/13#n241). - - // ZFS in particular does not override the default: - // https://cgit.freebsd.org/src/tree/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c?h=stable/13#n2027 - - // Since `Stat_t.Rdev` is uint64, the cast turns -1 into (2^64 - 1). - // Such large values cannot be encoded in a tar header. - if runtime.GOOS == "freebsd" && hdr.Typeflag != tar.TypeBlock && hdr.Typeflag != tar.TypeChar { - return nil - } s, ok := fi.Sys().(*syscall.Stat_t) if !ok { return nil @@ -97,7 +83,7 @@ func getFileUIDGID(stat interface{}) (idtools.Identity, error) { // handleTarTypeBlockCharFifo is an OS-specific helper function used by // createTarFile to handle the following types of header: Block; Char; Fifo func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error { - mode := uint32(hdr.Mode & 0o7777) + mode := uint32(hdr.Mode & 07777) switch hdr.Typeflag { case tar.TypeBlock: mode |= unix.S_IFBLK diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/changes.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/changes.go index f9f16c9259..7f7242be50 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/changes.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/changes.go @@ -3,7 +3,6 @@ package archive // import "github.com/docker/docker/pkg/archive" import ( "archive/tar" "bytes" - "context" "fmt" "io" "os" @@ -13,10 +12,10 @@ import ( "syscall" "time" - "github.com/containerd/log" "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/pools" "github.com/docker/docker/pkg/system" + "github.com/sirupsen/logrus" ) // ChangeType represents the change type. @@ -108,10 +107,8 @@ func aufsDeletedFile(root, path string, fi os.FileInfo) (string, error) { return "", nil } -type ( - skipChange func(string) (bool, error) - deleteChange func(string, string, os.FileInfo) (string, error) -) +type skipChange func(string) (bool, error) +type deleteChange func(string, string, os.FileInfo) (string, error) func changes(layers []string, rw string, dc deleteChange, sc skipChange) ([]Change, error) { var ( @@ -344,7 +341,9 @@ func newRootFileInfo() *FileInfo { // ChangesDirs compares two directories and generates an array of Change objects describing the changes. // If oldDir is "", then all files in newDir will be Add-Changes. func ChangesDirs(newDir, oldDir string) ([]Change, error) { - var oldRoot, newRoot *FileInfo + var ( + oldRoot, newRoot *FileInfo + ) if oldDir == "" { emptyDir, err := os.MkdirTemp("", "empty") if err != nil { @@ -372,7 +371,7 @@ func ChangesSize(newDir string, changes []Change) int64 { file := filepath.Join(newDir, change.Path) fileInfo, err := os.Lstat(file) if err != nil { - log.G(context.TODO()).Errorf("Can not stat %q: %s", file, err) + logrus.Errorf("Can not stat %q: %s", file, err) continue } @@ -421,22 +420,22 @@ func ExportChanges(dir string, changes []Change, idMap idtools.IdentityMapping) ChangeTime: timestamp, } if err := ta.TarWriter.WriteHeader(hdr); err != nil { - log.G(context.TODO()).Debugf("Can't write whiteout header: %s", err) + logrus.Debugf("Can't write whiteout header: %s", err) } } else { path := filepath.Join(dir, change.Path) if err := ta.addTarFile(path, change.Path[1:]); err != nil { - log.G(context.TODO()).Debugf("Can't add file %s to tar: %s", path, err) + logrus.Debugf("Can't add file %s to tar: %s", path, err) } } } // Make sure to check the error on Close. if err := ta.TarWriter.Close(); err != nil { - log.G(context.TODO()).Debugf("Can't close layer: %s", err) + logrus.Debugf("Can't close layer: %s", err) } if err := writer.Close(); err != nil { - log.G(context.TODO()).Debugf("failed close Changes writer: %s", err) + logrus.Debugf("failed close Changes writer: %s", err) } }() return reader, nil diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_linux.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_linux.go index 81fcbc5bab..f8792b3d4e 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_linux.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_linux.go @@ -267,7 +267,7 @@ func parseDirent(buf []byte, names []nameIno) (consumed int, newnames []nameIno) continue } bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) - name := string(bytes[0:clen(bytes[:])]) + var name = string(bytes[0:clen(bytes[:])]) if name == "." || name == ".." { // Useless names continue } diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_other.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_other.go index 13a7d3c0c6..833798bd11 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_other.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_other.go @@ -1,4 +1,5 @@ //go:build !linux +// +build !linux package archive // import "github.com/docker/docker/pkg/archive" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_unix.go index 853c73ee8c..54aace970e 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/changes_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package archive // import "github.com/docker/docker/pkg/archive" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/copy.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/copy.go index 01eadc30d9..0ea1596278 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/copy.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/copy.go @@ -2,15 +2,14 @@ package archive // import "github.com/docker/docker/pkg/archive" import ( "archive/tar" - "context" "errors" "io" "os" "path/filepath" "strings" - "github.com/containerd/log" "github.com/docker/docker/pkg/system" + "github.com/sirupsen/logrus" ) // Errors used or returned by this file. @@ -108,7 +107,7 @@ func TarResourceRebase(sourcePath, rebaseName string) (content io.ReadCloser, er sourceDir, sourceBase := SplitPathDirEntry(sourcePath) opts := TarResourceRebaseOpts(sourceBase, rebaseName) - log.G(context.TODO()).Debugf("copying %q from %q", sourceBase, sourceDir) + logrus.Debugf("copying %q from %q", sourceBase, sourceDir) return TarWithOptions(sourceDir, opts) } diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/copy_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/copy_unix.go index 065bd4adda..2ac7729f4c 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/copy_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/copy_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package archive // import "github.com/docker/docker/pkg/archive" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/diff.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/diff.go index 318f594212..1a2fb971f9 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/diff.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/diff.go @@ -2,7 +2,6 @@ package archive // import "github.com/docker/docker/pkg/archive" import ( "archive/tar" - "context" "fmt" "io" "os" @@ -10,9 +9,9 @@ import ( "runtime" "strings" - "github.com/containerd/log" "github.com/docker/docker/pkg/pools" "github.com/docker/docker/pkg/system" + "github.com/sirupsen/logrus" ) // UnpackLayer unpack `layer` to a `dest`. The stream `layer` can be @@ -68,7 +67,7 @@ func UnpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64, // image but have it tagged as Windows inadvertently. if runtime.GOOS == "windows" { if strings.Contains(hdr.Name, ":") { - log.G(context.TODO()).Warnf("Windows: Ignoring %s (is this a Linux image?)", hdr.Name) + logrus.Warnf("Windows: Ignoring %s (is this a Linux image?)", hdr.Name) continue } } @@ -93,7 +92,7 @@ func UnpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64, } defer os.RemoveAll(aufsTempdir) } - if err := createTarFile(filepath.Join(aufsTempdir, basename), dest, hdr, tr, options); err != nil { + if err := createTarFile(filepath.Join(aufsTempdir, basename), dest, hdr, tr, true, nil, options.InUserNS); err != nil { return 0, err } } @@ -184,7 +183,7 @@ func UnpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64, return 0, err } - if err := createTarFile(path, dest, srcHdr, srcData, options); err != nil { + if err := createTarFile(path, dest, srcHdr, srcData, !options.NoLchown, nil, options.InUserNS); err != nil { return 0, err } diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/diff_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/diff_unix.go index 7216f2f4f9..d7f806445e 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/diff_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/diff_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package archive diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/path_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/path_unix.go index 390264bf85..0b135aea75 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/path_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/path_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package archive diff --git a/test/integration/vendor/github.com/docker/docker/pkg/archive/time_unsupported.go b/test/integration/vendor/github.com/docker/docker/pkg/archive/time_unsupported.go index 14c4ceb1d8..d087796861 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/archive/time_unsupported.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/archive/time_unsupported.go @@ -1,4 +1,5 @@ //go:build !linux +// +build !linux package archive // import "github.com/docker/docker/pkg/archive" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir.go b/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir.go deleted file mode 100644 index 590683206c..0000000000 --- a/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir.go +++ /dev/null @@ -1,44 +0,0 @@ -package homedir - -import ( - "os" - "os/user" - "runtime" -) - -// Key returns the env var name for the user's home dir based on -// the platform being run on. -// -// Deprecated: this function is no longer used, and will be removed in the next release. -func Key() string { - return envKeyName -} - -// Get returns the home directory of the current user with the help of -// environment variables depending on the target operating system. -// Returned path should be used with "path/filepath" to form new paths. -// -// On non-Windows platforms, it falls back to nss lookups, if the home -// directory cannot be obtained from environment-variables. -// -// If linking statically with cgo enabled against glibc, ensure the -// osusergo build tag is used. -// -// If needing to do nss lookups, do not disable cgo or set osusergo. -func Get() string { - home, _ := os.UserHomeDir() - if home == "" && runtime.GOOS != "windows" { - if u, err := user.Current(); err == nil { - return u.HomeDir - } - } - return home -} - -// GetShortcutString returns the string that is shortcut to user's home directory -// in the native shell of the platform running on. -// -// Deprecated: this function is no longer used, and will be removed in the next release. -func GetShortcutString() string { - return homeShortCut -} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go b/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go index 4eeb26b5dc..11f1bec985 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go @@ -1,4 +1,5 @@ //go:build !linux +// +build !linux package homedir // import "github.com/docker/docker/pkg/homedir" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go index feae4d736c..d1732dee52 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go @@ -1,8 +1,39 @@ //go:build !windows +// +build !windows package homedir // import "github.com/docker/docker/pkg/homedir" -const ( - envKeyName = "HOME" - homeShortCut = "~" +import ( + "os" + "os/user" ) + +// Key returns the env var name for the user's home dir based on +// the platform being run on +func Key() string { + return "HOME" +} + +// Get returns the home directory of the current user with the help of +// environment variables depending on the target operating system. +// Returned path should be used with "path/filepath" to form new paths. +// +// If linking statically with cgo enabled against glibc, ensure the +// osusergo build tag is used. +// +// If needing to do nss lookups, do not disable cgo or set osusergo. +func Get() string { + home := os.Getenv(Key()) + if home == "" { + if u, err := user.Current(); err == nil { + return u.HomeDir + } + } + return home +} + +// GetShortcutString returns the string that is shortcut to user's home directory +// in the native shell of the platform running on. +func GetShortcutString() string { + return "~" +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go b/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go index 37f4ee6701..2f81813b28 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go @@ -1,6 +1,24 @@ package homedir // import "github.com/docker/docker/pkg/homedir" -const ( - envKeyName = "USERPROFILE" - homeShortCut = "%USERPROFILE%" // be careful while using in format functions +import ( + "os" ) + +// Key returns the env var name for the user's home dir based on +// the platform being run on +func Key() string { + return "USERPROFILE" +} + +// Get returns the home directory of the current user with the help of +// environment variables depending on the target operating system. +// Returned path should be used with "path/filepath" to form new paths. +func Get() string { + return os.Getenv(Key()) +} + +// GetShortcutString returns the string that is shortcut to user's home directory +// in the native shell of the platform running on. +func GetShortcutString() string { + return "%USERPROFILE%" // be careful while using in format functions +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/idtools/idtools_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/idtools/idtools_unix.go index cd621bdcc2..a4001c3b87 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/idtools/idtools_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/idtools/idtools_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package idtools // import "github.com/docker/docker/pkg/idtools" @@ -10,9 +11,15 @@ import ( "os/exec" "path/filepath" "strconv" + "sync" "syscall" - "github.com/moby/sys/user" + "github.com/opencontainers/runc/libcontainer/user" +) + +var ( + entOnce sync.Once + getentCmd string ) func mkdirAs(path string, mode os.FileMode, owner Identity, mkAll, chownExisting bool) error { @@ -155,10 +162,10 @@ func getentGroup(name string) (user.Group, error) { } func callGetent(database, key string) (io.Reader, error) { - getentCmd, err := resolveBinary("getent") - // if no `getent` command within the execution environment, can't do anything else - if err != nil { - return nil, fmt.Errorf("unable to find getent command: %w", err) + entOnce.Do(func() { getentCmd, _ = resolveBinary("getent") }) + // if no `getent` command on host, can't do anything else + if getentCmd == "" { + return nil, fmt.Errorf("unable to find getent command") } command := exec.Command(getentCmd, database, key) // we run getent within container filesystem, but without /dev so /dev/null is not available for exec to mock stdin diff --git a/test/integration/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_unsupported.go b/test/integration/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_unsupported.go index 6a9311c4a7..5e24577e2c 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_unsupported.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_unsupported.go @@ -1,4 +1,5 @@ //go:build !linux +// +build !linux package idtools // import "github.com/docker/docker/pkg/idtools" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/idtools/utils_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/idtools/utils_unix.go index 517a2f52ca..05cc696365 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/idtools/utils_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/idtools/utils_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package idtools // import "github.com/docker/docker/pkg/idtools" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/ioutils/tempdir_deprecated.go b/test/integration/vendor/github.com/docker/docker/pkg/ioutils/tempdir_deprecated.go new file mode 100644 index 0000000000..b3321602c2 --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/ioutils/tempdir_deprecated.go @@ -0,0 +1,10 @@ +package ioutils + +import "github.com/docker/docker/pkg/longpath" + +// TempDir is the equivalent of [os.MkdirTemp], except that on Windows +// the result is in Windows longpath format. On Unix systems it is +// equivalent to [os.MkdirTemp]. +// +// Deprecated: use [longpath.MkdirTemp]. +var TempDir = longpath.MkdirTemp diff --git a/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo.go b/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo.go new file mode 100644 index 0000000000..4f33ad26bf --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo.go @@ -0,0 +1,26 @@ +// Package meminfo provides utilites to retrieve memory statistics of +// the host system. +package meminfo + +// Read retrieves memory statistics of the host system and returns a +// Memory type. It is only supported on Linux and Windows, and returns an +// error on other platforms. +func Read() (*Memory, error) { + return readMemInfo() +} + +// Memory contains memory statistics of the host system. +type Memory struct { + // Total usable RAM (i.e. physical RAM minus a few reserved bits and the + // kernel binary code). + MemTotal int64 + + // Amount of free memory. + MemFree int64 + + // Total amount of swap space available. + SwapTotal int64 + + // Amount of swap space that is currently unused. + SwapFree int64 +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo_linux.go b/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo_linux.go new file mode 100644 index 0000000000..0c1cd21d49 --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo_linux.go @@ -0,0 +1,69 @@ +package meminfo + +import ( + "bufio" + "io" + "os" + "strconv" + "strings" +) + +// readMemInfo retrieves memory statistics of the host system and returns a +// Memory type. +func readMemInfo() (*Memory, error) { + file, err := os.Open("/proc/meminfo") + if err != nil { + return nil, err + } + defer file.Close() + return parseMemInfo(file) +} + +// parseMemInfo parses the /proc/meminfo file into +// a Memory object given an io.Reader to the file. +// Throws error if there are problems reading from the file +func parseMemInfo(reader io.Reader) (*Memory, error) { + meminfo := &Memory{} + scanner := bufio.NewScanner(reader) + memAvailable := int64(-1) + for scanner.Scan() { + // Expected format: ["MemTotal:", "1234", "kB"] + parts := strings.Fields(scanner.Text()) + + // Sanity checks: Skip malformed entries. + if len(parts) < 3 || parts[2] != "kB" { + continue + } + + // Convert to bytes. + size, err := strconv.Atoi(parts[1]) + if err != nil { + continue + } + // Convert to KiB + bytes := int64(size) * 1024 + + switch parts[0] { + case "MemTotal:": + meminfo.MemTotal = bytes + case "MemFree:": + meminfo.MemFree = bytes + case "MemAvailable:": + memAvailable = bytes + case "SwapTotal:": + meminfo.SwapTotal = bytes + case "SwapFree:": + meminfo.SwapFree = bytes + } + } + if memAvailable != -1 { + meminfo.MemFree = memAvailable + } + + // Handle errors that may have occurred during the reading of the file. + if err := scanner.Err(); err != nil { + return nil, err + } + + return meminfo, nil +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo_unsupported.go b/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo_unsupported.go new file mode 100644 index 0000000000..ebfadd5343 --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo_unsupported.go @@ -0,0 +1,11 @@ +//go:build !linux && !windows +// +build !linux,!windows + +package meminfo + +import "errors" + +// readMemInfo is not supported on platforms other than linux and windows. +func readMemInfo() (*Memory, error) { + return nil, errors.New("platform and architecture is not supported") +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo_windows.go b/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo_windows.go new file mode 100644 index 0000000000..aa7d9375be --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/meminfo/meminfo_windows.go @@ -0,0 +1,45 @@ +package meminfo + +import ( + "unsafe" + + "golang.org/x/sys/windows" +) + +var ( + modkernel32 = windows.NewLazySystemDLL("kernel32.dll") + + procGlobalMemoryStatusEx = modkernel32.NewProc("GlobalMemoryStatusEx") +) + +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa366589(v=vs.85).aspx +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa366770(v=vs.85).aspx +type memorystatusex struct { + dwLength uint32 + dwMemoryLoad uint32 + ullTotalPhys uint64 + ullAvailPhys uint64 + ullTotalPageFile uint64 + ullAvailPageFile uint64 + ullTotalVirtual uint64 + ullAvailVirtual uint64 + ullAvailExtendedVirtual uint64 +} + +// readMemInfo retrieves memory statistics of the host system and returns a +// Memory type. +func readMemInfo() (*Memory, error) { + msi := &memorystatusex{ + dwLength: 64, + } + r1, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(msi))) + if r1 == 0 { + return &Memory{}, nil + } + return &Memory{ + MemTotal: int64(msi.ullTotalPhys), + MemFree: int64(msi.ullAvailPhys), + SwapTotal: int64(msi.ullTotalPageFile), + SwapFree: int64(msi.ullAvailPageFile), + }, nil +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/process/doc.go b/test/integration/vendor/github.com/docker/docker/pkg/process/doc.go new file mode 100644 index 0000000000..dae536d7db --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/process/doc.go @@ -0,0 +1,3 @@ +// Package process provides a set of basic functions to manage individual +// processes. +package process diff --git a/test/integration/vendor/github.com/docker/docker/pkg/process/process_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/process/process_unix.go new file mode 100644 index 0000000000..daf3923626 --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/process/process_unix.go @@ -0,0 +1,82 @@ +//go:build !windows +// +build !windows + +package process + +import ( + "bytes" + "fmt" + "os" + "path/filepath" + "runtime" + "strconv" + + "golang.org/x/sys/unix" +) + +// Alive returns true if process with a given pid is running. It only considers +// positive PIDs; 0 (all processes in the current process group), -1 (all processes +// with a PID larger than 1), and negative (-n, all processes in process group +// "n") values for pid are never considered to be alive. +func Alive(pid int) bool { + if pid < 1 { + return false + } + switch runtime.GOOS { + case "darwin": + // OS X does not have a proc filesystem. Use kill -0 pid to judge if the + // process exists. From KILL(2): https://www.freebsd.org/cgi/man.cgi?query=kill&sektion=2&manpath=OpenDarwin+7.2.1 + // + // Sig may be one of the signals specified in sigaction(2) or it may + // be 0, in which case error checking is performed but no signal is + // actually sent. This can be used to check the validity of pid. + err := unix.Kill(pid, 0) + + // Either the PID was found (no error) or we get an EPERM, which means + // the PID exists, but we don't have permissions to signal it. + return err == nil || err == unix.EPERM + default: + _, err := os.Stat(filepath.Join("/proc", strconv.Itoa(pid))) + return err == nil + } +} + +// Kill force-stops a process. It only considers positive PIDs; 0 (all processes +// in the current process group), -1 (all processes with a PID larger than 1), +// and negative (-n, all processes in process group "n") values for pid are +// ignored. Refer to [KILL(2)] for details. +// +// [KILL(2)]: https://man7.org/linux/man-pages/man2/kill.2.html +func Kill(pid int) error { + if pid < 1 { + return fmt.Errorf("invalid PID (%d): only positive PIDs are allowed", pid) + } + err := unix.Kill(pid, unix.SIGKILL) + if err != nil && err != unix.ESRCH { + return err + } + return nil +} + +// Zombie return true if process has a state with "Z". It only considers positive +// PIDs; 0 (all processes in the current process group), -1 (all processes with +// a PID larger than 1), and negative (-n, all processes in process group "n") +// values for pid are ignored. Refer to [PROC(5)] for details. +// +// [PROC(5)]: https://man7.org/linux/man-pages/man5/proc.5.html +func Zombie(pid int) (bool, error) { + if pid < 1 { + return false, nil + } + data, err := os.ReadFile(fmt.Sprintf("/proc/%d/stat", pid)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + if cols := bytes.SplitN(data, []byte(" "), 4); len(cols) >= 3 && string(cols[2]) == "Z" { + return true, nil + } + return false, nil +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/process/process_windows.go b/test/integration/vendor/github.com/docker/docker/pkg/process/process_windows.go new file mode 100644 index 0000000000..26158d09ec --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/process/process_windows.go @@ -0,0 +1,52 @@ +package process + +import ( + "os" + + "golang.org/x/sys/windows" +) + +// Alive returns true if process with a given pid is running. +func Alive(pid int) bool { + h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid)) + if err != nil { + return false + } + var c uint32 + err = windows.GetExitCodeProcess(h, &c) + _ = windows.CloseHandle(h) + if err != nil { + // From the GetExitCodeProcess function (processthreadsapi.h) API docs: + // https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess + // + // The GetExitCodeProcess function returns a valid error code defined by the + // application only after the thread terminates. Therefore, an application should + // not use STILL_ACTIVE (259) as an error code (STILL_ACTIVE is a macro for + // STATUS_PENDING (minwinbase.h)). If a thread returns STILL_ACTIVE (259) as + // an error code, then applications that test for that value could interpret it + // to mean that the thread is still running, and continue to test for the + // completion of the thread after the thread has terminated, which could put + // the application into an infinite loop. + return c == uint32(windows.STATUS_PENDING) + } + return true +} + +// Kill force-stops a process. +func Kill(pid int) error { + p, err := os.FindProcess(pid) + if err == nil { + err = p.Kill() + if err != nil && err != os.ErrProcessDone { + return err + } + } + return nil +} + +// Zombie is not supported on Windows. +// +// TODO(thaJeztah): remove once we remove the stubs from pkg/system. +func Zombie(_ int) (bool, error) { + return false, nil +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/chtimes_nowindows.go b/test/integration/vendor/github.com/docker/docker/pkg/system/chtimes_nowindows.go index 92ff02097d..84ae157051 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/chtimes_nowindows.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/chtimes_nowindows.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package system // import "github.com/docker/docker/pkg/system" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/errors.go b/test/integration/vendor/github.com/docker/docker/pkg/system/errors.go index f4bbcce744..2573d71622 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/errors.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/errors.go @@ -1,6 +1,13 @@ package system // import "github.com/docker/docker/pkg/system" -import "errors" +import ( + "errors" +) -// ErrNotSupportedPlatform means the platform is not supported. -var ErrNotSupportedPlatform = errors.New("platform and architecture is not supported") +var ( + // ErrNotSupportedPlatform means the platform is not supported. + ErrNotSupportedPlatform = errors.New("platform and architecture is not supported") + + // ErrNotSupportedOperatingSystem means the operating system is not supported. + ErrNotSupportedOperatingSystem = errors.New("operating system is not supported") +) diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/filesys_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/system/filesys_unix.go index f01f9385e1..3801129404 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/filesys_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/filesys_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package system // import "github.com/docker/docker/pkg/system" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/image_os.go b/test/integration/vendor/github.com/docker/docker/pkg/system/image_os.go new file mode 100644 index 0000000000..e3de86be29 --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/image_os.go @@ -0,0 +1,10 @@ +package system // import "github.com/docker/docker/pkg/system" +import ( + "runtime" + "strings" +) + +// IsOSSupported determines if an operating system is supported by the host. +func IsOSSupported(os string) bool { + return strings.EqualFold(runtime.GOOS, os) +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/image_os_deprecated.go b/test/integration/vendor/github.com/docker/docker/pkg/system/image_os_deprecated.go deleted file mode 100644 index afb57dae6a..0000000000 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/image_os_deprecated.go +++ /dev/null @@ -1,19 +0,0 @@ -package system - -import ( - "errors" - "runtime" - "strings" -) - -// ErrNotSupportedOperatingSystem means the operating system is not supported. -// -// Deprecated: use [github.com/docker/docker/image.CheckOS] and check the error returned. -var ErrNotSupportedOperatingSystem = errors.New("operating system is not supported") - -// IsOSSupported determines if an operating system is supported by the host. -// -// Deprecated: use [github.com/docker/docker/image.CheckOS] and check the error returned. -func IsOSSupported(os string) bool { - return strings.EqualFold(runtime.GOOS, os) -} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/init_windows.go b/test/integration/vendor/github.com/docker/docker/pkg/system/init_windows.go index 7603efbbd8..3c2a43ddbd 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/init_windows.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/init_windows.go @@ -1,7 +1,9 @@ package system // import "github.com/docker/docker/pkg/system" -// containerdRuntimeSupported determines if containerd should be the runtime. -var containerdRuntimeSupported = false +var ( + // containerdRuntimeSupported determines if containerd should be the runtime. + containerdRuntimeSupported = false +) // InitContainerdRuntime sets whether to use containerd for runtime on Windows. func InitContainerdRuntime(cdPath string) { diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/lstat_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/system/lstat_unix.go index 5e29a6b3b8..654b9f2c9e 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/lstat_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/lstat_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package system // import "github.com/docker/docker/pkg/system" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/meminfo_deprecated.go b/test/integration/vendor/github.com/docker/docker/pkg/system/meminfo_deprecated.go new file mode 100644 index 0000000000..216519923e --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/meminfo_deprecated.go @@ -0,0 +1,16 @@ +package system + +import "github.com/docker/docker/pkg/meminfo" + +// MemInfo contains memory statistics of the host system. +// +// Deprecated: use [meminfo.Memory]. +type MemInfo = meminfo.Memory + +// ReadMemInfo retrieves memory statistics of the host system and returns a +// MemInfo type. +// +// Deprecated: use [meminfo.Read]. +func ReadMemInfo() (*meminfo.Memory, error) { + return meminfo.Read() +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/mknod.go b/test/integration/vendor/github.com/docker/docker/pkg/system/mknod.go index 2a62237a45..d27152c0f5 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/mknod.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/mknod.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package system // import "github.com/docker/docker/pkg/system" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/mknod_freebsd.go b/test/integration/vendor/github.com/docker/docker/pkg/system/mknod_freebsd.go index e218e742d4..c890be116f 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/mknod_freebsd.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/mknod_freebsd.go @@ -1,4 +1,5 @@ //go:build freebsd +// +build freebsd package system // import "github.com/docker/docker/pkg/system" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/mknod_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/system/mknod_unix.go index 34df0b9236..4586aad19e 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/mknod_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/mknod_unix.go @@ -1,4 +1,5 @@ //go:build !freebsd && !windows +// +build !freebsd,!windows package system // import "github.com/docker/docker/pkg/system" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/mknod_windows.go b/test/integration/vendor/github.com/docker/docker/pkg/system/mknod_windows.go new file mode 100644 index 0000000000..ec89d7a15e --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/mknod_windows.go @@ -0,0 +1,11 @@ +package system // import "github.com/docker/docker/pkg/system" + +// Mknod is not implemented on Windows. +func Mknod(path string, mode uint32, dev int) error { + return ErrNotSupportedPlatform +} + +// Mkdev is not implemented on Windows. +func Mkdev(major int64, minor int64) uint32 { + panic("Mkdev not implemented on Windows.") +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/path_deprecated.go b/test/integration/vendor/github.com/docker/docker/pkg/system/path_deprecated.go new file mode 100644 index 0000000000..5c95026c3d --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/path_deprecated.go @@ -0,0 +1,18 @@ +package system + +const defaultUnixPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +// DefaultPathEnv is unix style list of directories to search for +// executables. Each directory is separated from the next by a colon +// ':' character . +// For Windows containers, an empty string is returned as the default +// path will be set by the container, and Docker has no context of what the +// default path should be. +// +// Deprecated: use oci.DefaultPathEnv +func DefaultPathEnv(os string) string { + if os == "windows" { + return "" + } + return defaultUnixPathEnv +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/process_deprecated.go b/test/integration/vendor/github.com/docker/docker/pkg/system/process_deprecated.go new file mode 100644 index 0000000000..7b9f19acd5 --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/process_deprecated.go @@ -0,0 +1,27 @@ +//go:build linux || freebsd || darwin || windows +// +build linux freebsd darwin windows + +package system + +import "github.com/docker/docker/pkg/process" + +var ( + // IsProcessAlive returns true if process with a given pid is running. + // + // Deprecated: use [process.Alive]. + IsProcessAlive = process.Alive + + // IsProcessZombie return true if process has a state with "Z" + // + // Deprecated: use [process.Zombie]. + // + // TODO(thaJeztah): remove the Windows implementation in process once we remove this stub. + IsProcessZombie = process.Zombie +) + +// KillProcess force-stops a process. +// +// Deprecated: use [process.Kill]. +func KillProcess(pid int) { + _ = process.Kill(pid) +} diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_bsd.go b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_bsd.go index 435b776ee3..8e61d820f0 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_bsd.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_bsd.go @@ -1,4 +1,5 @@ //go:build freebsd || netbsd +// +build freebsd netbsd package system // import "github.com/docker/docker/pkg/system" @@ -6,12 +7,10 @@ import "syscall" // fromStatT converts a syscall.Stat_t type to a system.Stat_t type func fromStatT(s *syscall.Stat_t) (*StatT, error) { - return &StatT{ - size: s.Size, + return &StatT{size: s.Size, mode: uint32(s.Mode), uid: s.Uid, gid: s.Gid, rdev: uint64(s.Rdev), - mtim: s.Mtimespec, - }, nil + mtim: s.Mtimespec}, nil } diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_darwin.go b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_darwin.go index e0b629df0e..c1c0ee9f38 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_darwin.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_darwin.go @@ -4,12 +4,10 @@ import "syscall" // fromStatT converts a syscall.Stat_t type to a system.Stat_t type func fromStatT(s *syscall.Stat_t) (*StatT, error) { - return &StatT{ - size: s.Size, + return &StatT{size: s.Size, mode: uint32(s.Mode), uid: s.Uid, gid: s.Gid, rdev: uint64(s.Rdev), - mtim: s.Mtimespec, - }, nil + mtim: s.Mtimespec}, nil } diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_linux.go b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_linux.go index 4309d42b9f..3ac02393f0 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_linux.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_linux.go @@ -4,15 +4,13 @@ import "syscall" // fromStatT converts a syscall.Stat_t type to a system.Stat_t type func fromStatT(s *syscall.Stat_t) (*StatT, error) { - return &StatT{ - size: s.Size, + return &StatT{size: s.Size, mode: s.Mode, uid: s.Uid, gid: s.Gid, // the type is 32bit on mips rdev: uint64(s.Rdev), //nolint: unconvert - mtim: s.Mtim, - }, nil + mtim: s.Mtim}, nil } // FromStatT converts a syscall.Stat_t type to a system.Stat_t type diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_openbsd.go b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_openbsd.go index 851374e5d9..756b92d1e6 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_openbsd.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_openbsd.go @@ -4,12 +4,10 @@ import "syscall" // fromStatT converts a syscall.Stat_t type to a system.Stat_t type func fromStatT(s *syscall.Stat_t) (*StatT, error) { - return &StatT{ - size: s.Size, + return &StatT{size: s.Size, mode: uint32(s.Mode), uid: s.Uid, gid: s.Gid, rdev: uint64(s.Rdev), - mtim: s.Mtim, - }, nil + mtim: s.Mtim}, nil } diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_unix.go index 205e54677d..a45ffddf75 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package system // import "github.com/docker/docker/pkg/system" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_windows.go b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_windows.go index 10876cd73e..0ff3af2fa1 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/stat_windows.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/stat_windows.go @@ -45,6 +45,5 @@ func fromStatT(fi *os.FileInfo) (*StatT, error) { return &StatT{ size: (*fi).Size(), mode: (*fi).Mode(), - mtim: (*fi).ModTime(), - }, nil + mtim: (*fi).ModTime()}, nil } diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/utimes_unix.go b/test/integration/vendor/github.com/docker/docker/pkg/system/utimes_unix.go index f3a079f887..2768750a00 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/utimes_unix.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/utimes_unix.go @@ -1,4 +1,5 @@ //go:build linux || freebsd +// +build linux freebsd package system // import "github.com/docker/docker/pkg/system" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/utimes_unsupported.go b/test/integration/vendor/github.com/docker/docker/pkg/system/utimes_unsupported.go index 7c19d59156..bfed4af032 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/utimes_unsupported.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/utimes_unsupported.go @@ -1,4 +1,5 @@ //go:build !linux && !freebsd +// +build !linux,!freebsd package system // import "github.com/docker/docker/pkg/system" diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/xattrs_linux.go b/test/integration/vendor/github.com/docker/docker/pkg/system/xattrs_linux.go index 4196b281b3..95b609fe7a 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/xattrs_linux.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/xattrs_linux.go @@ -1,19 +1,11 @@ package system // import "github.com/docker/docker/pkg/system" -import ( - "io/fs" - - "golang.org/x/sys/unix" -) +import "golang.org/x/sys/unix" // Lgetxattr retrieves the value of the extended attribute identified by attr // and associated with the given path in the file system. // It will returns a nil slice and nil error if the xattr is not set. func Lgetxattr(path string, attr string) ([]byte, error) { - pathErr := func(err error) ([]byte, error) { - return nil, &fs.PathError{Op: "lgetxattr", Path: path, Err: err} - } - // Start with a 128 length byte array dest := make([]byte, 128) sz, errno := unix.Lgetxattr(path, attr, dest) @@ -22,7 +14,7 @@ func Lgetxattr(path string, attr string) ([]byte, error) { // Buffer too small, use zero-sized buffer to get the actual size sz, errno = unix.Lgetxattr(path, attr, []byte{}) if errno != nil { - return pathErr(errno) + return nil, errno } dest = make([]byte, sz) sz, errno = unix.Lgetxattr(path, attr, dest) @@ -32,7 +24,7 @@ func Lgetxattr(path string, attr string) ([]byte, error) { case errno == unix.ENODATA: return nil, nil case errno != nil: - return pathErr(errno) + return nil, errno } return dest[:sz], nil @@ -41,9 +33,5 @@ func Lgetxattr(path string, attr string) ([]byte, error) { // Lsetxattr sets the value of the extended attribute identified by attr // and associated with the given path in the file system. func Lsetxattr(path string, attr string, data []byte, flags int) error { - err := unix.Lsetxattr(path, attr, data, flags) - if err != nil { - return &fs.PathError{Op: "lsetxattr", Path: path, Err: err} - } - return nil + return unix.Lsetxattr(path, attr, data, flags) } diff --git a/test/integration/vendor/github.com/docker/docker/pkg/system/xattrs_unsupported.go b/test/integration/vendor/github.com/docker/docker/pkg/system/xattrs_unsupported.go index 2a3698f129..b165a5dbfe 100644 --- a/test/integration/vendor/github.com/docker/docker/pkg/system/xattrs_unsupported.go +++ b/test/integration/vendor/github.com/docker/docker/pkg/system/xattrs_unsupported.go @@ -1,4 +1,5 @@ //go:build !linux +// +build !linux package system // import "github.com/docker/docker/pkg/system" diff --git a/test/integration/vendor/github.com/docker/docker/registry/auth.go b/test/integration/vendor/github.com/docker/docker/registry/auth.go index f685892c1f..dd75a49f38 100644 --- a/test/integration/vendor/github.com/docker/docker/registry/auth.go +++ b/test/integration/vendor/github.com/docker/docker/registry/auth.go @@ -1,18 +1,17 @@ package registry // import "github.com/docker/docker/registry" import ( - "context" "net/http" "net/url" "strings" "time" - "github.com/containerd/log" "github.com/docker/distribution/registry/client/auth" "github.com/docker/distribution/registry/client/auth/challenge" "github.com/docker/distribution/registry/client/transport" "github.com/docker/docker/api/types/registry" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) // AuthClientID is used the ClientID used for the token server @@ -75,7 +74,7 @@ func loginV2(authConfig *registry.AuthConfig, endpoint APIEndpoint, userAgent st creds = loginCredentialStore{authConfig: &credentialAuthConfig} ) - log.G(context.TODO()).Debugf("attempting v2 login to registry endpoint %s", endpointStr) + logrus.Debugf("attempting v2 login to registry endpoint %s", endpointStr) loginClient, err := v2AuthHTTPClient(endpoint.URL, authTransport, modifiers, creds, nil) if err != nil { @@ -125,10 +124,8 @@ func v2AuthHTTPClient(endpoint *url.URL, authTransport http.RoundTripper, modifi }, nil } -// ConvertToHostname normalizes a registry URL which has http|https prepended -// to just its hostname. It is used to match credentials, which may be either -// stored as hostname or as hostname including scheme (in legacy configuration -// files). +// ConvertToHostname converts a registry url which has http|https prepended +// to just an hostname. func ConvertToHostname(url string) string { stripped := url if strings.HasPrefix(url, "http://") { @@ -149,8 +146,8 @@ func ResolveAuthConfig(authConfigs map[string]registry.AuthConfig, index *regist // Maybe they have a legacy config file, we will iterate the keys converting // them to the new format and testing - for registryURL, ac := range authConfigs { - if configKey == ConvertToHostname(registryURL) { + for registry, ac := range authConfigs { + if configKey == ConvertToHostname(registry) { return ac } } diff --git a/test/integration/vendor/github.com/docker/docker/registry/config.go b/test/integration/vendor/github.com/docker/docker/registry/config.go index 84b0a63ad2..2766306ac2 100644 --- a/test/integration/vendor/github.com/docker/docker/registry/config.go +++ b/test/integration/vendor/github.com/docker/docker/registry/config.go @@ -1,16 +1,15 @@ package registry // import "github.com/docker/docker/registry" import ( - "context" "net" "net/url" "regexp" "strconv" "strings" - "github.com/containerd/log" - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/docker/docker/api/types/registry" + "github.com/sirupsen/logrus" ) // ServiceOptions holds command line options. @@ -198,10 +197,10 @@ skip: return err } if strings.HasPrefix(strings.ToLower(r), "http://") { - log.G(context.TODO()).Warnf("insecure registry %s should not contain 'http://' and 'http://' has been removed from the insecure registry config", r) + logrus.Warnf("insecure registry %s should not contain 'http://' and 'http://' has been removed from the insecure registry config", r) r = r[7:] } else if strings.HasPrefix(strings.ToLower(r), "https://") { - log.G(context.TODO()).Warnf("insecure registry %s should not contain 'https://' and 'https://' has been removed from the insecure registry config", r) + logrus.Warnf("insecure registry %s should not contain 'https://' and 'https://' has been removed from the insecure registry config", r) r = r[8:] } else if hasScheme(r) { return invalidParamf("insecure registry %s should not contain '://'", r) @@ -320,8 +319,7 @@ func isCIDRMatch(cidrs []*registry.NetIPNet, URLHost string) bool { return false } -// ValidateMirror validates an HTTP(S) registry mirror. It is used by the daemon -// to validate the daemon configuration. +// ValidateMirror validates an HTTP(S) registry mirror func ValidateMirror(val string) (string, error) { uri, err := url.Parse(val) if err != nil { @@ -330,8 +328,8 @@ func ValidateMirror(val string) (string, error) { if uri.Scheme != "http" && uri.Scheme != "https" { return "", invalidParamf("invalid mirror: unsupported scheme %q in %q", uri.Scheme, uri) } - if uri.RawQuery != "" || uri.Fragment != "" { - return "", invalidParamf("invalid mirror: query or fragment at end of the URI %q", uri) + if (uri.Path != "" && uri.Path != "/") || uri.RawQuery != "" || uri.Fragment != "" { + return "", invalidParamf("invalid mirror: path, query, or fragment at end of the URI %q", uri) } if uri.User != nil { // strip password from output @@ -341,8 +339,7 @@ func ValidateMirror(val string) (string, error) { return strings.TrimSuffix(val, "/") + "/", nil } -// ValidateIndexName validates an index name. It is used by the daemon to -// validate the daemon configuration. +// ValidateIndexName validates an index name. func ValidateIndexName(val string) (string, error) { // TODO: upstream this to check to reference package if val == "index.docker.io" { @@ -428,10 +425,24 @@ func newRepositoryInfo(config *serviceConfig, name reference.Named) (*Repository }, nil } -// ParseRepositoryInfo performs the breakdown of a repository name into a -// [RepositoryInfo], but lacks registry configuration. -// -// It is used by the Docker cli to interact with registry-related endpoints. +// ParseRepositoryInfo performs the breakdown of a repository name into a RepositoryInfo, but +// lacks registry configuration. func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) { return newRepositoryInfo(emptyServiceConfig, reposName) } + +// ParseSearchIndexInfo will use repository name to get back an indexInfo. +// +// TODO(thaJeztah) this function is only used by the CLI, and used to get +// information of the registry (to provide credentials if needed). We should +// move this function (or equivalent) to the CLI, as it's doing too much just +// for that. +func ParseSearchIndexInfo(reposName string) (*registry.IndexInfo, error) { + indexName, _ := splitReposSearchTerm(reposName) + + indexInfo, err := newIndexInfo(emptyServiceConfig, indexName) + if err != nil { + return nil, err + } + return indexInfo, nil +} diff --git a/test/integration/vendor/github.com/docker/docker/registry/config_unix.go b/test/integration/vendor/github.com/docker/docker/registry/config_unix.go index 2142049305..898c6b8a5b 100644 --- a/test/integration/vendor/github.com/docker/docker/registry/config_unix.go +++ b/test/integration/vendor/github.com/docker/docker/registry/config_unix.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package registry // import "github.com/docker/docker/registry" diff --git a/test/integration/vendor/github.com/docker/docker/registry/endpoint_v1.go b/test/integration/vendor/github.com/docker/docker/registry/endpoint_v1.go new file mode 100644 index 0000000000..56257dc799 --- /dev/null +++ b/test/integration/vendor/github.com/docker/docker/registry/endpoint_v1.go @@ -0,0 +1,185 @@ +package registry // import "github.com/docker/docker/registry" + +import ( + "crypto/tls" + "encoding/json" + "io" + "net/http" + "net/url" + "strings" + + "github.com/docker/distribution/registry/client/transport" + "github.com/docker/docker/api/types/registry" + "github.com/sirupsen/logrus" +) + +// v1PingResult contains the information returned when pinging a registry. It +// indicates the registry's version and whether the registry claims to be a +// standalone registry. +type v1PingResult struct { + // Version is the registry version supplied by the registry in an HTTP + // header + Version string `json:"version"` + // Standalone is set to true if the registry indicates it is a + // standalone registry in the X-Docker-Registry-Standalone + // header + Standalone bool `json:"standalone"` +} + +// v1Endpoint stores basic information about a V1 registry endpoint. +type v1Endpoint struct { + client *http.Client + URL *url.URL + IsSecure bool +} + +// newV1Endpoint parses the given address to return a registry endpoint. +// TODO: remove. This is only used by search. +func newV1Endpoint(index *registry.IndexInfo, headers http.Header) (*v1Endpoint, error) { + tlsConfig, err := newTLSConfig(index.Name, index.Secure) + if err != nil { + return nil, err + } + + endpoint, err := newV1EndpointFromStr(GetAuthConfigKey(index), tlsConfig, headers) + if err != nil { + return nil, err + } + + err = validateEndpoint(endpoint) + if err != nil { + return nil, err + } + + return endpoint, nil +} + +func validateEndpoint(endpoint *v1Endpoint) error { + logrus.Debugf("pinging registry endpoint %s", endpoint) + + // Try HTTPS ping to registry + endpoint.URL.Scheme = "https" + if _, err := endpoint.ping(); err != nil { + if endpoint.IsSecure { + // If registry is secure and HTTPS failed, show user the error and tell them about `--insecure-registry` + // in case that's what they need. DO NOT accept unknown CA certificates, and DO NOT fallback to HTTP. + return invalidParamf("invalid registry endpoint %s: %v. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry %s` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/%s/ca.crt", endpoint, err, endpoint.URL.Host, endpoint.URL.Host) + } + + // If registry is insecure and HTTPS failed, fallback to HTTP. + logrus.WithError(err).Debugf("error from registry %q marked as insecure - insecurely falling back to HTTP", endpoint) + endpoint.URL.Scheme = "http" + + var err2 error + if _, err2 = endpoint.ping(); err2 == nil { + return nil + } + + return invalidParamf("invalid registry endpoint %q. HTTPS attempt: %v. HTTP attempt: %v", endpoint, err, err2) + } + + return nil +} + +// trimV1Address trims the version off the address and returns the +// trimmed address or an error if there is a non-V1 version. +func trimV1Address(address string) (string, error) { + address = strings.TrimSuffix(address, "/") + chunks := strings.Split(address, "/") + apiVersionStr := chunks[len(chunks)-1] + if apiVersionStr == "v1" { + return strings.Join(chunks[:len(chunks)-1], "/"), nil + } + + for k, v := range apiVersions { + if k != APIVersion1 && apiVersionStr == v { + return "", invalidParamf("unsupported V1 version path %s", apiVersionStr) + } + } + + return address, nil +} + +func newV1EndpointFromStr(address string, tlsConfig *tls.Config, headers http.Header) (*v1Endpoint, error) { + if !strings.HasPrefix(address, "http://") && !strings.HasPrefix(address, "https://") { + address = "https://" + address + } + + address, err := trimV1Address(address) + if err != nil { + return nil, err + } + + uri, err := url.Parse(address) + if err != nil { + return nil, invalidParam(err) + } + + // TODO(tiborvass): make sure a ConnectTimeout transport is used + tr := newTransport(tlsConfig) + + return &v1Endpoint{ + IsSecure: tlsConfig == nil || !tlsConfig.InsecureSkipVerify, + URL: uri, + client: httpClient(transport.NewTransport(tr, Headers("", headers)...)), + }, nil +} + +// Get the formatted URL for the root of this registry Endpoint +func (e *v1Endpoint) String() string { + return e.URL.String() + "/v1/" +} + +// ping returns a v1PingResult which indicates whether the registry is standalone or not. +func (e *v1Endpoint) ping() (v1PingResult, error) { + if e.String() == IndexServer { + // Skip the check, we know this one is valid + // (and we never want to fallback to http in case of error) + return v1PingResult{}, nil + } + + logrus.Debugf("attempting v1 ping for registry endpoint %s", e) + pingURL := e.String() + "_ping" + req, err := http.NewRequest(http.MethodGet, pingURL, nil) + if err != nil { + return v1PingResult{}, invalidParam(err) + } + + resp, err := e.client.Do(req) + if err != nil { + return v1PingResult{}, invalidParam(err) + } + + defer resp.Body.Close() + + jsonString, err := io.ReadAll(resp.Body) + if err != nil { + return v1PingResult{}, invalidParamWrapf(err, "error while reading response from %s", pingURL) + } + + // If the header is absent, we assume true for compatibility with earlier + // versions of the registry. default to true + info := v1PingResult{ + Standalone: true, + } + if err := json.Unmarshal(jsonString, &info); err != nil { + logrus.WithError(err).Debug("error unmarshaling _ping response") + // don't stop here. Just assume sane defaults + } + if hdr := resp.Header.Get("X-Docker-Registry-Version"); hdr != "" { + info.Version = hdr + } + logrus.Debugf("v1PingResult.Version: %q", info.Version) + + standalone := resp.Header.Get("X-Docker-Registry-Standalone") + + // Accepted values are "true" (case-insensitive) and "1". + if strings.EqualFold(standalone, "true") || standalone == "1" { + info.Standalone = true + } else if len(standalone) > 0 { + // there is a header set, and it is not "true" or "1", so assume fails + info.Standalone = false + } + logrus.Debugf("v1PingResult.Standalone: %t", info.Standalone) + return info, nil +} diff --git a/test/integration/vendor/github.com/docker/docker/registry/registry.go b/test/integration/vendor/github.com/docker/docker/registry/registry.go index 7866dcd0d8..5ff39ce5e7 100644 --- a/test/integration/vendor/github.com/docker/docker/registry/registry.go +++ b/test/integration/vendor/github.com/docker/docker/registry/registry.go @@ -2,7 +2,6 @@ package registry // import "github.com/docker/docker/registry" import ( - "context" "crypto/tls" "net" "net/http" @@ -11,9 +10,9 @@ import ( "strings" "time" - "github.com/containerd/log" "github.com/docker/distribution/registry/client/transport" "github.com/docker/go-connections/tlsconfig" + "github.com/sirupsen/logrus" ) // HostCertsDir returns the config directory for a specific host. @@ -30,7 +29,7 @@ func newTLSConfig(hostname string, isSecure bool) (*tls.Config, error) { if isSecure && CertsDir() != "" { hostDir := HostCertsDir(hostname) - log.G(context.TODO()).Debugf("hostDir: %s", hostDir) + logrus.Debugf("hostDir: %s", hostDir) if err := ReadCertsDirectory(tlsConfig, hostDir); err != nil { return nil, err } @@ -66,7 +65,7 @@ func ReadCertsDirectory(tlsConfig *tls.Config, directory string) error { } tlsConfig.RootCAs = systemPool } - log.G(context.TODO()).Debugf("crt: %s", filepath.Join(directory, f.Name())) + logrus.Debugf("crt: %s", filepath.Join(directory, f.Name())) data, err := os.ReadFile(filepath.Join(directory, f.Name())) if err != nil { return err @@ -76,7 +75,7 @@ func ReadCertsDirectory(tlsConfig *tls.Config, directory string) error { if strings.HasSuffix(f.Name(), ".cert") { certName := f.Name() keyName := certName[:len(certName)-5] + ".key" - log.G(context.TODO()).Debugf("cert: %s", filepath.Join(directory, f.Name())) + logrus.Debugf("cert: %s", filepath.Join(directory, f.Name())) if !hasFile(fs, keyName) { return invalidParamf("missing key %s for client certificate %s. CA certificates must use the extension .crt", keyName, certName) } @@ -89,7 +88,7 @@ func ReadCertsDirectory(tlsConfig *tls.Config, directory string) error { if strings.HasSuffix(f.Name(), ".key") { keyName := f.Name() certName := keyName[:len(keyName)-4] + ".cert" - log.G(context.TODO()).Debugf("key: %s", filepath.Join(directory, f.Name())) + logrus.Debugf("key: %s", filepath.Join(directory, f.Name())) if !hasFile(fs, certName) { return invalidParamf("missing client certificate %s for key %s", certName, keyName) } @@ -113,6 +112,51 @@ func Headers(userAgent string, metaHeaders http.Header) []transport.RequestModif return modifiers } +// httpClient returns an HTTP client structure which uses the given transport +// and contains the necessary headers for redirected requests +func httpClient(transport http.RoundTripper) *http.Client { + return &http.Client{ + Transport: transport, + CheckRedirect: addRequiredHeadersToRedirectedRequests, + } +} + +func trustedLocation(req *http.Request) bool { + var ( + trusteds = []string{"docker.com", "docker.io"} + hostname = strings.SplitN(req.Host, ":", 2)[0] + ) + if req.URL.Scheme != "https" { + return false + } + + for _, trusted := range trusteds { + if hostname == trusted || strings.HasSuffix(hostname, "."+trusted) { + return true + } + } + return false +} + +// addRequiredHeadersToRedirectedRequests adds the necessary redirection headers +// for redirected requests +func addRequiredHeadersToRedirectedRequests(req *http.Request, via []*http.Request) error { + if len(via) != 0 && via[0] != nil { + if trustedLocation(req) && trustedLocation(via[0]) { + req.Header = via[0].Header + return nil + } + for k, v := range via[0].Header { + if k != "Authorization" { + for _, vv := range v { + req.Header.Add(k, vv) + } + } + } + } + return nil +} + // newTransport returns a new HTTP transport. If tlsConfig is nil, it uses the // default TLS configuration. func newTransport(tlsConfig *tls.Config) *http.Transport { diff --git a/test/integration/vendor/github.com/docker/docker/registry/search.go b/test/integration/vendor/github.com/docker/docker/registry/search.go index 75a5444109..60b86ea228 100644 --- a/test/integration/vendor/github.com/docker/docker/registry/search.go +++ b/test/integration/vendor/github.com/docker/docker/registry/search.go @@ -1,4 +1,4 @@ -package registry +package registry // import "github.com/docker/docker/registry" import ( "context" @@ -6,16 +6,17 @@ import ( "strconv" "strings" - "github.com/containerd/log" - "github.com/docker/distribution/registry/client/auth" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/errdefs" + + "github.com/docker/distribution/registry/client/auth" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) var acceptedSearchFilterTags = map[string]bool{ - "is-automated": true, // Deprecated: the "is_automated" field is deprecated and will always be false in the future. + "is-automated": true, "is-official": true, "stars": true, } @@ -27,7 +28,6 @@ func (s *Service) Search(ctx context.Context, searchFilters filters.Args, term s return nil, err } - // TODO(thaJeztah): the "is-automated" field is deprecated; reset the field for the next release (v26.0.0). Return early when using "is-automated=true", and ignore "is-automated=false". isAutomated, err := searchFilters.GetBoolOrDefault("is-automated", false) if err != nil { return nil, err @@ -51,7 +51,6 @@ func (s *Service) Search(ctx context.Context, searchFilters filters.Args, term s } } - // TODO(thaJeztah): the "is-automated" field is deprecated. Reset the field for the next release (v26.0.0) if any "true" values are present. unfilteredResult, err := s.searchUnfiltered(ctx, term, limit, authConfig, headers) if err != nil { return nil, err @@ -60,7 +59,7 @@ func (s *Service) Search(ctx context.Context, searchFilters filters.Args, term s filteredResults := []registry.SearchResult{} for _, result := range unfilteredResult.Results { if searchFilters.Contains("is-automated") { - if isAutomated != result.IsAutomated { //nolint:staticcheck // ignore SA1019 for old API versions. + if isAutomated != result.IsAutomated { continue } } @@ -127,7 +126,7 @@ func (s *Service) searchUnfiltered(ctx context.Context, term string, limit int, v2Client.CheckRedirect = endpoint.client.CheckRedirect v2Client.Jar = endpoint.client.Jar - log.G(ctx).Debugf("using v2 client for search to %s", endpoint.URL) + logrus.Debugf("using v2 client for search to %s", endpoint.URL) client = v2Client } else { client = endpoint.client @@ -138,26 +137,3 @@ func (s *Service) searchUnfiltered(ctx context.Context, term string, limit int, return newSession(client, endpoint).searchRepositories(remoteName, limit) } - -// splitReposSearchTerm breaks a search term into an index name and remote name -func splitReposSearchTerm(reposName string) (string, string) { - nameParts := strings.SplitN(reposName, "/", 2) - if len(nameParts) == 1 || (!strings.Contains(nameParts[0], ".") && - !strings.Contains(nameParts[0], ":") && nameParts[0] != "localhost") { - // This is a Docker Hub repository (ex: samalba/hipache or ubuntu), - // use the default Docker Hub registry (docker.io) - return IndexName, reposName - } - return nameParts[0], nameParts[1] -} - -// ParseSearchIndexInfo will use repository name to get back an indexInfo. -// -// TODO(thaJeztah) this function is only used by the CLI, and used to get -// information of the registry (to provide credentials if needed). We should -// move this function (or equivalent) to the CLI, as it's doing too much just -// for that. -func ParseSearchIndexInfo(reposName string) (*registry.IndexInfo, error) { - indexName, _ := splitReposSearchTerm(reposName) - return newIndexInfo(emptyServiceConfig, indexName) -} diff --git a/test/integration/vendor/github.com/docker/docker/registry/search_endpoint_v1.go b/test/integration/vendor/github.com/docker/docker/registry/search_endpoint_v1.go deleted file mode 100644 index f6c369a93b..0000000000 --- a/test/integration/vendor/github.com/docker/docker/registry/search_endpoint_v1.go +++ /dev/null @@ -1,200 +0,0 @@ -package registry // import "github.com/docker/docker/registry" - -import ( - "context" - "crypto/tls" - "encoding/json" - "net/http" - "net/url" - "strings" - - "github.com/containerd/log" - "github.com/docker/distribution/registry/client/transport" - "github.com/docker/docker/api/types/registry" -) - -// v1PingResult contains the information returned when pinging a registry. It -// indicates whether the registry claims to be a standalone registry. -type v1PingResult struct { - // Standalone is set to true if the registry indicates it is a - // standalone registry in the X-Docker-Registry-Standalone - // header - Standalone bool `json:"standalone"` -} - -// v1Endpoint stores basic information about a V1 registry endpoint. -type v1Endpoint struct { - client *http.Client - URL *url.URL - IsSecure bool -} - -// newV1Endpoint parses the given address to return a registry endpoint. -// TODO: remove. This is only used by search. -func newV1Endpoint(index *registry.IndexInfo, headers http.Header) (*v1Endpoint, error) { - tlsConfig, err := newTLSConfig(index.Name, index.Secure) - if err != nil { - return nil, err - } - - endpoint, err := newV1EndpointFromStr(GetAuthConfigKey(index), tlsConfig, headers) - if err != nil { - return nil, err - } - - if endpoint.String() == IndexServer { - // Skip the check, we know this one is valid - // (and we never want to fall back to http in case of error) - return endpoint, nil - } - - // Try HTTPS ping to registry - endpoint.URL.Scheme = "https" - if _, err := endpoint.ping(); err != nil { - if endpoint.IsSecure { - // If registry is secure and HTTPS failed, show user the error and tell them about `--insecure-registry` - // in case that's what they need. DO NOT accept unknown CA certificates, and DO NOT fall back to HTTP. - return nil, invalidParamf("invalid registry endpoint %s: %v. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry %s` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/%s/ca.crt", endpoint, err, endpoint.URL.Host, endpoint.URL.Host) - } - - // registry is insecure and HTTPS failed, fallback to HTTP. - log.G(context.TODO()).WithError(err).Debugf("error from registry %q marked as insecure - insecurely falling back to HTTP", endpoint) - endpoint.URL.Scheme = "http" - if _, err2 := endpoint.ping(); err2 != nil { - return nil, invalidParamf("invalid registry endpoint %q. HTTPS attempt: %v. HTTP attempt: %v", endpoint, err, err2) - } - } - - return endpoint, nil -} - -// trimV1Address trims the "v1" version suffix off the address and returns -// the trimmed address. It returns an error on "v2" endpoints. -func trimV1Address(address string) (string, error) { - trimmed := strings.TrimSuffix(address, "/") - if strings.HasSuffix(trimmed, "/v2") { - return "", invalidParamf("search is not supported on v2 endpoints: %s", address) - } - return strings.TrimSuffix(trimmed, "/v1"), nil -} - -func newV1EndpointFromStr(address string, tlsConfig *tls.Config, headers http.Header) (*v1Endpoint, error) { - if !strings.HasPrefix(address, "http://") && !strings.HasPrefix(address, "https://") { - address = "https://" + address - } - - address, err := trimV1Address(address) - if err != nil { - return nil, err - } - - uri, err := url.Parse(address) - if err != nil { - return nil, invalidParam(err) - } - - // TODO(tiborvass): make sure a ConnectTimeout transport is used - tr := newTransport(tlsConfig) - - return &v1Endpoint{ - IsSecure: tlsConfig == nil || !tlsConfig.InsecureSkipVerify, - URL: uri, - client: httpClient(transport.NewTransport(tr, Headers("", headers)...)), - }, nil -} - -// Get the formatted URL for the root of this registry Endpoint -func (e *v1Endpoint) String() string { - return e.URL.String() + "/v1/" -} - -// ping returns a v1PingResult which indicates whether the registry is standalone or not. -func (e *v1Endpoint) ping() (v1PingResult, error) { - if e.String() == IndexServer { - // Skip the check, we know this one is valid - // (and we never want to fallback to http in case of error) - return v1PingResult{}, nil - } - - pingURL := e.String() + "_ping" - log.G(context.TODO()).WithField("url", pingURL).Debug("attempting v1 ping for registry endpoint") - req, err := http.NewRequest(http.MethodGet, pingURL, nil) - if err != nil { - return v1PingResult{}, invalidParam(err) - } - - resp, err := e.client.Do(req) - if err != nil { - return v1PingResult{}, invalidParam(err) - } - - defer resp.Body.Close() - - if v := resp.Header.Get("X-Docker-Registry-Standalone"); v != "" { - info := v1PingResult{} - // Accepted values are "1", and "true" (case-insensitive). - if v == "1" || strings.EqualFold(v, "true") { - info.Standalone = true - } - log.G(context.TODO()).Debugf("v1PingResult.Standalone (from X-Docker-Registry-Standalone header): %t", info.Standalone) - return info, nil - } - - // If the header is absent, we assume true for compatibility with earlier - // versions of the registry. default to true - info := v1PingResult{ - Standalone: true, - } - if err := json.NewDecoder(resp.Body).Decode(&info); err != nil { - log.G(context.TODO()).WithError(err).Debug("error unmarshaling _ping response") - // don't stop here. Just assume sane defaults - } - - log.G(context.TODO()).Debugf("v1PingResult.Standalone: %t", info.Standalone) - return info, nil -} - -// httpClient returns an HTTP client structure which uses the given transport -// and contains the necessary headers for redirected requests -func httpClient(transport http.RoundTripper) *http.Client { - return &http.Client{ - Transport: transport, - CheckRedirect: addRequiredHeadersToRedirectedRequests, - } -} - -func trustedLocation(req *http.Request) bool { - var ( - trusteds = []string{"docker.com", "docker.io"} - hostname = strings.SplitN(req.Host, ":", 2)[0] - ) - if req.URL.Scheme != "https" { - return false - } - - for _, trusted := range trusteds { - if hostname == trusted || strings.HasSuffix(hostname, "."+trusted) { - return true - } - } - return false -} - -// addRequiredHeadersToRedirectedRequests adds the necessary redirection headers -// for redirected requests -func addRequiredHeadersToRedirectedRequests(req *http.Request, via []*http.Request) error { - if len(via) != 0 && via[0] != nil { - if trustedLocation(req) && trustedLocation(via[0]) { - req.Header = via[0].Header - return nil - } - for k, v := range via[0].Header { - if k != "Authorization" { - for _, vv := range v { - req.Header.Add(k, vv) - } - } - } - } - return nil -} diff --git a/test/integration/vendor/github.com/docker/docker/registry/service.go b/test/integration/vendor/github.com/docker/docker/registry/service.go index 6881c11057..b848065b3c 100644 --- a/test/integration/vendor/github.com/docker/docker/registry/service.go +++ b/test/integration/vendor/github.com/docker/docker/registry/service.go @@ -7,10 +7,10 @@ import ( "strings" "sync" - "github.com/containerd/log" - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/errdefs" + "github.com/sirupsen/logrus" ) // Service is a registry service. It tracks configuration data such as a list @@ -20,8 +20,8 @@ type Service struct { mu sync.RWMutex } -// NewService returns a new instance of [Service] ready to be installed into -// an engine. +// NewService returns a new instance of defaultService ready to be +// installed into an engine. func NewService(options ServiceOptions) (*Service, error) { config, err := newServiceConfig(options) @@ -35,18 +35,28 @@ func (s *Service) ServiceConfig() *registry.ServiceConfig { return s.config.copy() } -// ReplaceConfig prepares a transaction which will atomically replace the -// registry service's configuration when the returned commit function is called. -func (s *Service) ReplaceConfig(options ServiceOptions) (commit func(), err error) { - config, err := newServiceConfig(options) - if err != nil { - return nil, err - } - return func() { - s.mu.Lock() - defer s.mu.Unlock() - s.config = config - }, nil +// LoadAllowNondistributableArtifacts loads allow-nondistributable-artifacts registries for Service. +func (s *Service) LoadAllowNondistributableArtifacts(registries []string) error { + s.mu.Lock() + defer s.mu.Unlock() + + return s.config.loadAllowNondistributableArtifacts(registries) +} + +// LoadMirrors loads registry mirrors for Service +func (s *Service) LoadMirrors(mirrors []string) error { + s.mu.Lock() + defer s.mu.Unlock() + + return s.config.loadMirrors(mirrors) +} + +// LoadInsecureRegistries loads insecure registries for Service +func (s *Service) LoadInsecureRegistries(registries []string) error { + s.mu.Lock() + defer s.mu.Unlock() + + return s.config.loadInsecureRegistries(registries) } // Auth contacts the public registry with the provided credentials, @@ -54,7 +64,7 @@ func (s *Service) ReplaceConfig(options ServiceOptions) (commit func(), err erro // It can be used to verify the validity of a client's credentials. func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, userAgent string) (status, token string, err error) { // TODO Use ctx when searching for repositories - registryHostName := IndexHostname + var registryHostName = IndexHostname if authConfig.ServerAddress != "" { serverAddress := authConfig.ServerAddress @@ -85,12 +95,24 @@ func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, use // Failed to authenticate; don't continue with (non-TLS) endpoints. return status, token, err } - log.G(ctx).WithError(err).Infof("Error logging in to endpoint, trying next endpoint") + logrus.WithError(err).Infof("Error logging in to endpoint, trying next endpoint") } return "", "", err } +// splitReposSearchTerm breaks a search term into an index name and remote name +func splitReposSearchTerm(reposName string) (string, string) { + nameParts := strings.SplitN(reposName, "/", 2) + if len(nameParts) == 1 || (!strings.Contains(nameParts[0], ".") && + !strings.Contains(nameParts[0], ":") && nameParts[0] != "localhost") { + // This is a Docker Hub repository (ex: samalba/hipache or ubuntu), + // use the default Docker Hub registry (docker.io) + return IndexName, reposName + } + return nameParts[0], nameParts[1] +} + // ResolveRepository splits a repository name into its components // and configuration of the associated registry. func (s *Service) ResolveRepository(name reference.Named) (*RepositoryInfo, error) { @@ -103,7 +125,7 @@ func (s *Service) ResolveRepository(name reference.Named) (*RepositoryInfo, erro type APIEndpoint struct { Mirror bool URL *url.URL - Version APIVersion // Deprecated: v1 registries are deprecated, and endpoints are always v2. + Version APIVersion AllowNondistributableArtifacts bool Official bool TrimHostname bool diff --git a/test/integration/vendor/github.com/docker/docker/registry/service_v2.go b/test/integration/vendor/github.com/docker/docker/registry/service_v2.go index 5d09e11c9c..c8c545d21f 100644 --- a/test/integration/vendor/github.com/docker/docker/registry/service_v2.go +++ b/test/integration/vendor/github.com/docker/docker/registry/service_v2.go @@ -25,7 +25,7 @@ func (s *Service) lookupV2Endpoints(hostname string) (endpoints []APIEndpoint, e } endpoints = append(endpoints, APIEndpoint{ URL: mirrorURL, - Version: APIVersion2, //nolint:staticcheck // ignore SA1019 (Version is deprecated) to allow potential consumers to transition. + Version: APIVersion2, Mirror: true, TrimHostname: true, TLSConfig: mirrorTLSConfig, @@ -33,7 +33,7 @@ func (s *Service) lookupV2Endpoints(hostname string) (endpoints []APIEndpoint, e } endpoints = append(endpoints, APIEndpoint{ URL: DefaultV2Registry, - Version: APIVersion2, //nolint:staticcheck // ignore SA1019 (Version is deprecated) to allow potential consumers to transition. + Version: APIVersion2, Official: true, TrimHostname: true, TLSConfig: tlsconfig.ServerDefault(), @@ -55,7 +55,7 @@ func (s *Service) lookupV2Endpoints(hostname string) (endpoints []APIEndpoint, e Scheme: "https", Host: hostname, }, - Version: APIVersion2, //nolint:staticcheck // ignore SA1019 (Version is deprecated) to allow potential consumers to transition. + Version: APIVersion2, AllowNondistributableArtifacts: ana, TrimHostname: true, TLSConfig: tlsConfig, @@ -68,7 +68,7 @@ func (s *Service) lookupV2Endpoints(hostname string) (endpoints []APIEndpoint, e Scheme: "http", Host: hostname, }, - Version: APIVersion2, //nolint:staticcheck // ignore SA1019 (Version is deprecated) to allow potential consumers to transition. + Version: APIVersion2, AllowNondistributableArtifacts: ana, TrimHostname: true, // used to check if supposed to be secure via InsecureSkipVerify diff --git a/test/integration/vendor/github.com/docker/docker/registry/search_session.go b/test/integration/vendor/github.com/docker/docker/registry/session.go similarity index 90% rename from test/integration/vendor/github.com/docker/docker/registry/search_session.go rename to test/integration/vendor/github.com/docker/docker/registry/session.go index c334143c6b..86a5cd9edf 100644 --- a/test/integration/vendor/github.com/docker/docker/registry/search_session.go +++ b/test/integration/vendor/github.com/docker/docker/registry/session.go @@ -2,7 +2,6 @@ package registry // import "github.com/docker/docker/registry" import ( // this is required for some certificates - "context" _ "crypto/sha512" "encoding/json" "fmt" @@ -12,11 +11,12 @@ import ( "strings" "sync" - "github.com/containerd/log" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/errdefs" "github.com/docker/docker/pkg/ioutils" + "github.com/docker/docker/pkg/jsonmessage" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) // A session is used to communicate with a V1 registry @@ -155,7 +155,7 @@ func authorizeClient(client *http.Client, authConfig *registry.AuthConfig, endpo return err } if info.Standalone && authConfig != nil { - log.G(context.TODO()).Debugf("Endpoint %s is eligible for private registry. Enabling decorator.", endpoint.String()) + logrus.Debugf("Endpoint %s is eligible for private registry. Enabling decorator.", endpoint.String()) alwaysSetBasicAuth = true } } @@ -191,8 +191,8 @@ func (r *session) searchRepositories(term string, limit int) (*registry.SearchRe if limit < 1 || limit > 100 { return nil, invalidParamf("limit %d is outside the range of [1, 100]", limit) } + logrus.Debugf("Index server: %s", r.indexEndpoint) u := r.indexEndpoint.String() + "search?q=" + url.QueryEscape(term) + "&n=" + url.QueryEscape(fmt.Sprintf("%d", limit)) - log.G(context.TODO()).WithField("url", u).Debug("searchRepositories") req, err := http.NewRequest(http.MethodGet, u, nil) if err != nil { @@ -206,13 +206,11 @@ func (r *session) searchRepositories(term string, limit int) (*registry.SearchRe } defer res.Body.Close() if res.StatusCode != http.StatusOK { - // TODO(thaJeztah): return upstream response body for errors (see https://github.com/moby/moby/issues/27286). - return nil, errdefs.Unknown(fmt.Errorf("Unexpected status code %d", res.StatusCode)) + return nil, errdefs.Unknown(&jsonmessage.JSONError{ + Message: fmt.Sprintf("Unexpected status code %d", res.StatusCode), + Code: res.StatusCode, + }) } - result := ®istry.SearchResults{} - err = json.NewDecoder(res.Body).Decode(result) - if err != nil { - return nil, errdefs.System(errors.Wrap(err, "error decoding registry search results")) - } - return result, nil + result := new(registry.SearchResults) + return result, errors.Wrap(json.NewDecoder(res.Body).Decode(result), "error decoding registry search results") } diff --git a/test/integration/vendor/github.com/docker/docker/registry/types.go b/test/integration/vendor/github.com/docker/docker/registry/types.go index 54aa0bd19d..37094737f2 100644 --- a/test/integration/vendor/github.com/docker/docker/registry/types.go +++ b/test/integration/vendor/github.com/docker/docker/registry/types.go @@ -1,14 +1,12 @@ package registry // import "github.com/docker/docker/registry" import ( - "github.com/distribution/reference" + "github.com/docker/distribution/reference" "github.com/docker/docker/api/types/registry" ) // APIVersion is an integral representation of an API version (presently // either 1 or 2) -// -// Deprecated: v1 registries are deprecated, and endpoints are always v2. type APIVersion int func (av APIVersion) String() string { @@ -17,8 +15,8 @@ func (av APIVersion) String() string { // API Version identifiers. const ( - APIVersion1 APIVersion = 1 // Deprecated: v1 registries are deprecated, and endpoints are always v2. - APIVersion2 APIVersion = 2 // Deprecated: v1 registries are deprecated, and endpoints are always v2. + APIVersion1 APIVersion = 1 + APIVersion2 APIVersion = 2 ) var apiVersions = map[APIVersion]string{ diff --git a/test/integration/vendor/github.com/moby/sys/user/LICENSE b/test/integration/vendor/github.com/opencontainers/runc/LICENSE similarity index 94% rename from test/integration/vendor/github.com/moby/sys/user/LICENSE rename to test/integration/vendor/github.com/opencontainers/runc/LICENSE index d645695673..27448585ad 100644 --- a/test/integration/vendor/github.com/moby/sys/user/LICENSE +++ b/test/integration/vendor/github.com/opencontainers/runc/LICENSE @@ -176,18 +176,7 @@ END OF TERMS AND CONDITIONS - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] + Copyright 2014 Docker, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/test/integration/vendor/github.com/opencontainers/runc/NOTICE b/test/integration/vendor/github.com/opencontainers/runc/NOTICE new file mode 100644 index 0000000000..5c97abce4b --- /dev/null +++ b/test/integration/vendor/github.com/opencontainers/runc/NOTICE @@ -0,0 +1,17 @@ +runc + +Copyright 2012-2015 Docker, Inc. + +This product includes software developed at Docker, Inc. (http://www.docker.com). + +The following is courtesy of our legal counsel: + + +Use and transfer of Docker may be subject to certain restrictions by the +United States and other governments. +It is your responsibility to ensure that your use and/or transfer does not +violate applicable laws. + +For more information, please see http://www.bis.doc.gov + +See also http://www.apache.org/dev/crypto.html and/or seek legal counsel. diff --git a/test/integration/vendor/github.com/moby/sys/user/lookup_unix.go b/test/integration/vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unix.go similarity index 100% rename from test/integration/vendor/github.com/moby/sys/user/lookup_unix.go rename to test/integration/vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unix.go diff --git a/test/integration/vendor/github.com/moby/sys/user/user.go b/test/integration/vendor/github.com/opencontainers/runc/libcontainer/user/user.go similarity index 100% rename from test/integration/vendor/github.com/moby/sys/user/user.go rename to test/integration/vendor/github.com/opencontainers/runc/libcontainer/user/user.go diff --git a/test/integration/vendor/github.com/moby/sys/user/user_fuzzer.go b/test/integration/vendor/github.com/opencontainers/runc/libcontainer/user/user_fuzzer.go similarity index 100% rename from test/integration/vendor/github.com/moby/sys/user/user_fuzzer.go rename to test/integration/vendor/github.com/opencontainers/runc/libcontainer/user/user_fuzzer.go diff --git a/test/integration/vendor/modules.txt b/test/integration/vendor/modules.txt index a38b574fb9..6d79a34803 100644 --- a/test/integration/vendor/modules.txt +++ b/test/integration/vendor/modules.txt @@ -221,7 +221,7 @@ github.com/docker/buildx/util/platformutil github.com/docker/buildx/util/progress github.com/docker/buildx/util/resolver github.com/docker/buildx/util/waitmap -# github.com/docker/cli v24.0.7+incompatible +# github.com/docker/cli v24.0.6+incompatible ## explicit github.com/docker/cli/cli github.com/docker/cli/cli-plugins/manager @@ -288,12 +288,11 @@ github.com/docker/distribution/registry/client/transport github.com/docker/distribution/registry/storage/cache github.com/docker/distribution/registry/storage/cache/memory github.com/docker/distribution/uuid -# github.com/docker/docker v25.0.0+incompatible +# github.com/docker/docker v24.0.7+incompatible ## explicit github.com/docker/docker/api github.com/docker/docker/api/types github.com/docker/docker/api/types/blkiodev -github.com/docker/docker/api/types/checkpoint github.com/docker/docker/api/types/container github.com/docker/docker/api/types/events github.com/docker/docker/api/types/filters @@ -304,7 +303,6 @@ github.com/docker/docker/api/types/registry github.com/docker/docker/api/types/strslice github.com/docker/docker/api/types/swarm github.com/docker/docker/api/types/swarm/runtime -github.com/docker/docker/api/types/system github.com/docker/docker/api/types/time github.com/docker/docker/api/types/versions github.com/docker/docker/api/types/volume @@ -312,16 +310,16 @@ github.com/docker/docker/builder/remotecontext/git github.com/docker/docker/builder/remotecontext/urlutil github.com/docker/docker/client github.com/docker/docker/errdefs -github.com/docker/docker/image/spec/specs-go/v1 -github.com/docker/docker/internal/multierror github.com/docker/docker/pkg/archive github.com/docker/docker/pkg/homedir github.com/docker/docker/pkg/idtools github.com/docker/docker/pkg/ioutils github.com/docker/docker/pkg/jsonmessage github.com/docker/docker/pkg/longpath +github.com/docker/docker/pkg/meminfo github.com/docker/docker/pkg/namesgenerator github.com/docker/docker/pkg/pools +github.com/docker/docker/pkg/process github.com/docker/docker/pkg/progress github.com/docker/docker/pkg/stdcopy github.com/docker/docker/pkg/streamformatter @@ -638,9 +636,6 @@ github.com/moby/sys/signal # github.com/moby/sys/symlink v0.2.0 ## explicit; go 1.16 github.com/moby/sys/symlink -# github.com/moby/sys/user v0.1.0 -## explicit; go 1.17 -github.com/moby/sys/user # github.com/moby/term v0.5.0 ## explicit; go 1.18 github.com/moby/term @@ -706,6 +701,7 @@ github.com/opencontainers/image-spec/specs-go github.com/opencontainers/image-spec/specs-go/v1 # github.com/opencontainers/runc v1.1.12 => github.com/opencontainers/runc v1.1.12 ## explicit; go 1.17 +github.com/opencontainers/runc/libcontainer/user # github.com/opencontainers/runtime-spec v1.1.0 ## explicit # github.com/opentracing/opentracing-go v1.2.0