Older versions of Go don't format comments, so committing this as
a separate commit, so that we can already make these changes before
we upgrade to Go 1.19.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -45,31 +45,32 @@ func (ipnet *NetIPNet) UnmarshalJSON(b []byte) (err error) {
|
| 45 | 45 |
// IndexInfo contains information about a registry |
| 46 | 46 |
// |
| 47 | 47 |
// RepositoryInfo Examples: |
| 48 |
-// {
|
|
| 49 |
-// "Index" : {
|
|
| 50 |
-// "Name" : "docker.io", |
|
| 51 |
-// "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"], |
|
| 52 |
-// "Secure" : true, |
|
| 53 |
-// "Official" : true, |
|
| 54 |
-// }, |
|
| 55 |
-// "RemoteName" : "library/debian", |
|
| 56 |
-// "LocalName" : "debian", |
|
| 57 |
-// "CanonicalName" : "docker.io/debian" |
|
| 58 |
-// "Official" : true, |
|
| 59 |
-// } |
|
| 60 | 48 |
// |
| 61 |
-// {
|
|
| 62 |
-// "Index" : {
|
|
| 63 |
-// "Name" : "127.0.0.1:5000", |
|
| 64 |
-// "Mirrors" : [], |
|
| 65 |
-// "Secure" : false, |
|
| 66 |
-// "Official" : false, |
|
| 67 |
-// }, |
|
| 68 |
-// "RemoteName" : "user/repo", |
|
| 69 |
-// "LocalName" : "127.0.0.1:5000/user/repo", |
|
| 70 |
-// "CanonicalName" : "127.0.0.1:5000/user/repo", |
|
| 71 |
-// "Official" : false, |
|
| 72 |
-// } |
|
| 49 |
+// {
|
|
| 50 |
+// "Index" : {
|
|
| 51 |
+// "Name" : "docker.io", |
|
| 52 |
+// "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"], |
|
| 53 |
+// "Secure" : true, |
|
| 54 |
+// "Official" : true, |
|
| 55 |
+// }, |
|
| 56 |
+// "RemoteName" : "library/debian", |
|
| 57 |
+// "LocalName" : "debian", |
|
| 58 |
+// "CanonicalName" : "docker.io/debian" |
|
| 59 |
+// "Official" : true, |
|
| 60 |
+// } |
|
| 61 |
+// |
|
| 62 |
+// {
|
|
| 63 |
+// "Index" : {
|
|
| 64 |
+// "Name" : "127.0.0.1:5000", |
|
| 65 |
+// "Mirrors" : [], |
|
| 66 |
+// "Secure" : false, |
|
| 67 |
+// "Official" : false, |
|
| 68 |
+// }, |
|
| 69 |
+// "RemoteName" : "user/repo", |
|
| 70 |
+// "LocalName" : "127.0.0.1:5000/user/repo", |
|
| 71 |
+// "CanonicalName" : "127.0.0.1:5000/user/repo", |
|
| 72 |
+// "Official" : false, |
|
| 73 |
+// } |
|
| 73 | 74 |
type IndexInfo struct {
|
| 74 | 75 |
// Name is the name of the registry, such as "docker.io" |
| 75 | 76 |
Name string |
| ... | ... |
@@ -100,8 +100,10 @@ func GetTimestamp(value string, reference time.Time) (string, error) {
|
| 100 | 100 |
// if the incoming nanosecond portion is longer or shorter than 9 digits it is |
| 101 | 101 |
// converted to nanoseconds. The expectation is that the seconds and |
| 102 | 102 |
// seconds will be used to create a time variable. For example: |
| 103 |
-// seconds, nanoseconds, err := ParseTimestamp("1136073600.000000001",0)
|
|
| 104 |
-// if err == nil since := time.Unix(seconds, nanoseconds) |
|
| 103 |
+// |
|
| 104 |
+// seconds, nanoseconds, err := ParseTimestamp("1136073600.000000001",0)
|
|
| 105 |
+// if err == nil since := time.Unix(seconds, nanoseconds) |
|
| 106 |
+// |
|
| 105 | 107 |
// returns seconds as def(aultSeconds) if value == "" |
| 106 | 108 |
func ParseTimestamps(value string, def int64) (int64, int64, error) {
|
| 107 | 109 |
if value == "" {
|
| ... | ... |
@@ -35,7 +35,6 @@ import ( |
| 35 | 35 |
// |
| 36 | 36 |
// Sets the environment variable foo to bar, also makes interpolation |
| 37 | 37 |
// in the dockerfile available from the next statement on via ${foo}.
|
| 38 |
-// |
|
| 39 | 38 |
func dispatchEnv(d dispatchRequest, c *instructions.EnvCommand) error {
|
| 40 | 39 |
runConfig := d.state.runConfig |
| 41 | 40 |
commitMessage := bytes.NewBufferString("ENV")
|
| ... | ... |
@@ -73,7 +72,6 @@ func dispatchMaintainer(d dispatchRequest, c *instructions.MaintainerCommand) er |
| 73 | 73 |
// LABEL some json data describing the image |
| 74 | 74 |
// |
| 75 | 75 |
// Sets the Label variable foo to bar, |
| 76 |
-// |
|
| 77 | 76 |
func dispatchLabel(d dispatchRequest, c *instructions.LabelCommand) error {
|
| 78 | 77 |
if d.state.runConfig.Labels == nil {
|
| 79 | 78 |
d.state.runConfig.Labels = make(map[string]string) |
| ... | ... |
@@ -90,7 +88,6 @@ func dispatchLabel(d dispatchRequest, c *instructions.LabelCommand) error {
|
| 90 | 90 |
// |
| 91 | 91 |
// Add the file 'foo' to '/path'. Tarball and Remote URL (http, https) handling |
| 92 | 92 |
// exist here. If you do not wish to have this automatic handling, use COPY. |
| 93 |
-// |
|
| 94 | 93 |
func dispatchAdd(d dispatchRequest, c *instructions.AddCommand) error {
|
| 95 | 94 |
if c.Chmod != "" {
|
| 96 | 95 |
return errors.New("the --chmod option requires BuildKit. Refer to https://docs.docker.com/go/buildkit/ to learn how to build images with BuildKit enabled")
|
| ... | ... |
@@ -112,7 +109,6 @@ func dispatchAdd(d dispatchRequest, c *instructions.AddCommand) error {
|
| 112 | 112 |
// COPY foo /path |
| 113 | 113 |
// |
| 114 | 114 |
// Same as 'ADD' but without the tar and remote url handling. |
| 115 |
-// |
|
| 116 | 115 |
func dispatchCopy(d dispatchRequest, c *instructions.CopyCommand) error {
|
| 117 | 116 |
if c.Chmod != "" {
|
| 118 | 117 |
return errors.New("the --chmod option requires BuildKit. Refer to https://docs.docker.com/go/buildkit/ to learn how to build images with BuildKit enabled")
|
| ... | ... |
@@ -157,7 +153,6 @@ func (d *dispatchRequest) getImageMount(imageRefOrID string) (*imageMount, error |
| 157 | 157 |
} |
| 158 | 158 |
|
| 159 | 159 |
// FROM [--platform=platform] imagename[:tag | @digest] [AS build-stage-name] |
| 160 |
-// |
|
| 161 | 160 |
func initializeStage(d dispatchRequest, cmd *instructions.Stage) error {
|
| 162 | 161 |
d.builder.imageProber.Reset() |
| 163 | 162 |
|
| ... | ... |
@@ -290,7 +285,6 @@ func dispatchOnbuild(d dispatchRequest, c *instructions.OnbuildCommand) error {
|
| 290 | 290 |
// WORKDIR /tmp |
| 291 | 291 |
// |
| 292 | 292 |
// Set the working directory for future RUN/CMD/etc statements. |
| 293 |
-// |
|
| 294 | 293 |
func dispatchWorkdir(d dispatchRequest, c *instructions.WorkdirCommand) error {
|
| 295 | 294 |
runConfig := d.state.runConfig |
| 296 | 295 |
var err error |
| ... | ... |
@@ -333,7 +327,6 @@ func dispatchWorkdir(d dispatchRequest, c *instructions.WorkdirCommand) error {
|
| 333 | 333 |
// RUN echo hi # sh -c echo hi (Linux and LCOW) |
| 334 | 334 |
// RUN echo hi # cmd /S /C echo hi (Windows) |
| 335 | 335 |
// RUN [ "echo", "hi" ] # echo hi |
| 336 |
-// |
|
| 337 | 336 |
func dispatchRun(d dispatchRequest, c *instructions.RunCommand) error {
|
| 338 | 337 |
if !system.IsOSSupported(d.state.operatingSystem) {
|
| 339 | 338 |
return system.ErrNotSupportedOperatingSystem |
| ... | ... |
@@ -428,7 +421,6 @@ func prependEnvOnCmd(buildArgs *BuildArgs, buildArgVars []string, cmd strslice.S |
| 428 | 428 |
// |
| 429 | 429 |
// Set the default command to run in the container (which may be empty). |
| 430 | 430 |
// Argument handling is the same as RUN. |
| 431 |
-// |
|
| 432 | 431 |
func dispatchCmd(d dispatchRequest, c *instructions.CmdCommand) error {
|
| 433 | 432 |
runConfig := d.state.runConfig |
| 434 | 433 |
cmd, argsEscaped := resolveCmdLine(c.ShellDependantCmdLine, runConfig, d.state.operatingSystem, c.Name(), c.String()) |
| ... | ... |
@@ -459,7 +451,6 @@ func dispatchCmd(d dispatchRequest, c *instructions.CmdCommand) error {
|
| 459 | 459 |
// |
| 460 | 460 |
// Set the default healthcheck command to run in the container (which may be empty). |
| 461 | 461 |
// Argument handling is the same as RUN. |
| 462 |
-// |
|
| 463 | 462 |
func dispatchHealthcheck(d dispatchRequest, c *instructions.HealthCheckCommand) error {
|
| 464 | 463 |
runConfig := d.state.runConfig |
| 465 | 464 |
if runConfig.Healthcheck != nil {
|
| ... | ... |
@@ -479,7 +470,6 @@ func dispatchHealthcheck(d dispatchRequest, c *instructions.HealthCheckCommand) |
| 479 | 479 |
// |
| 480 | 480 |
// Handles command processing similar to CMD and RUN, only req.runConfig.Entrypoint |
| 481 | 481 |
// is initialized at newBuilder time instead of through argument parsing. |
| 482 |
-// |
|
| 483 | 482 |
func dispatchEntrypoint(d dispatchRequest, c *instructions.EntrypointCommand) error {
|
| 484 | 483 |
runConfig := d.state.runConfig |
| 485 | 484 |
cmd, argsEscaped := resolveCmdLine(c.ShellDependantCmdLine, runConfig, d.state.operatingSystem, c.Name(), c.String()) |
| ... | ... |
@@ -509,7 +499,6 @@ func dispatchEntrypoint(d dispatchRequest, c *instructions.EntrypointCommand) er |
| 509 | 509 |
// |
| 510 | 510 |
// Expose ports for links and port mappings. This all ends up in |
| 511 | 511 |
// req.runConfig.ExposedPorts for runconfig. |
| 512 |
-// |
|
| 513 | 512 |
func dispatchExpose(d dispatchRequest, c *instructions.ExposeCommand, envs []string) error {
|
| 514 | 513 |
// custom multi word expansion |
| 515 | 514 |
// expose $FOO with FOO="80 443" is expanded as EXPOSE [80,443]. This is the only command supporting word to words expansion |
| ... | ... |
@@ -543,7 +532,6 @@ func dispatchExpose(d dispatchRequest, c *instructions.ExposeCommand, envs []str |
| 543 | 543 |
// |
| 544 | 544 |
// Set the user to 'foo' for future commands and when running the |
| 545 | 545 |
// ENTRYPOINT/CMD at container run time. |
| 546 |
-// |
|
| 547 | 546 |
func dispatchUser(d dispatchRequest, c *instructions.UserCommand) error {
|
| 548 | 547 |
d.state.runConfig.User = c.User |
| 549 | 548 |
return d.builder.commit(d.state, fmt.Sprintf("USER %v", c.User))
|
| ... | ... |
@@ -552,7 +540,6 @@ func dispatchUser(d dispatchRequest, c *instructions.UserCommand) error {
|
| 552 | 552 |
// VOLUME /foo |
| 553 | 553 |
// |
| 554 | 554 |
// Expose the volume /foo for use. Will also accept the JSON array form. |
| 555 |
-// |
|
| 556 | 555 |
func dispatchVolume(d dispatchRequest, c *instructions.VolumeCommand) error {
|
| 557 | 556 |
if d.state.runConfig.Volumes == nil {
|
| 558 | 557 |
d.state.runConfig.Volumes = map[string]struct{}{}
|
| ... | ... |
@@ -80,10 +80,10 @@ func GetWithStatusError(address string) (resp *http.Response, err error) {
|
| 80 | 80 |
// inspectResponse looks into the http response data at r to determine whether its |
| 81 | 81 |
// content-type is on the list of acceptable content types for remote build contexts. |
| 82 | 82 |
// This function returns: |
| 83 |
-// - a string representation of the detected content-type |
|
| 84 |
-// - an io.Reader for the response body |
|
| 85 |
-// - an error value which will be non-nil either when something goes wrong while |
|
| 86 |
-// reading bytes from r or when the detected content-type is not acceptable. |
|
| 83 |
+// - a string representation of the detected content-type |
|
| 84 |
+// - an io.Reader for the response body |
|
| 85 |
+// - an error value which will be non-nil either when something goes wrong while |
|
| 86 |
+// reading bytes from r or when the detected content-type is not acceptable. |
|
| 87 | 87 |
func inspectResponse(ct string, r io.Reader, clen int64) (string, io.Reader, error) {
|
| 88 | 88 |
plen := clen |
| 89 | 89 |
if plen <= 0 || plen > maxPreambleLength {
|
| ... | ... |
@@ -30,12 +30,11 @@ func IsURL(str string) bool {
|
| 30 | 30 |
// |
| 31 | 31 |
// The following patterns are considered to be a Git URL: |
| 32 | 32 |
// |
| 33 |
-// - https://(.*).git(?:#.+)?$ git repository URL with optional fragment, as |
|
| 34 |
-// known to be used by GitHub and GitLab. |
|
| 35 |
-// - http://(.*).git(?:#.+)?$ same, but non-TLS |
|
| 36 |
-// - git://(.*) URLs using git:// scheme |
|
| 37 |
-// - git@(.*) |
|
| 38 |
-// - github.com/ see description below |
|
| 33 |
+// - https://(.*).git(?:#.+)?$ git repository URL with optional fragment, as known to be used by GitHub and GitLab. |
|
| 34 |
+// - http://(.*).git(?:#.+)?$ same, but non-TLS |
|
| 35 |
+// - git://(.*) URLs using git:// scheme |
|
| 36 |
+// - git@(.*) |
|
| 37 |
+// - github.com/ see description below |
|
| 39 | 38 |
// |
| 40 | 39 |
// The github.com/ prefix is a special case used to treat context-paths |
| 41 | 40 |
// starting with "github.com/" as a git URL if the given path does not |
| ... | ... |
@@ -49,7 +48,7 @@ func IsURL(str string) bool {
|
| 49 | 49 |
// path. Code using this function should check if the path exists locally before |
| 50 | 50 |
// using it as a URL. |
| 51 | 51 |
// |
| 52 |
-// Fragments |
|
| 52 |
+// # Fragments |
|
| 53 | 53 |
// |
| 54 | 54 |
// Git URLs accept context configuration in their fragment section, separated by |
| 55 | 55 |
// a colon (`:`). The first part represents the reference to check out, and can |
| ... | ... |
@@ -74,7 +73,6 @@ func IsURL(str string) bool {
|
| 74 | 74 |
// | my-repo.git#master:directory | refs/heads/master | /directory | |
| 75 | 75 |
// | my-repo.git#mytag:directory | refs/tags/my-tag | /directory | |
| 76 | 76 |
// | my-repo.git#mybranch:directory | refs/heads/my-branch | /directory | |
| 77 |
-// |
|
| 78 | 77 |
func IsGitURL(str string) bool {
|
| 79 | 78 |
if IsURL(str) && urlPathWithFragmentSuffix.MatchString(str) {
|
| 80 | 79 |
return true |
| ... | ... |
@@ -4,7 +4,7 @@ Package client is a Go client for the Docker Engine API. |
| 4 | 4 |
For more information about the Engine API, see the documentation: |
| 5 | 5 |
https://docs.docker.com/engine/api/ |
| 6 | 6 |
|
| 7 |
-Usage |
|
| 7 |
+# Usage |
|
| 8 | 8 |
|
| 9 | 9 |
You use the library by creating a client object and calling methods on it. The |
| 10 | 10 |
client can be created either from environment variables with NewClientWithOpts(client.FromEnv), |
| ... | ... |
@@ -37,7 +37,6 @@ For example, to list running containers (the equivalent of "docker ps"): |
| 37 | 37 |
fmt.Printf("%s %s\n", container.ID[:10], container.Image)
|
| 38 | 38 |
} |
| 39 | 39 |
} |
| 40 |
- |
|
| 41 | 40 |
*/ |
| 42 | 41 |
package client // import "github.com/docker/docker/client" |
| 43 | 42 |
|
| ... | ... |
@@ -121,12 +120,10 @@ func CheckRedirect(req *http.Request, via []*http.Request) error {
|
| 121 | 121 |
// itself with values from environment variables (client.FromEnv), and has |
| 122 | 122 |
// automatic API version negotiation enabled (client.WithAPIVersionNegotiation()). |
| 123 | 123 |
// |
| 124 |
-// |
|
| 125 | 124 |
// cli, err := client.NewClientWithOpts( |
| 126 | 125 |
// client.FromEnv, |
| 127 | 126 |
// client.WithAPIVersionNegotiation(), |
| 128 | 127 |
// ) |
| 129 |
-// |
|
| 130 | 128 |
func NewClientWithOpts(ops ...Opt) (*Client, error) {
|
| 131 | 129 |
client, err := defaultHTTPClient(DefaultDockerHost) |
| 132 | 130 |
if err != nil {
|
| ... | ... |
@@ -22,7 +22,7 @@ import ( |
| 22 | 22 |
// multiplexed. |
| 23 | 23 |
// The format of the multiplexed stream is as follows: |
| 24 | 24 |
// |
| 25 |
-// [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT}
|
|
| 25 |
+// [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT}
|
|
| 26 | 26 |
// |
| 27 | 27 |
// STREAM_TYPE can be 1 for stdout and 2 for stderr |
| 28 | 28 |
// |
| ... | ... |
@@ -24,7 +24,7 @@ import ( |
| 24 | 24 |
// multiplexed. |
| 25 | 25 |
// The format of the multiplexed stream is as follows: |
| 26 | 26 |
// |
| 27 |
-// [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT}
|
|
| 27 |
+// [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT}
|
|
| 28 | 28 |
// |
| 29 | 29 |
// STREAM_TYPE can be 1 for stdout and 2 for stderr |
| 30 | 30 |
// |
| ... | ... |
@@ -648,7 +648,7 @@ func newAPIServerConfig(config *config.Config) (*apiserver.Config, error) {
|
| 648 | 648 |
|
| 649 | 649 |
// checkTLSAuthOK checks basically for an explicitly disabled TLS/TLSVerify |
| 650 | 650 |
// Going forward we do not want to support a scenario where dockerd listens |
| 651 |
-// on TCP without either TLS client auth (or an explicit opt-in to disable it) |
|
| 651 |
+// on TCP without either TLS client auth (or an explicit opt-in to disable it) |
|
| 652 | 652 |
func checkTLSAuthOK(c *config.Config) bool {
|
| 653 | 653 |
if c.TLS == nil {
|
| 654 | 654 |
// Either TLS is enabled by default, in which case TLS verification should be enabled by default, or explicitly disabled |
| ... | ... |
@@ -14,14 +14,13 @@ import ( |
| 14 | 14 |
// behavior expected from a vanilla unix command-line tool in general |
| 15 | 15 |
// (and the Docker engine in particular). |
| 16 | 16 |
// |
| 17 |
-// * If SIGINT or SIGTERM are received, `cleanup` is called, then the process is terminated. |
|
| 18 |
-// * If SIGINT or SIGTERM are received 3 times before cleanup is complete, then cleanup is |
|
| 19 |
-// skipped and the process is terminated immediately (allows force quit of stuck daemon) |
|
| 20 |
-// * A SIGQUIT always causes an exit without cleanup, with a goroutine dump preceding exit. |
|
| 21 |
-// * Ignore SIGPIPE events. These are generated by systemd when journald is restarted while |
|
| 22 |
-// the docker daemon is not restarted and also running under systemd. |
|
| 23 |
-// Fixes https://github.com/docker/docker/issues/19728 |
|
| 24 |
-// |
|
| 17 |
+// - If SIGINT or SIGTERM are received, `cleanup` is called, then the process is terminated. |
|
| 18 |
+// - If SIGINT or SIGTERM are received 3 times before cleanup is complete, then cleanup is |
|
| 19 |
+// skipped and the process is terminated immediately (allows force quit of stuck daemon) |
|
| 20 |
+// - A SIGQUIT always causes an exit without cleanup, with a goroutine dump preceding exit. |
|
| 21 |
+// - Ignore SIGPIPE events. These are generated by systemd when journald is restarted while |
|
| 22 |
+// the docker daemon is not restarted and also running under systemd. |
|
| 23 |
+// Fixes https://github.com/docker/docker/issues/19728 |
|
| 25 | 24 |
func Trap(cleanup func(), logger interface {
|
| 26 | 25 |
Info(args ...interface{})
|
| 27 | 26 |
}) {
|
| ... | ... |
@@ -295,10 +295,11 @@ func (container *Container) SetupWorkingDirectory(rootIdentity idtools.Identity) |
| 295 | 295 |
// particular path inside the container as though you were a process in that |
| 296 | 296 |
// container. |
| 297 | 297 |
// |
| 298 |
-// NOTE: The returned path is *only* safely scoped inside the container's BaseFS |
|
| 299 |
-// if no component of the returned path changes (such as a component |
|
| 300 |
-// symlinking to a different path) between using this method and using the |
|
| 301 |
-// path. See symlink.FollowSymlinkInScope for more details. |
|
| 298 |
+// # NOTE |
|
| 299 |
+// The returned path is *only* safely scoped inside the container's BaseFS |
|
| 300 |
+// if no component of the returned path changes (such as a component |
|
| 301 |
+// symlinking to a different path) between using this method and using the |
|
| 302 |
+// path. See symlink.FollowSymlinkInScope for more details. |
|
| 302 | 303 |
func (container *Container) GetResourcePath(path string) (string, error) {
|
| 303 | 304 |
if container.BaseFS == nil {
|
| 304 | 305 |
return "", errors.New("GetResourcePath: BaseFS of container " + container.ID + " is unexpectedly nil")
|
| ... | ... |
@@ -324,10 +325,11 @@ func (container *Container) GetResourcePath(path string) (string, error) {
|
| 324 | 324 |
// Only use this method to safely access the container's `container.json` or |
| 325 | 325 |
// other metadata files. If in doubt, use container.GetResourcePath. |
| 326 | 326 |
// |
| 327 |
-// NOTE: The returned path is *only* safely scoped inside the container's root |
|
| 328 |
-// if no component of the returned path changes (such as a component |
|
| 329 |
-// symlinking to a different path) between using this method and using the |
|
| 330 |
-// path. See symlink.FollowSymlinkInScope for more details. |
|
| 327 |
+// # NOTE |
|
| 328 |
+// The returned path is *only* safely scoped inside the container's root |
|
| 329 |
+// if no component of the returned path changes (such as a component |
|
| 330 |
+// symlinking to a different path) between using this method and using the |
|
| 331 |
+// path. See symlink.FollowSymlinkInScope for more details. |
|
| 331 | 332 |
func (container *Container) GetRootResourcePath(path string) (string, error) {
|
| 332 | 333 |
// IMPORTANT - These are paths on the OS where the daemon is running, hence |
| 333 | 334 |
// any filepath operations must be done in an OS agnostic way. |
| ... | ... |
@@ -205,9 +205,9 @@ func resolveInterfaceAddr(specifiedInterface string) (net.IP, error) {
|
| 205 | 205 |
} |
| 206 | 206 |
|
| 207 | 207 |
// resolveInputIPAddr tries to resolve the IP address from the string passed as input |
| 208 |
-// - tries to match the string as an interface name, if so returns the IP address associated with it |
|
| 209 |
-// - on failure of previous step tries to parse the string as an IP address itself |
|
| 210 |
-// if succeeds returns the IP address |
|
| 208 |
+// - tries to match the string as an interface name, if so returns the IP address associated with it |
|
| 209 |
+// - on failure of previous step tries to parse the string as an IP address itself |
|
| 210 |
+// if succeeds returns the IP address |
|
| 211 | 211 |
func resolveInputIPAddr(input string, isUnspecifiedValid bool) (net.IP, error) {
|
| 212 | 212 |
// Try to see if it is an interface name |
| 213 | 213 |
interfaceAddr, err := resolveInterfaceAddr(input) |
| ... | ... |
@@ -27,11 +27,11 @@ import ( |
| 27 | 27 |
|
| 28 | 28 |
// GetContainer looks for a container using the provided information, which could be |
| 29 | 29 |
// one of the following inputs from the caller: |
| 30 |
-// - A full container ID, which will exact match a container in daemon's list |
|
| 31 |
-// - A container name, which will only exact match via the GetByName() function |
|
| 32 |
-// - A partial container ID prefix (e.g. short ID) of any length that is |
|
| 33 |
-// unique enough to only return a single container object |
|
| 34 |
-// If none of these searches succeed, an error is returned |
|
| 30 |
+// - A full container ID, which will exact match a container in daemon's list |
|
| 31 |
+// - A container name, which will only exact match via the GetByName() function |
|
| 32 |
+// - A partial container ID prefix (e.g. short ID) of any length that is |
|
| 33 |
+// unique enough to only return a single container object |
|
| 34 |
+// If none of these searches succeed, an error is returned |
|
| 35 | 35 |
func (daemon *Daemon) GetContainer(prefixOrName string) (*container.Container, error) {
|
| 36 | 36 |
if len(prefixOrName) == 0 {
|
| 37 | 37 |
return nil, errors.WithStack(invalidIdentifier(prefixOrName)) |
| ... | ... |
@@ -1077,15 +1077,16 @@ func setupInitLayer(idMapping idtools.IdentityMapping) func(containerfs.Containe |
| 1077 | 1077 |
} |
| 1078 | 1078 |
|
| 1079 | 1079 |
// Parse the remapped root (user namespace) option, which can be one of: |
| 1080 |
-// username - valid username from /etc/passwd |
|
| 1081 |
-// username:groupname - valid username; valid groupname from /etc/group |
|
| 1082 |
-// uid - 32-bit unsigned int valid Linux UID value |
|
| 1083 |
-// uid:gid - uid value; 32-bit unsigned int Linux GID value |
|
| 1084 | 1080 |
// |
| 1085 |
-// If no groupname is specified, and a username is specified, an attempt |
|
| 1086 |
-// will be made to lookup a gid for that username as a groupname |
|
| 1081 |
+// - username - valid username from /etc/passwd |
|
| 1082 |
+// - username:groupname - valid username; valid groupname from /etc/group |
|
| 1083 |
+// - uid - 32-bit unsigned int valid Linux UID value |
|
| 1084 |
+// - uid:gid - uid value; 32-bit unsigned int Linux GID value |
|
| 1087 | 1085 |
// |
| 1088 |
-// If names are used, they are verified to exist in passwd/group |
|
| 1086 |
+// If no groupname is specified, and a username is specified, an attempt |
|
| 1087 |
+// will be made to lookup a gid for that username as a groupname |
|
| 1088 |
+// |
|
| 1089 |
+// If names are used, they are verified to exist in passwd/group |
|
| 1089 | 1090 |
func parseRemappedRoot(usergrp string) (string, string, error) {
|
| 1090 | 1091 |
|
| 1091 | 1092 |
var ( |
| ... | ... |
@@ -30,10 +30,11 @@ type NaiveDiffDriver struct {
|
| 30 | 30 |
// NewNaiveDiffDriver returns a fully functional driver that wraps the |
| 31 | 31 |
// given ProtoDriver and adds the capability of the following methods which |
| 32 | 32 |
// it may or may not support on its own: |
| 33 |
-// Diff(id, parent string) (archive.Archive, error) |
|
| 34 |
-// Changes(id, parent string) ([]archive.Change, error) |
|
| 35 |
-// ApplyDiff(id, parent string, diff archive.Reader) (size int64, err error) |
|
| 36 |
-// DiffSize(id, parent string) (size int64, err error) |
|
| 33 |
+// |
|
| 34 |
+// Diff(id, parent string) (archive.Archive, error) |
|
| 35 |
+// Changes(id, parent string) ([]archive.Change, error) |
|
| 36 |
+// ApplyDiff(id, parent string, diff archive.Reader) (size int64, err error) |
|
| 37 |
+// DiffSize(id, parent string) (size int64, err error) |
|
| 37 | 38 |
func NewNaiveDiffDriver(driver ProtoDriver, idMap idtools.IdentityMapping) Driver {
|
| 38 | 39 |
return &NaiveDiffDriver{ProtoDriver: driver,
|
| 39 | 40 |
idMap: idMap} |
| ... | ... |
@@ -219,7 +219,7 @@ func (i *ImageService) GetImage(refOrID string, platform *specs.Platform) (retIm |
| 219 | 219 |
} |
| 220 | 220 |
|
| 221 | 221 |
// OnlyPlatformWithFallback uses `platforms.Only` with a fallback to handle the case where the platform |
| 222 |
-// being matched does not have a CPU variant. |
|
| 222 |
+// being matched does not have a CPU variant. |
|
| 223 | 223 |
// |
| 224 | 224 |
// The reason for this is that CPU variant is not even if the official image config spec as of this writing. |
| 225 | 225 |
// See: https://github.com/opencontainers/image-spec/pull/809 |
| ... | ... |
@@ -104,9 +104,9 @@ func exportContainerRw(layerStore layer.Store, id, mountLabel string) (arch io.R |
| 104 | 104 |
// the build. |
| 105 | 105 |
// |
| 106 | 106 |
// This method is different from CreateImageFromContainer: |
| 107 |
-// * it doesn't attempt to validate container state |
|
| 108 |
-// * it doesn't send a commit action to metrics |
|
| 109 |
-// * it doesn't log a container commit event |
|
| 107 |
+// - it doesn't attempt to validate container state |
|
| 108 |
+// - it doesn't send a commit action to metrics |
|
| 109 |
+// - it doesn't log a container commit event |
|
| 110 | 110 |
// |
| 111 | 111 |
// This is a temporary shim. Should be removed when builder stops using commit. |
| 112 | 112 |
func (i *ImageService) CommitBuildStep(c backend.CommitConfig) (image.ID, error) {
|
| ... | ... |
@@ -44,13 +44,13 @@ const ( |
| 44 | 44 |
// are divided into two categories grouped by their severity: |
| 45 | 45 |
// |
| 46 | 46 |
// Hard Conflict: |
| 47 |
-// - a pull or build using the image. |
|
| 48 |
-// - any descendant image. |
|
| 49 |
-// - any running container using the image. |
|
| 47 |
+// - a pull or build using the image. |
|
| 48 |
+// - any descendant image. |
|
| 49 |
+// - any running container using the image. |
|
| 50 | 50 |
// |
| 51 | 51 |
// Soft Conflict: |
| 52 |
-// - any stopped container using the image. |
|
| 53 |
-// - any repository tag or digest references to the image. |
|
| 52 |
+// - any stopped container using the image. |
|
| 53 |
+// - any repository tag or digest references to the image. |
|
| 54 | 54 |
// |
| 55 | 55 |
// The image cannot be removed if there are any hard conflicts and can be |
| 56 | 56 |
// removed if there are soft conflicts only if force is true. |
| ... | ... |
@@ -58,7 +58,6 @@ const ( |
| 58 | 58 |
// If prune is true, ancestor images will each attempt to be deleted quietly, |
| 59 | 59 |
// meaning any delete conflicts will cause the image to not be deleted and the |
| 60 | 60 |
// conflict will not be reported. |
| 61 |
-// |
|
| 62 | 61 |
func (i *ImageService) ImageDelete(imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error) {
|
| 63 | 62 |
start := time.Now() |
| 64 | 63 |
records := []types.ImageDeleteResponseItem{}
|
| ... | ... |
@@ -306,7 +306,7 @@ func getBackingFs(v *types.Info) string {
|
| 306 | 306 |
// |
| 307 | 307 |
// Output example from `docker-init --version`: |
| 308 | 308 |
// |
| 309 |
-// tini version 0.18.0 - git.fec3683 |
|
| 309 |
+// tini version 0.18.0 - git.fec3683 |
|
| 310 | 310 |
func parseInitVersion(v string) (version string, commit string, err error) {
|
| 311 | 311 |
parts := strings.Split(v, " - ") |
| 312 | 312 |
|
| ... | ... |
@@ -331,9 +331,9 @@ func parseInitVersion(v string) (version string, commit string, err error) {
|
| 331 | 331 |
// |
| 332 | 332 |
// Output example from `runc --version`: |
| 333 | 333 |
// |
| 334 |
-// runc version 1.0.0-rc5+dev |
|
| 335 |
-// commit: 69663f0bd4b60df09991c08812a60108003fa340 |
|
| 336 |
-// spec: 1.0.0 |
|
| 334 |
+// runc version 1.0.0-rc5+dev |
|
| 335 |
+// commit: 69663f0bd4b60df09991c08812a60108003fa340 |
|
| 336 |
+// spec: 1.0.0 |
|
| 337 | 337 |
func parseRuntimeVersion(v string) (runtime string, version string, commit string, err error) {
|
| 338 | 338 |
lines := strings.Split(strings.TrimSpace(v), "\n") |
| 339 | 339 |
for _, line := range lines {
|
| ... | ... |
@@ -11,19 +11,20 @@ import ( |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// ContainerTop handles `docker top` client requests. |
| 14 |
+// |
|
| 14 | 15 |
// Future considerations: |
| 15 |
-// -- Windows users are far more familiar with CPU% total. |
|
| 16 |
-// Further, users on Windows rarely see user/kernel CPU stats split. |
|
| 17 |
-// The kernel returns everything in terms of 100ns. To obtain |
|
| 18 |
-// CPU%, we could do something like docker stats does which takes two |
|
| 19 |
-// samples, subtract the difference and do the maths. Unfortunately this |
|
| 20 |
-// would slow the stat call down and require two kernel calls. So instead, |
|
| 21 |
-// we do something similar to linux and display the CPU as combined HH:MM:SS.mmm. |
|
| 22 |
-// -- Perhaps we could add an argument to display "raw" stats |
|
| 23 |
-// -- "Memory" is an extremely overloaded term in Windows. Hence we do what |
|
| 24 |
-// task manager does and use the private working set as the memory counter. |
|
| 25 |
-// We could return more info for those who really understand how memory |
|
| 26 |
-// management works in Windows if we introduced a "raw" stats (above). |
|
| 16 |
+// - Windows users are far more familiar with CPU% total. |
|
| 17 |
+// Further, users on Windows rarely see user/kernel CPU stats split. |
|
| 18 |
+// The kernel returns everything in terms of 100ns. To obtain |
|
| 19 |
+// CPU%, we could do something like docker stats does which takes two |
|
| 20 |
+// samples, subtract the difference and do the maths. Unfortunately this |
|
| 21 |
+// would slow the stat call down and require two kernel calls. So instead, |
|
| 22 |
+// we do something similar to linux and display the CPU as combined HH:MM:SS.mmm. |
|
| 23 |
+// - Perhaps we could add an argument to display "raw" stats |
|
| 24 |
+// - "Memory" is an extremely overloaded term in Windows. Hence we do what |
|
| 25 |
+// task manager does and use the private working set as the memory counter. |
|
| 26 |
+// We could return more info for those who really understand how memory |
|
| 27 |
+// management works in Windows if we introduced a "raw" stats (above). |
|
| 27 | 28 |
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*containertypes.ContainerTopOKBody, error) {
|
| 28 | 29 |
// It's not at all an equivalent to linux 'ps' on Windows |
| 29 | 30 |
if psArgs != "" {
|
| ... | ... |
@@ -14,7 +14,8 @@ type UAStringKey struct{}
|
| 14 | 14 |
|
| 15 | 15 |
// DockerUserAgent is the User-Agent the Docker client uses to identify itself. |
| 16 | 16 |
// In accordance with RFC 7231 (5.5.3) is of the form: |
| 17 |
-// [docker client's UA] UpstreamClient([upstream client's UA]) |
|
| 17 |
+// |
|
| 18 |
+// [docker client's UA] UpstreamClient([upstream client's UA]) |
|
| 18 | 19 |
func DockerUserAgent(ctx context.Context) string {
|
| 19 | 20 |
httpVersion := make([]useragent.VersionInfo, 0, 6) |
| 20 | 21 |
httpVersion = append(httpVersion, useragent.VersionInfo{Name: "docker", Version: Version})
|
| ... | ... |
@@ -68,7 +69,8 @@ func escapeStr(s string, charsToEscape string) string {
|
| 68 | 68 |
|
| 69 | 69 |
// insertUpstreamUserAgent adds the upstream client useragent to create a user-agent |
| 70 | 70 |
// string of the form: |
| 71 |
-// $dockerUA UpstreamClient($upstreamUA) |
|
| 71 |
+// |
|
| 72 |
+// $dockerUA UpstreamClient($upstreamUA) |
|
| 72 | 73 |
func insertUpstreamUserAgent(upstreamUA string, dockerUA string) string {
|
| 73 | 74 |
charsToEscape := `();\` |
| 74 | 75 |
upstreamUAEscaped := escapeStr(upstreamUA, charsToEscape) |
| ... | ... |
@@ -93,9 +93,10 @@ func (s *DockerCLICpSuite) TestCpFromSymlinkDestination(c *testing.T) {
|
| 93 | 93 |
// J | yes | yes | yes | yes | - | copy dir contents |
| 94 | 94 |
// |
| 95 | 95 |
|
| 96 |
-// A. SRC specifies a file and DST (no trailing path separator) doesn't |
|
| 97 |
-// exist. This should create a file with the name DST and copy the |
|
| 98 |
-// contents of the source file into it. |
|
| 96 |
+// A. SRC specifies a file and DST (no trailing path separator) doesn't exist. |
|
| 97 |
+// |
|
| 98 |
+// This should create a file with the name DST and copy the contents of the |
|
| 99 |
+// source file into it. |
|
| 99 | 100 |
func (s *DockerCLICpSuite) TestCpFromCaseA(c *testing.T) {
|
| 100 | 101 |
testRequires(c, DaemonIsLinux) |
| 101 | 102 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -112,9 +113,10 @@ func (s *DockerCLICpSuite) TestCpFromCaseA(c *testing.T) {
|
| 112 | 112 |
assert.NilError(c, fileContentEquals(c, dstPath, "file1\n")) |
| 113 | 113 |
} |
| 114 | 114 |
|
| 115 |
-// B. SRC specifies a file and DST (with trailing path separator) doesn't |
|
| 116 |
-// exist. This should cause an error because the copy operation cannot |
|
| 117 |
-// create a directory when copying a single file. |
|
| 115 |
+// B. SRC specifies a file and DST (with trailing path separator) doesn't exist. |
|
| 116 |
+// |
|
| 117 |
+// This should cause an error because the copy operation cannot create a directory |
|
| 118 |
+// when copying a single file. |
|
| 118 | 119 |
func (s *DockerCLICpSuite) TestCpFromCaseB(c *testing.T) {
|
| 119 | 120 |
testRequires(c, DaemonIsLinux) |
| 120 | 121 |
containerID := makeTestContainer(c, testContainerOptions{addContent: true})
|
| ... | ... |
@@ -130,8 +132,9 @@ func (s *DockerCLICpSuite) TestCpFromCaseB(c *testing.T) {
|
| 130 | 130 |
assert.Assert(c, isCpDirNotExist(err), "expected DirNotExists error, but got %T: %s", err, err) |
| 131 | 131 |
} |
| 132 | 132 |
|
| 133 |
-// C. SRC specifies a file and DST exists as a file. This should overwrite |
|
| 134 |
-// the file at DST with the contents of the source file. |
|
| 133 |
+// C. SRC specifies a file and DST exists as a file. |
|
| 134 |
+// |
|
| 135 |
+// This should overwrite the file at DST with the contents of the source file. |
|
| 135 | 136 |
func (s *DockerCLICpSuite) TestCpFromCaseC(c *testing.T) {
|
| 136 | 137 |
testRequires(c, DaemonIsLinux) |
| 137 | 138 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -152,9 +155,10 @@ func (s *DockerCLICpSuite) TestCpFromCaseC(c *testing.T) {
|
| 152 | 152 |
assert.NilError(c, fileContentEquals(c, dstPath, "file1\n")) |
| 153 | 153 |
} |
| 154 | 154 |
|
| 155 |
-// D. SRC specifies a file and DST exists as a directory. This should place |
|
| 156 |
-// a copy of the source file inside it using the basename from SRC. Ensure |
|
| 157 |
-// this works whether DST has a trailing path separator or not. |
|
| 155 |
+// D. SRC specifies a file and DST exists as a directory. |
|
| 156 |
+// |
|
| 157 |
+// This should place a copy of the source file inside it using the basename from |
|
| 158 |
+// SRC. Ensure this works whether DST has a trailing path separator or not. |
|
| 158 | 159 |
func (s *DockerCLICpSuite) TestCpFromCaseD(c *testing.T) {
|
| 159 | 160 |
testRequires(c, DaemonIsLinux) |
| 160 | 161 |
containerID := makeTestContainer(c, testContainerOptions{addContent: true})
|
| ... | ... |
@@ -186,10 +190,11 @@ func (s *DockerCLICpSuite) TestCpFromCaseD(c *testing.T) {
|
| 186 | 186 |
assert.NilError(c, fileContentEquals(c, dstPath, "file1\n")) |
| 187 | 187 |
} |
| 188 | 188 |
|
| 189 |
-// E. SRC specifies a directory and DST does not exist. This should create a |
|
| 190 |
-// directory at DST and copy the contents of the SRC directory into the DST |
|
| 191 |
-// directory. Ensure this works whether DST has a trailing path separator or |
|
| 192 |
-// not. |
|
| 189 |
+// E. SRC specifies a directory and DST does not exist. |
|
| 190 |
+// |
|
| 191 |
+// This should create a directory at DST and copy the contents of the SRC directory |
|
| 192 |
+// into the DST directory. Ensure this works whether DST has a trailing path |
|
| 193 |
+// separator or not. |
|
| 193 | 194 |
func (s *DockerCLICpSuite) TestCpFromCaseE(c *testing.T) {
|
| 194 | 195 |
testRequires(c, DaemonIsLinux) |
| 195 | 196 |
containerID := makeTestContainer(c, testContainerOptions{addContent: true})
|
| ... | ... |
@@ -214,8 +219,10 @@ func (s *DockerCLICpSuite) TestCpFromCaseE(c *testing.T) {
|
| 214 | 214 |
assert.NilError(c, fileContentEquals(c, dstPath, "file1-1\n")) |
| 215 | 215 |
} |
| 216 | 216 |
|
| 217 |
-// F. SRC specifies a directory and DST exists as a file. This should cause an |
|
| 218 |
-// error as it is not possible to overwrite a file with a directory. |
|
| 217 |
+// F. SRC specifies a directory and DST exists as a file. |
|
| 218 |
+// |
|
| 219 |
+// This should cause an error as it is not possible to overwrite a file with a |
|
| 220 |
+// directory. |
|
| 219 | 221 |
func (s *DockerCLICpSuite) TestCpFromCaseF(c *testing.T) {
|
| 220 | 222 |
testRequires(c, DaemonIsLinux) |
| 221 | 223 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -235,9 +242,10 @@ func (s *DockerCLICpSuite) TestCpFromCaseF(c *testing.T) {
|
| 235 | 235 |
assert.Assert(c, isCpCannotCopyDir(err), "expected ErrCannotCopyDir error, but got %T: %s", err, err) |
| 236 | 236 |
} |
| 237 | 237 |
|
| 238 |
-// G. SRC specifies a directory and DST exists as a directory. This should copy |
|
| 239 |
-// the SRC directory and all its contents to the DST directory. Ensure this |
|
| 240 |
-// works whether DST has a trailing path separator or not. |
|
| 238 |
+// G. SRC specifies a directory and DST exists as a directory. |
|
| 239 |
+// |
|
| 240 |
+// This should copy the SRC directory and all its contents to the DST directory. |
|
| 241 |
+// Ensure this works whether DST has a trailing path separator or not. |
|
| 241 | 242 |
func (s *DockerCLICpSuite) TestCpFromCaseG(c *testing.T) {
|
| 242 | 243 |
testRequires(c, DaemonIsLinux) |
| 243 | 244 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -268,10 +276,11 @@ func (s *DockerCLICpSuite) TestCpFromCaseG(c *testing.T) {
|
| 268 | 268 |
assert.NilError(c, fileContentEquals(c, dstPath, "file1-1\n")) |
| 269 | 269 |
} |
| 270 | 270 |
|
| 271 |
-// H. SRC specifies a directory's contents only and DST does not exist. This |
|
| 272 |
-// should create a directory at DST and copy the contents of the SRC |
|
| 273 |
-// directory (but not the directory itself) into the DST directory. Ensure |
|
| 274 |
-// this works whether DST has a trailing path separator or not. |
|
| 271 |
+// H. SRC specifies a directory's contents only and DST does not exist. |
|
| 272 |
+// |
|
| 273 |
+// This should create a directory at DST and copy the contents of the SRC |
|
| 274 |
+// directory (but not the directory itself) into the DST directory. Ensure |
|
| 275 |
+// this works whether DST has a trailing path separator or not. |
|
| 275 | 276 |
func (s *DockerCLICpSuite) TestCpFromCaseH(c *testing.T) {
|
| 276 | 277 |
testRequires(c, DaemonIsLinux) |
| 277 | 278 |
containerID := makeTestContainer(c, testContainerOptions{addContent: true})
|
| ... | ... |
@@ -296,9 +305,10 @@ func (s *DockerCLICpSuite) TestCpFromCaseH(c *testing.T) {
|
| 296 | 296 |
assert.NilError(c, fileContentEquals(c, dstPath, "file1-1\n")) |
| 297 | 297 |
} |
| 298 | 298 |
|
| 299 |
-// I. SRC specifies a directory's contents only and DST exists as a file. This |
|
| 300 |
-// should cause an error as it is not possible to overwrite a file with a |
|
| 301 |
-// directory. |
|
| 299 |
+// I. SRC specifies a directory's contents only and DST exists as a file. |
|
| 300 |
+// |
|
| 301 |
+// This should cause an error as it is not possible to overwrite a file with a |
|
| 302 |
+// directory. |
|
| 302 | 303 |
func (s *DockerCLICpSuite) TestCpFromCaseI(c *testing.T) {
|
| 303 | 304 |
testRequires(c, DaemonIsLinux) |
| 304 | 305 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -319,9 +329,10 @@ func (s *DockerCLICpSuite) TestCpFromCaseI(c *testing.T) {
|
| 319 | 319 |
} |
| 320 | 320 |
|
| 321 | 321 |
// J. SRC specifies a directory's contents only and DST exists as a directory. |
| 322 |
-// This should copy the contents of the SRC directory (but not the directory |
|
| 323 |
-// itself) into the DST directory. Ensure this works whether DST has a |
|
| 324 |
-// trailing path separator or not. |
|
| 322 |
+// |
|
| 323 |
+// This should copy the contents of the SRC directory (but not the directory |
|
| 324 |
+// itself) into the DST directory. Ensure this works whether DST has a |
|
| 325 |
+// trailing path separator or not. |
|
| 325 | 326 |
func (s *DockerCLICpSuite) TestCpFromCaseJ(c *testing.T) {
|
| 326 | 327 |
testRequires(c, DaemonIsLinux) |
| 327 | 328 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -97,9 +97,10 @@ func (s *DockerCLICpSuite) TestCpToSymlinkDestination(c *testing.T) {
|
| 97 | 97 |
// J | yes | yes | yes | yes | - | copy dir contents |
| 98 | 98 |
// |
| 99 | 99 |
|
| 100 |
-// A. SRC specifies a file and DST (no trailing path separator) doesn't |
|
| 101 |
-// exist. This should create a file with the name DST and copy the |
|
| 102 |
-// contents of the source file into it. |
|
| 100 |
+// A. SRC specifies a file and DST (no trailing path separator) doesn't exist. |
|
| 101 |
+// |
|
| 102 |
+// This should create a file with the name DST and copy the contents of the |
|
| 103 |
+// source file into it. |
|
| 103 | 104 |
func (s *DockerCLICpSuite) TestCpToCaseA(c *testing.T) {
|
| 104 | 105 |
containerID := makeTestContainer(c, testContainerOptions{
|
| 105 | 106 |
workDir: "/root", command: makeCatFileCommand("itWorks.txt"),
|
| ... | ... |
@@ -117,9 +118,10 @@ func (s *DockerCLICpSuite) TestCpToCaseA(c *testing.T) {
|
| 117 | 117 |
assert.NilError(c, containerStartOutputEquals(c, containerID, "file1\n")) |
| 118 | 118 |
} |
| 119 | 119 |
|
| 120 |
-// B. SRC specifies a file and DST (with trailing path separator) doesn't |
|
| 121 |
-// exist. This should cause an error because the copy operation cannot |
|
| 122 |
-// create a directory when copying a single file. |
|
| 120 |
+// B. SRC specifies a file and DST (with trailing path separator) doesn't exist. |
|
| 121 |
+// |
|
| 122 |
+// This should cause an error because the copy operation cannot create a |
|
| 123 |
+// directory when copying a single file. |
|
| 123 | 124 |
func (s *DockerCLICpSuite) TestCpToCaseB(c *testing.T) {
|
| 124 | 125 |
containerID := makeTestContainer(c, testContainerOptions{
|
| 125 | 126 |
command: makeCatFileCommand("testDir/file1"),
|
| ... | ... |
@@ -138,8 +140,9 @@ func (s *DockerCLICpSuite) TestCpToCaseB(c *testing.T) {
|
| 138 | 138 |
assert.Assert(c, isCpDirNotExist(err), "expected DirNotExists error, but got %T: %s", err, err) |
| 139 | 139 |
} |
| 140 | 140 |
|
| 141 |
-// C. SRC specifies a file and DST exists as a file. This should overwrite |
|
| 142 |
-// the file at DST with the contents of the source file. |
|
| 141 |
+// C. SRC specifies a file and DST exists as a file. |
|
| 142 |
+// |
|
| 143 |
+// This should overwrite the file at DST with the contents of the source file. |
|
| 143 | 144 |
func (s *DockerCLICpSuite) TestCpToCaseC(c *testing.T) {
|
| 144 | 145 |
testRequires(c, DaemonIsLinux) |
| 145 | 146 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -161,9 +164,10 @@ func (s *DockerCLICpSuite) TestCpToCaseC(c *testing.T) {
|
| 161 | 161 |
assert.NilError(c, containerStartOutputEquals(c, containerID, "file1\n"), "Should now contain file1's contents") |
| 162 | 162 |
} |
| 163 | 163 |
|
| 164 |
-// D. SRC specifies a file and DST exists as a directory. This should place |
|
| 165 |
-// a copy of the source file inside it using the basename from SRC. Ensure |
|
| 166 |
-// this works whether DST has a trailing path separator or not. |
|
| 164 |
+// D. SRC specifies a file and DST exists as a directory. |
|
| 165 |
+// |
|
| 166 |
+// This should place a copy of the source file inside it using the basename from |
|
| 167 |
+// SRC. Ensure this works whether DST has a trailing path separator or not. |
|
| 167 | 168 |
func (s *DockerCLICpSuite) TestCpToCaseD(c *testing.T) {
|
| 168 | 169 |
testRequires(c, DaemonIsLinux) |
| 169 | 170 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -198,10 +202,11 @@ func (s *DockerCLICpSuite) TestCpToCaseD(c *testing.T) {
|
| 198 | 198 |
assert.NilError(c, containerStartOutputEquals(c, containerID, "file1\n"), "Should now contain file1's contents") |
| 199 | 199 |
} |
| 200 | 200 |
|
| 201 |
-// E. SRC specifies a directory and DST does not exist. This should create a |
|
| 202 |
-// directory at DST and copy the contents of the SRC directory into the DST |
|
| 203 |
-// directory. Ensure this works whether DST has a trailing path separator or |
|
| 204 |
-// not. |
|
| 201 |
+// E. SRC specifies a directory and DST does not exist. |
|
| 202 |
+// |
|
| 203 |
+// This should create a directory at DST and copy the contents of the SRC |
|
| 204 |
+// directory into the DST directory. Ensure this works whether DST has a |
|
| 205 |
+// trailing path separator or not. |
|
| 205 | 206 |
func (s *DockerCLICpSuite) TestCpToCaseE(c *testing.T) {
|
| 206 | 207 |
containerID := makeTestContainer(c, testContainerOptions{
|
| 207 | 208 |
command: makeCatFileCommand("/testDir/file1-1"),
|
| ... | ... |
@@ -231,8 +236,10 @@ func (s *DockerCLICpSuite) TestCpToCaseE(c *testing.T) {
|
| 231 | 231 |
assert.NilError(c, containerStartOutputEquals(c, containerID, "file1-1\n"), "Should now contain file1-1's contents") |
| 232 | 232 |
} |
| 233 | 233 |
|
| 234 |
-// F. SRC specifies a directory and DST exists as a file. This should cause an |
|
| 235 |
-// error as it is not possible to overwrite a file with a directory. |
|
| 234 |
+// F. SRC specifies a directory and DST exists as a file. |
|
| 235 |
+// |
|
| 236 |
+// This should cause an error as it is not possible to overwrite a file with a |
|
| 237 |
+// directory. |
|
| 236 | 238 |
func (s *DockerCLICpSuite) TestCpToCaseF(c *testing.T) {
|
| 237 | 239 |
testRequires(c, DaemonIsLinux) |
| 238 | 240 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -252,9 +259,10 @@ func (s *DockerCLICpSuite) TestCpToCaseF(c *testing.T) {
|
| 252 | 252 |
assert.Assert(c, isCpCannotCopyDir(err), "expected ErrCannotCopyDir error, but got %T: %s", err, err) |
| 253 | 253 |
} |
| 254 | 254 |
|
| 255 |
-// G. SRC specifies a directory and DST exists as a directory. This should copy |
|
| 256 |
-// the SRC directory and all its contents to the DST directory. Ensure this |
|
| 257 |
-// works whether DST has a trailing path separator or not. |
|
| 255 |
+// G. SRC specifies a directory and DST exists as a directory. |
|
| 256 |
+// |
|
| 257 |
+// This should copy the SRC directory and all its contents to the DST directory. |
|
| 258 |
+// Ensure this works whether DST has a trailing path separator or not. |
|
| 258 | 259 |
func (s *DockerCLICpSuite) TestCpToCaseG(c *testing.T) {
|
| 259 | 260 |
testRequires(c, DaemonIsLinux) |
| 260 | 261 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -289,10 +297,11 @@ func (s *DockerCLICpSuite) TestCpToCaseG(c *testing.T) {
|
| 289 | 289 |
assert.NilError(c, containerStartOutputEquals(c, containerID, "file1-1\n"), "Should now contain file1-1's contents") |
| 290 | 290 |
} |
| 291 | 291 |
|
| 292 |
-// H. SRC specifies a directory's contents only and DST does not exist. This |
|
| 293 |
-// should create a directory at DST and copy the contents of the SRC |
|
| 294 |
-// directory (but not the directory itself) into the DST directory. Ensure |
|
| 295 |
-// this works whether DST has a trailing path separator or not. |
|
| 292 |
+// H. SRC specifies a directory's contents only and DST does not exist. |
|
| 293 |
+// |
|
| 294 |
+// This should create a directory at DST and copy the contents of the SRC |
|
| 295 |
+// directory (but not the directory itself) into the DST directory. Ensure |
|
| 296 |
+// this works whether DST has a trailing path separator or not. |
|
| 296 | 297 |
func (s *DockerCLICpSuite) TestCpToCaseH(c *testing.T) {
|
| 297 | 298 |
containerID := makeTestContainer(c, testContainerOptions{
|
| 298 | 299 |
command: makeCatFileCommand("/testDir/file1-1"),
|
| ... | ... |
@@ -322,9 +331,10 @@ func (s *DockerCLICpSuite) TestCpToCaseH(c *testing.T) {
|
| 322 | 322 |
assert.NilError(c, containerStartOutputEquals(c, containerID, "file1-1\n"), "Should now contain file1-1's contents") |
| 323 | 323 |
} |
| 324 | 324 |
|
| 325 |
-// I. SRC specifies a directory's contents only and DST exists as a file. This |
|
| 326 |
-// should cause an error as it is not possible to overwrite a file with a |
|
| 327 |
-// directory. |
|
| 325 |
+// I. SRC specifies a directory's contents only and DST exists as a file. |
|
| 326 |
+// |
|
| 327 |
+// This should cause an error as it is not possible to overwrite a file with a |
|
| 328 |
+// directory. |
|
| 328 | 329 |
func (s *DockerCLICpSuite) TestCpToCaseI(c *testing.T) {
|
| 329 | 330 |
testRequires(c, DaemonIsLinux) |
| 330 | 331 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -345,9 +355,10 @@ func (s *DockerCLICpSuite) TestCpToCaseI(c *testing.T) {
|
| 345 | 345 |
} |
| 346 | 346 |
|
| 347 | 347 |
// J. SRC specifies a directory's contents only and DST exists as a directory. |
| 348 |
-// This should copy the contents of the SRC directory (but not the directory |
|
| 349 |
-// itself) into the DST directory. Ensure this works whether DST has a |
|
| 350 |
-// trailing path separator or not. |
|
| 348 |
+// |
|
| 349 |
+// This should copy the contents of the SRC directory (but not the directory |
|
| 350 |
+// itself) into the DST directory. Ensure this works whether DST has a |
|
| 351 |
+// trailing path separator or not. |
|
| 351 | 352 |
func (s *DockerCLICpSuite) TestCpToCaseJ(c *testing.T) {
|
| 352 | 353 |
testRequires(c, DaemonIsLinux) |
| 353 | 354 |
containerID := makeTestContainer(c, testContainerOptions{
|
| ... | ... |
@@ -506,8 +506,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c * |
| 506 | 506 |
|
| 507 | 507 |
// Ensure only cached paths are used in volume list to prevent N+1 calls to `VolumeDriver.Path` |
| 508 | 508 |
// |
| 509 |
-// TODO(@cpuguy83): This test is testing internal implementation. In all the cases here, there may not even be a path |
|
| 510 |
-// available because the volume is not even mounted. Consider removing this test. |
|
| 509 |
+// TODO(@cpuguy83): This test is testing internal implementation. In all the cases here, there may not even be a path available because the volume is not even mounted. Consider removing this test. |
|
| 511 | 510 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverPathCalls(c *testing.T) {
|
| 512 | 511 |
s.d.Start(c) |
| 513 | 512 |
assert.Equal(c, s.ec.paths, 0) |
| ... | ... |
@@ -26,9 +26,9 @@ import ( |
| 26 | 26 |
// |
| 27 | 27 |
// The format of /proc/self/mountinfo is like: |
| 28 | 28 |
// |
| 29 |
-// 29 23 0:24 / /dev/shm rw,nosuid,nodev shared:4 - tmpfs tmpfs rw |
|
| 30 |
-// ^^^^\ |
|
| 31 |
-// - this is the minor:major we look for |
|
| 29 |
+// 29 23 0:24 / /dev/shm rw,nosuid,nodev shared:4 - tmpfs tmpfs rw |
|
| 30 |
+// ^^^^\ |
|
| 31 |
+// - this is the minor:major we look for |
|
| 32 | 32 |
func testIpcCheckDevExists(mm string) (bool, error) {
|
| 33 | 33 |
f, err := os.Open("/proc/self/mountinfo")
|
| 34 | 34 |
if err != nil {
|
| ... | ... |
@@ -33,8 +33,8 @@ func (res *ExecResult) Combined() string {
|
| 33 | 33 |
|
| 34 | 34 |
// Exec executes a command inside a container, returning the result |
| 35 | 35 |
// containing stdout, stderr, and exit code. Note: |
| 36 |
-// - this is a synchronous operation; |
|
| 37 |
-// - cmd stdin is closed. |
|
| 36 |
+// - this is a synchronous operation; |
|
| 37 |
+// - cmd stdin is closed. |
|
| 38 | 38 |
func Exec(ctx context.Context, cli client.APIClient, id string, cmd []string, ops ...func(*types.ExecConfig)) (ExecResult, error) {
|
| 39 | 39 |
// prepare exec |
| 40 | 40 |
execConfig := types.ExecConfig{
|
| ... | ... |
@@ -363,7 +363,7 @@ func TestCreateServiceConfigFileMode(t *testing.T) {
|
| 363 | 363 |
// |
| 364 | 364 |
// To test this, we're going to create a service with the sysctl option |
| 365 | 365 |
// |
| 366 |
-// {"net.ipv4.ip_nonlocal_bind": "0"}
|
|
| 366 |
+// {"net.ipv4.ip_nonlocal_bind": "0"}
|
|
| 367 | 367 |
// |
| 368 | 368 |
// We'll get the service's tasks to get the container ID, and then we'll |
| 369 | 369 |
// inspect the container. If the output of the container inspect contains the |
| ... | ... |
@@ -458,7 +458,7 @@ func TestCreateServiceSysctls(t *testing.T) {
|
| 458 | 458 |
// |
| 459 | 459 |
// To test this, we're going to create a service with the capabilities option |
| 460 | 460 |
// |
| 461 |
-// []string{"CAP_NET_RAW", "CAP_SYS_CHROOT"}
|
|
| 461 |
+// []string{"CAP_NET_RAW", "CAP_SYS_CHROOT"}
|
|
| 462 | 462 |
// |
| 463 | 463 |
// We'll get the service's tasks to get the container ID, and then we'll |
| 464 | 464 |
// inspect the container. If the output of the container inspect contains the |
| ... | ... |
@@ -26,7 +26,7 @@ func hasSystemd() bool {
|
| 26 | 26 |
|
| 27 | 27 |
// TestCgroupDriverSystemdMemoryLimit checks that container |
| 28 | 28 |
// memory limit can be set when using systemd cgroupdriver. |
| 29 |
-// https://github.com/moby/moby/issues/35123 |
|
| 29 |
+// https://github.com/moby/moby/issues/35123 |
|
| 30 | 30 |
func TestCgroupDriverSystemdMemoryLimit(t *testing.T) {
|
| 31 | 31 |
skip.If(t, testEnv.DaemonInfo.OSType == "windows") |
| 32 | 32 |
skip.If(t, !hasSystemd()) |
| ... | ... |
@@ -102,43 +102,43 @@ func (c *client) Version(ctx context.Context) (containerd.Version, error) {
|
| 102 | 102 |
// |
| 103 | 103 |
// Isolation=Process example: |
| 104 | 104 |
// |
| 105 |
-// {
|
|
| 106 |
-// "SystemType": "Container", |
|
| 107 |
-// "Name": "5e0055c814a6005b8e57ac59f9a522066e0af12b48b3c26a9416e23907698776", |
|
| 108 |
-// "Owner": "docker", |
|
| 109 |
-// "VolumePath": "\\\\\\\\?\\\\Volume{66d1ef4c-7a00-11e6-8948-00155ddbef9d}",
|
|
| 110 |
-// "IgnoreFlushesDuringBoot": true, |
|
| 111 |
-// "LayerFolderPath": "C:\\\\control\\\\windowsfilter\\\\5e0055c814a6005b8e57ac59f9a522066e0af12b48b3c26a9416e23907698776", |
|
| 112 |
-// "Layers": [{
|
|
| 113 |
-// "ID": "18955d65-d45a-557b-bf1c-49d6dfefc526", |
|
| 114 |
-// "Path": "C:\\\\control\\\\windowsfilter\\\\65bf96e5760a09edf1790cb229e2dfb2dbd0fcdc0bf7451bae099106bfbfea0c" |
|
| 115 |
-// }], |
|
| 116 |
-// "HostName": "5e0055c814a6", |
|
| 117 |
-// "MappedDirectories": [], |
|
| 118 |
-// "HvPartition": false, |
|
| 119 |
-// "EndpointList": ["eef2649d-bb17-4d53-9937-295a8efe6f2c"], |
|
| 120 |
-// } |
|
| 105 |
+// {
|
|
| 106 |
+// "SystemType": "Container", |
|
| 107 |
+// "Name": "5e0055c814a6005b8e57ac59f9a522066e0af12b48b3c26a9416e23907698776", |
|
| 108 |
+// "Owner": "docker", |
|
| 109 |
+// "VolumePath": "\\\\\\\\?\\\\Volume{66d1ef4c-7a00-11e6-8948-00155ddbef9d}",
|
|
| 110 |
+// "IgnoreFlushesDuringBoot": true, |
|
| 111 |
+// "LayerFolderPath": "C:\\\\control\\\\windowsfilter\\\\5e0055c814a6005b8e57ac59f9a522066e0af12b48b3c26a9416e23907698776", |
|
| 112 |
+// "Layers": [{
|
|
| 113 |
+// "ID": "18955d65-d45a-557b-bf1c-49d6dfefc526", |
|
| 114 |
+// "Path": "C:\\\\control\\\\windowsfilter\\\\65bf96e5760a09edf1790cb229e2dfb2dbd0fcdc0bf7451bae099106bfbfea0c" |
|
| 115 |
+// }], |
|
| 116 |
+// "HostName": "5e0055c814a6", |
|
| 117 |
+// "MappedDirectories": [], |
|
| 118 |
+// "HvPartition": false, |
|
| 119 |
+// "EndpointList": ["eef2649d-bb17-4d53-9937-295a8efe6f2c"], |
|
| 120 |
+// } |
|
| 121 | 121 |
// |
| 122 | 122 |
// Isolation=Hyper-V example: |
| 123 | 123 |
// |
| 124 |
-// {
|
|
| 125 |
-// "SystemType": "Container", |
|
| 126 |
-// "Name": "475c2c58933b72687a88a441e7e0ca4bd72d76413c5f9d5031fee83b98f6045d", |
|
| 127 |
-// "Owner": "docker", |
|
| 128 |
-// "IgnoreFlushesDuringBoot": true, |
|
| 129 |
-// "Layers": [{
|
|
| 130 |
-// "ID": "18955d65-d45a-557b-bf1c-49d6dfefc526", |
|
| 131 |
-// "Path": "C:\\\\control\\\\windowsfilter\\\\65bf96e5760a09edf1790cb229e2dfb2dbd0fcdc0bf7451bae099106bfbfea0c" |
|
| 132 |
-// }], |
|
| 133 |
-// "HostName": "475c2c58933b", |
|
| 134 |
-// "MappedDirectories": [], |
|
| 135 |
-// "HvPartition": true, |
|
| 136 |
-// "EndpointList": ["e1bb1e61-d56f-405e-b75d-fd520cefa0cb"], |
|
| 137 |
-// "DNSSearchList": "a.com,b.com,c.com", |
|
| 138 |
-// "HvRuntime": {
|
|
| 139 |
-// "ImagePath": "C:\\\\control\\\\windowsfilter\\\\65bf96e5760a09edf1790cb229e2dfb2dbd0fcdc0bf7451bae099106bfbfea0c\\\\UtilityVM" |
|
| 140 |
-// }, |
|
| 141 |
-// } |
|
| 124 |
+// {
|
|
| 125 |
+// "SystemType": "Container", |
|
| 126 |
+// "Name": "475c2c58933b72687a88a441e7e0ca4bd72d76413c5f9d5031fee83b98f6045d", |
|
| 127 |
+// "Owner": "docker", |
|
| 128 |
+// "IgnoreFlushesDuringBoot": true, |
|
| 129 |
+// "Layers": [{
|
|
| 130 |
+// "ID": "18955d65-d45a-557b-bf1c-49d6dfefc526", |
|
| 131 |
+// "Path": "C:\\\\control\\\\windowsfilter\\\\65bf96e5760a09edf1790cb229e2dfb2dbd0fcdc0bf7451bae099106bfbfea0c" |
|
| 132 |
+// }], |
|
| 133 |
+// "HostName": "475c2c58933b", |
|
| 134 |
+// "MappedDirectories": [], |
|
| 135 |
+// "HvPartition": true, |
|
| 136 |
+// "EndpointList": ["e1bb1e61-d56f-405e-b75d-fd520cefa0cb"], |
|
| 137 |
+// "DNSSearchList": "a.com,b.com,c.com", |
|
| 138 |
+// "HvRuntime": {
|
|
| 139 |
+// "ImagePath": "C:\\\\control\\\\windowsfilter\\\\65bf96e5760a09edf1790cb229e2dfb2dbd0fcdc0bf7451bae099106bfbfea0c\\\\UtilityVM" |
|
| 140 |
+// }, |
|
| 141 |
+// } |
|
| 142 | 142 |
func (c *client) Create(_ context.Context, id string, spec *specs.Spec, shim string, runtimeOptions interface{}, opts ...containerd.NewContainerOpts) error {
|
| 143 | 143 |
if ctr := c.getContainer(id); ctr != nil {
|
| 144 | 144 |
return errors.WithStack(errdefs.Conflict(errors.New("id already in use")))
|
| ... | ... |
@@ -617,13 +617,14 @@ func findSequence(head *sequence, bytePos uint64) (*sequence, *sequence, uint64, |
| 617 | 617 |
// Remove current sequence if empty. |
| 618 | 618 |
// Check if new sequence can be merged with neighbour (previous/next) sequences. |
| 619 | 619 |
// |
| 620 |
-// |
|
| 621 | 620 |
// Identify "current" sequence containing block: |
| 622 |
-// [prev seq] [current seq] [next seq] |
|
| 621 |
+// |
|
| 622 |
+// [prev seq] [current seq] [next seq] |
|
| 623 | 623 |
// |
| 624 | 624 |
// Based on block position, resulting list of sequences can be any of three forms: |
| 625 | 625 |
// |
| 626 |
-// block position Resulting list of sequences |
|
| 626 |
+// block position Resulting list of sequences |
|
| 627 |
+// |
|
| 627 | 628 |
// A) block is first in current: [prev seq] [new] [modified current seq] [next seq] |
| 628 | 629 |
// B) block is last in current: [prev seq] [modified current seq] [new] [next seq] |
| 629 | 630 |
// C) block is in the middle of current: [prev seq] [curr pre] [new] [curr post] [next seq] |
| ... | ... |
@@ -14,7 +14,7 @@ import ( |
| 14 | 14 |
"github.com/docker/libkv/store" |
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 |
-//DataStore exported |
|
| 17 |
+// DataStore exported |
|
| 18 | 18 |
type DataStore interface {
|
| 19 | 19 |
// GetObject gets data from datastore and unmarshals to the specified object |
| 20 | 20 |
GetObject(key string, o KVObject) error |
| ... | ... |
@@ -174,14 +174,14 @@ func (cfg *ScopeCfg) IsValid() bool {
|
| 174 | 174 |
return true |
| 175 | 175 |
} |
| 176 | 176 |
|
| 177 |
-//Key provides convenient method to create a Key |
|
| 177 |
+// Key provides convenient method to create a Key |
|
| 178 | 178 |
func Key(key ...string) string {
|
| 179 | 179 |
keychain := append(rootChain, key...) |
| 180 | 180 |
str := strings.Join(keychain, "/") |
| 181 | 181 |
return str + "/" |
| 182 | 182 |
} |
| 183 | 183 |
|
| 184 |
-//ParseKey provides convenient method to unpack the key to complement the Key function |
|
| 184 |
+// ParseKey provides convenient method to unpack the key to complement the Key function |
|
| 185 | 185 |
func ParseKey(key string) ([]string, error) {
|
| 186 | 186 |
chain := strings.Split(strings.Trim(key, "/"), "/") |
| 187 | 187 |
|
| ... | ... |
@@ -22,7 +22,7 @@ const ( |
| 22 | 22 |
ipvboth |
| 23 | 23 |
) |
| 24 | 24 |
|
| 25 |
-//Gets the IP version in use ( [ipv4], [ipv6] or [ipv4 and ipv6] ) |
|
| 25 |
+// getIPVersion gets the IP version in use ( [ipv4], [ipv6] or [ipv4 and ipv6] ) |
|
| 26 | 26 |
func getIPVersion(config *networkConfiguration) ipVersion {
|
| 27 | 27 |
ipVersion := ipv4 |
| 28 | 28 |
if config.AddressIPv6 != nil || config.EnableIPv6 {
|
| ... | ... |
@@ -51,7 +51,7 @@ func setupBridgeNetFiltering(config *networkConfiguration, i *bridgeInterface) e |
| 51 | 51 |
return nil |
| 52 | 52 |
} |
| 53 | 53 |
|
| 54 |
-//Enable bridge net filtering if ip forwarding is enabled. See github issue #11404 |
|
| 54 |
+// Enable bridge net filtering if ip forwarding is enabled. See github issue #11404 |
|
| 55 | 55 |
func checkBridgeNetFiltering(config *networkConfiguration, i *bridgeInterface) error {
|
| 56 | 56 |
ipVer := getIPVersion(config) |
| 57 | 57 |
iface := config.BridgeName |
| ... | ... |
@@ -121,7 +121,7 @@ func getBridgeNFKernelParam(ipVer ipVersion) string {
|
| 121 | 121 |
} |
| 122 | 122 |
} |
| 123 | 123 |
|
| 124 |
-//Gets the value of the kernel parameters located at the given path |
|
| 124 |
+// Gets the value of the kernel parameters located at the given path |
|
| 125 | 125 |
func getKernelBoolParam(path string) (bool, error) {
|
| 126 | 126 |
enabled := false |
| 127 | 127 |
line, err := os.ReadFile(path) |
| ... | ... |
@@ -134,7 +134,7 @@ func getKernelBoolParam(path string) (bool, error) {
|
| 134 | 134 |
return enabled, err |
| 135 | 135 |
} |
| 136 | 136 |
|
| 137 |
-//Sets the value of the kernel parameter located at the given path |
|
| 137 |
+// Sets the value of the kernel parameter located at the given path |
|
| 138 | 138 |
func setKernelBoolParam(path string, on bool) error {
|
| 139 | 139 |
value := byte('0')
|
| 140 | 140 |
if on {
|
| ... | ... |
@@ -143,7 +143,7 @@ func setKernelBoolParam(path string, on bool) error {
|
| 143 | 143 |
return os.WriteFile(path, []byte{value, '\n'}, 0644)
|
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 |
-//Checks to see if packet forwarding is enabled |
|
| 146 |
+// Checks to see if packet forwarding is enabled |
|
| 147 | 147 |
func isPacketForwardingEnabled(ipVer ipVersion, iface string) (bool, error) {
|
| 148 | 148 |
switch ipVer {
|
| 149 | 149 |
case ipv4, ipv6: |
| ... | ... |
@@ -34,14 +34,14 @@ func (capRes GetCapabilityResponse) ToCapability() *ipamapi.Capability {
|
| 34 | 34 |
} |
| 35 | 35 |
} |
| 36 | 36 |
|
| 37 |
-// GetAddressSpacesResponse is the response to the ``get default address spaces`` request message |
|
| 37 |
+// GetAddressSpacesResponse is the response to the “get default address spaces“ request message |
|
| 38 | 38 |
type GetAddressSpacesResponse struct {
|
| 39 | 39 |
Response |
| 40 | 40 |
LocalDefaultAddressSpace string |
| 41 | 41 |
GlobalDefaultAddressSpace string |
| 42 | 42 |
} |
| 43 | 43 |
|
| 44 |
-// RequestPoolRequest represents the expected data in a ``request address pool`` request message |
|
| 44 |
+// RequestPoolRequest represents the expected data in a “request address pool“ request message |
|
| 45 | 45 |
type RequestPoolRequest struct {
|
| 46 | 46 |
AddressSpace string |
| 47 | 47 |
Pool string |
| ... | ... |
@@ -50,7 +50,7 @@ type RequestPoolRequest struct {
|
| 50 | 50 |
V6 bool |
| 51 | 51 |
} |
| 52 | 52 |
|
| 53 |
-// RequestPoolResponse represents the response message to a ``request address pool`` request |
|
| 53 |
+// RequestPoolResponse represents the response message to a “request address pool“ request |
|
| 54 | 54 |
type RequestPoolResponse struct {
|
| 55 | 55 |
Response |
| 56 | 56 |
PoolID string |
| ... | ... |
@@ -58,37 +58,37 @@ type RequestPoolResponse struct {
|
| 58 | 58 |
Data map[string]string |
| 59 | 59 |
} |
| 60 | 60 |
|
| 61 |
-// ReleasePoolRequest represents the expected data in a ``release address pool`` request message |
|
| 61 |
+// ReleasePoolRequest represents the expected data in a “release address pool“ request message |
|
| 62 | 62 |
type ReleasePoolRequest struct {
|
| 63 | 63 |
PoolID string |
| 64 | 64 |
} |
| 65 | 65 |
|
| 66 |
-// ReleasePoolResponse represents the response message to a ``release address pool`` request |
|
| 66 |
+// ReleasePoolResponse represents the response message to a “release address pool“ request |
|
| 67 | 67 |
type ReleasePoolResponse struct {
|
| 68 | 68 |
Response |
| 69 | 69 |
} |
| 70 | 70 |
|
| 71 |
-// RequestAddressRequest represents the expected data in a ``request address`` request message |
|
| 71 |
+// RequestAddressRequest represents the expected data in a “request address“ request message |
|
| 72 | 72 |
type RequestAddressRequest struct {
|
| 73 | 73 |
PoolID string |
| 74 | 74 |
Address string |
| 75 | 75 |
Options map[string]string |
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 |
-// RequestAddressResponse represents the expected data in the response message to a ``request address`` request |
|
| 78 |
+// RequestAddressResponse represents the expected data in the response message to a “request address“ request |
|
| 79 | 79 |
type RequestAddressResponse struct {
|
| 80 | 80 |
Response |
| 81 | 81 |
Address string // in CIDR format |
| 82 | 82 |
Data map[string]string |
| 83 | 83 |
} |
| 84 | 84 |
|
| 85 |
-// ReleaseAddressRequest represents the expected data in a ``release address`` request message |
|
| 85 |
+// ReleaseAddressRequest represents the expected data in a “release address“ request message |
|
| 86 | 86 |
type ReleaseAddressRequest struct {
|
| 87 | 87 |
PoolID string |
| 88 | 88 |
Address string |
| 89 | 89 |
} |
| 90 | 90 |
|
| 91 |
-// ReleaseAddressResponse represents the response message to a ``release address`` request |
|
| 91 |
+// ReleaseAddressResponse represents the response message to a “release address“ request |
|
| 92 | 92 |
type ReleaseAddressResponse struct {
|
| 93 | 93 |
Response |
| 94 | 94 |
} |
| ... | ... |
@@ -978,13 +978,13 @@ func (n *network) Delete(options ...NetworkDeleteOption) error {
|
| 978 | 978 |
} |
| 979 | 979 |
|
| 980 | 980 |
// This function gets called in 3 ways: |
| 981 |
-// * Delete() -- (false, false) |
|
| 982 |
-// remove if endpoint count == 0 or endpoint count == 1 and |
|
| 983 |
-// there is a load balancer IP |
|
| 984 |
-// * Delete(libnetwork.NetworkDeleteOptionRemoveLB) -- (false, true) |
|
| 985 |
-// remove load balancer and network if endpoint count == 1 |
|
| 986 |
-// * controller.networkCleanup() -- (true, true) |
|
| 987 |
-// remove the network no matter what |
|
| 981 |
+// - Delete() -- (false, false) |
|
| 982 |
+// remove if endpoint count == 0 or endpoint count == 1 and |
|
| 983 |
+// there is a load balancer IP |
|
| 984 |
+// - Delete(libnetwork.NetworkDeleteOptionRemoveLB) -- (false, true) |
|
| 985 |
+// remove load balancer and network if endpoint count == 1 |
|
| 986 |
+// - controller.networkCleanup() -- (true, true) |
|
| 987 |
+// remove the network no matter what |
|
| 988 | 988 |
func (n *network) delete(force bool, rmLBEndpoint bool) error {
|
| 989 | 989 |
n.Lock() |
| 990 | 990 |
c := n.ctrlr |
| ... | ... |
@@ -483,17 +483,18 @@ func (nDB *NetworkDB) deleteNodeFromNetworks(deletedNode string) {
|
| 483 | 483 |
|
| 484 | 484 |
// deleteNodeNetworkEntries is called in 2 conditions with 2 different outcomes: |
| 485 | 485 |
// 1) when a notification is coming of a node leaving the network |
| 486 |
-// - Walk all the network entries and mark the leaving node's entries for deletion |
|
| 487 |
-// These will be garbage collected when the reap timer will expire |
|
| 486 |
+// - Walk all the network entries and mark the leaving node's entries for deletion |
|
| 487 |
+// These will be garbage collected when the reap timer will expire |
|
| 488 |
+// |
|
| 488 | 489 |
// 2) when the local node is leaving the network |
| 489 |
-// - Walk all the network entries: |
|
| 490 |
-// A) if the entry is owned by the local node |
|
| 491 |
-// then we will mark it for deletion. This will ensure that if a node did not |
|
| 492 |
-// yet received the notification that the local node is leaving, will be aware |
|
| 493 |
-// of the entries to be deleted. |
|
| 494 |
-// B) if the entry is owned by a remote node, then we can safely delete it. This |
|
| 495 |
-// ensures that if we join back this network as we receive the CREATE event for |
|
| 496 |
-// entries owned by remote nodes, we will accept them and we notify the application |
|
| 490 |
+// - Walk all the network entries: |
|
| 491 |
+// A) if the entry is owned by the local node |
|
| 492 |
+// then we will mark it for deletion. This will ensure that if a node did not |
|
| 493 |
+// yet received the notification that the local node is leaving, will be aware |
|
| 494 |
+// of the entries to be deleted. |
|
| 495 |
+// B) if the entry is owned by a remote node, then we can safely delete it. This |
|
| 496 |
+// ensures that if we join back this network as we receive the CREATE event for |
|
| 497 |
+// entries owned by remote nodes, we will accept them and we notify the application |
|
| 497 | 498 |
func (nDB *NetworkDB) deleteNodeNetworkEntries(nid, node string) {
|
| 498 | 499 |
// Indicates if the delete is triggered for the local node |
| 499 | 500 |
isNodeLocal := node == nDB.config.NodeID |
| ... | ... |
@@ -149,12 +149,11 @@ func GetLastModified() *File {
|
| 149 | 149 |
} |
| 150 | 150 |
|
| 151 | 151 |
// FilterResolvDNS cleans up the config in resolvConf. It has two main jobs: |
| 152 |
-// 1. It looks for localhost (127.*|::1) entries in the provided |
|
| 153 |
-// resolv.conf, removing local nameserver entries, and, if the resulting |
|
| 154 |
-// cleaned config has no defined nameservers left, adds default DNS entries |
|
| 155 |
-// 2. Given the caller provides the enable/disable state of IPv6, the filter |
|
| 156 |
-// code will remove all IPv6 nameservers if it is not enabled for containers |
|
| 157 |
-// |
|
| 152 |
+// 1. It looks for localhost (127.*|::1) entries in the provided |
|
| 153 |
+// resolv.conf, removing local nameserver entries, and, if the resulting |
|
| 154 |
+// cleaned config has no defined nameservers left, adds default DNS entries |
|
| 155 |
+// 2. Given the caller provides the enable/disable state of IPv6, the filter |
|
| 156 |
+// code will remove all IPv6 nameservers if it is not enabled for containers |
|
| 158 | 157 |
func FilterResolvDNS(resolvConf []byte, ipv6Enabled bool) (*File, error) {
|
| 159 | 158 |
cleanedResolvConf := localhostNSRegexp.ReplaceAll(resolvConf, []byte{})
|
| 160 | 159 |
// if IPv6 is not enabled, also clean out any IPv6 address nameserver |
| ... | ... |
@@ -16,8 +16,7 @@ import ( |
| 16 | 16 |
// |
| 17 | 17 |
// Example usage: |
| 18 | 18 |
// |
| 19 |
-// defer SetupTestOSContext(t)() |
|
| 20 |
-// |
|
| 19 |
+// defer SetupTestOSContext(t)() |
|
| 21 | 20 |
func SetupTestOSContext(t *testing.T) func() {
|
| 22 | 21 |
runtime.LockOSThread() |
| 23 | 22 |
if err := syscall.Unshare(syscall.CLONE_NEWNET); err != nil {
|
| ... | ... |
@@ -8,13 +8,14 @@ import ( |
| 8 | 8 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 |
-// TODO verify if this regex is correct for "a" (all); the docs (https://github.com/torvalds/linux/blob/v5.10/Documentation/admin-guide/cgroup-v1/devices.rst) describe: |
|
| 12 |
-// "'all' means it applies to all types and all major and minor numbers", and shows an example |
|
| 13 |
-// that *only* passes `a` as value: `echo a > /sys/fs/cgroup/1/devices.allow, which would be |
|
| 14 |
-// the "implicit" equivalent of "a *:* rwm". Source-code also looks to confirm this, and returns |
|
| 15 |
-// early for "a" (all); https://github.com/torvalds/linux/blob/v5.10/security/device_cgroup.c#L614-L642 |
|
| 16 |
-//nolint: gosimple |
|
| 17 |
-var deviceCgroupRuleRegex = regexp.MustCompile("^([acb]) ([0-9]+|\\*):([0-9]+|\\*) ([rwm]{1,3})$")
|
|
| 11 |
+// TODO verify if this regex is correct for "a" (all); |
|
| 12 |
+// |
|
| 13 |
+// The docs (https://github.com/torvalds/linux/blob/v5.10/Documentation/admin-guide/cgroup-v1/devices.rst) describe: |
|
| 14 |
+// "'all' means it applies to all types and all major and minor numbers", and shows an example |
|
| 15 |
+// that *only* passes `a` as value: `echo a > /sys/fs/cgroup/1/devices.allow, which would be |
|
| 16 |
+// the "implicit" equivalent of "a *:* rwm". Source-code also looks to confirm this, and returns |
|
| 17 |
+// early for "a" (all); https://github.com/torvalds/linux/blob/v5.10/security/device_cgroup.c#L614-L642 |
|
| 18 |
+var deviceCgroupRuleRegex = regexp.MustCompile("^([acb]) ([0-9]+|\\*):([0-9]+|\\*) ([rwm]{1,3})$") //nolint: gosimple
|
|
| 18 | 19 |
|
| 19 | 20 |
// SetCapabilities sets the provided capabilities on the spec |
| 20 | 21 |
// All capabilities are added if privileged is true. |
| ... | ... |
@@ -730,7 +730,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L |
| 730 | 730 |
} |
| 731 | 731 |
|
| 732 | 732 |
case tar.TypeLink: |
| 733 |
- //#nosec G305 -- The target path is checked for path traversal. |
|
| 733 |
+ // #nosec G305 -- The target path is checked for path traversal. |
|
| 734 | 734 |
targetPath := filepath.Join(extractDir, hdr.Linkname) |
| 735 | 735 |
// check for hardlink breakout |
| 736 | 736 |
if !strings.HasPrefix(targetPath, extractDir) {
|
| ... | ... |
@@ -743,7 +743,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L |
| 743 | 743 |
case tar.TypeSymlink: |
| 744 | 744 |
// path -> hdr.Linkname = targetPath |
| 745 | 745 |
// e.g. /extractDir/path/to/symlink -> ../2/file = /extractDir/path/2/file |
| 746 |
- targetPath := filepath.Join(filepath.Dir(path), hdr.Linkname) //#nosec G305 -- The target path is checked for path traversal. |
|
| 746 |
+ targetPath := filepath.Join(filepath.Dir(path), hdr.Linkname) // #nosec G305 -- The target path is checked for path traversal. |
|
| 747 | 747 |
|
| 748 | 748 |
// the reason we don't need to check symlinks in the path (with FollowSymlinkInScope) is because |
| 749 | 749 |
// that symlink would first have to be created, which would be caught earlier, at this very check: |
| ... | ... |
@@ -1099,7 +1099,7 @@ loop: |
| 1099 | 1099 |
} |
| 1100 | 1100 |
} |
| 1101 | 1101 |
|
| 1102 |
- //#nosec G305 -- The joined path is checked for path traversal. |
|
| 1102 |
+ // #nosec G305 -- The joined path is checked for path traversal. |
|
| 1103 | 1103 |
path := filepath.Join(dest, hdr.Name) |
| 1104 | 1104 |
rel, err := filepath.Rel(dest, path) |
| 1105 | 1105 |
if err != nil {
|
| ... | ... |
@@ -1164,7 +1164,7 @@ loop: |
| 1164 | 1164 |
} |
| 1165 | 1165 |
|
| 1166 | 1166 |
for _, hdr := range dirs {
|
| 1167 |
- //#nosec G305 -- The header was checked for path traversal before it was appended to the dirs slice. |
|
| 1167 |
+ // #nosec G305 -- The header was checked for path traversal before it was appended to the dirs slice. |
|
| 1168 | 1168 |
path := filepath.Join(dest, hdr.Name) |
| 1169 | 1169 |
|
| 1170 | 1170 |
if err := system.Chtimes(path, hdr.AccessTime, hdr.ModTime); err != nil {
|
| ... | ... |
@@ -1177,7 +1177,8 @@ loop: |
| 1177 | 1177 |
// Untar reads a stream of bytes from `archive`, parses it as a tar archive, |
| 1178 | 1178 |
// and unpacks it into the directory at `dest`. |
| 1179 | 1179 |
// The archive may be compressed with one of the following algorithms: |
| 1180 |
-// identity (uncompressed), gzip, bzip2, xz. |
|
| 1180 |
+// identity (uncompressed), gzip, bzip2, xz. |
|
| 1181 |
+// |
|
| 1181 | 1182 |
// FIXME: specify behavior when target path exists vs. doesn't exist. |
| 1182 | 1183 |
func Untar(tarArchive io.Reader, dest string, options *TarOptions) error {
|
| 1183 | 1184 |
return untarHandler(tarArchive, dest, options, true) |
| ... | ... |
@@ -15,13 +15,14 @@ import ( |
| 15 | 15 |
|
| 16 | 16 |
// setupOverlayTestDir creates files in a directory with overlay whiteouts |
| 17 | 17 |
// Tree layout |
| 18 |
-// . |
|
| 19 |
-// ├── d1 # opaque, 0700 |
|
| 20 |
-// │  └── f1 # empty file, 0600 |
|
| 21 |
-// ├── d2 # opaque, 0750 |
|
| 22 |
-// │  └── f1 # empty file, 0660 |
|
| 23 |
-// └── d3 # 0700 |
|
| 24 |
-// └── f1 # whiteout, 0644 |
|
| 18 |
+// |
|
| 19 |
+// . |
|
| 20 |
+// ├── d1 # opaque, 0700 |
|
| 21 |
+// │ └── f1 # empty file, 0600 |
|
| 22 |
+// ├── d2 # opaque, 0750 |
|
| 23 |
+// │ └── f1 # empty file, 0660 |
|
| 24 |
+// └── d3 # 0700 |
|
| 25 |
+// └── f1 # whiteout, 0644 |
|
| 25 | 26 |
func setupOverlayTestDir(t *testing.T, src string) {
|
| 26 | 27 |
skip.If(t, os.Getuid() != 0, "skipping test that requires root") |
| 27 | 28 |
skip.If(t, userns.RunningInUserNS(), "skipping test that requires initial userns (trusted.overlay.opaque xattr cannot be set in userns, even with Ubuntu kernel)") |
| ... | ... |
@@ -297,9 +297,10 @@ func TestCopyLongDstFilename(t *testing.T) {
|
| 297 | 297 |
// J | yes | yes | yes | yes | - | copy dir contents |
| 298 | 298 |
// |
| 299 | 299 |
|
| 300 |
-// A. SRC specifies a file and DST (no trailing path separator) doesn't |
|
| 301 |
-// exist. This should create a file with the name DST and copy the |
|
| 302 |
-// contents of the source file into it. |
|
| 300 |
+// A. SRC specifies a file and DST (no trailing path separator) doesn't exist. |
|
| 301 |
+// |
|
| 302 |
+// This should create a file with the name DST and copy the contents of the source |
|
| 303 |
+// file into it. |
|
| 303 | 304 |
func TestCopyCaseA(t *testing.T) {
|
| 304 | 305 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 305 | 306 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -339,9 +340,10 @@ func TestCopyCaseA(t *testing.T) {
|
| 339 | 339 |
assert.NilError(t, err) |
| 340 | 340 |
} |
| 341 | 341 |
|
| 342 |
-// B. SRC specifies a file and DST (with trailing path separator) doesn't |
|
| 343 |
-// exist. This should cause an error because the copy operation cannot |
|
| 344 |
-// create a directory when copying a single file. |
|
| 342 |
+// B. SRC specifies a file and DST (with trailing path separator) doesn't exist. |
|
| 343 |
+// |
|
| 344 |
+// This should cause an error because the copy operation cannot create a directory |
|
| 345 |
+// when copying a single file. |
|
| 345 | 346 |
func TestCopyCaseB(t *testing.T) {
|
| 346 | 347 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 347 | 348 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -373,8 +375,9 @@ func TestCopyCaseB(t *testing.T) {
|
| 373 | 373 |
|
| 374 | 374 |
} |
| 375 | 375 |
|
| 376 |
-// C. SRC specifies a file and DST exists as a file. This should overwrite |
|
| 377 |
-// the file at DST with the contents of the source file. |
|
| 376 |
+// C. SRC specifies a file and DST exists as a file. |
|
| 377 |
+// |
|
| 378 |
+// This should overwrite the file at DST with the contents of the source file. |
|
| 378 | 379 |
func TestCopyCaseC(t *testing.T) {
|
| 379 | 380 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 380 | 381 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -401,9 +404,9 @@ func TestCopyCaseC(t *testing.T) {
|
| 401 | 401 |
assert.NilError(t, err) |
| 402 | 402 |
} |
| 403 | 403 |
|
| 404 |
-// C. Symbol link following version: |
|
| 405 |
-// SRC specifies a file and DST exists as a file. This should overwrite |
|
| 406 |
-// the file at DST with the contents of the source file. |
|
| 404 |
+// C. Symbol link following version: SRC specifies a file and DST exists as a file. |
|
| 405 |
+// |
|
| 406 |
+// This should overwrite the file at DST with the contents of the source file. |
|
| 407 | 407 |
func TestCopyCaseCFSym(t *testing.T) {
|
| 408 | 408 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 409 | 409 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -438,9 +441,10 @@ func TestCopyCaseCFSym(t *testing.T) {
|
| 438 | 438 |
assert.NilError(t, err) |
| 439 | 439 |
} |
| 440 | 440 |
|
| 441 |
-// D. SRC specifies a file and DST exists as a directory. This should place |
|
| 442 |
-// a copy of the source file inside it using the basename from SRC. Ensure |
|
| 443 |
-// this works whether DST has a trailing path separator or not. |
|
| 441 |
+// D. SRC specifies a file and DST exists as a directory. |
|
| 442 |
+// |
|
| 443 |
+// This should place a copy of the source file inside it using the basename from |
|
| 444 |
+// SRC. Ensure this works whether DST has a trailing path separator or not. |
|
| 444 | 445 |
func TestCopyCaseD(t *testing.T) {
|
| 445 | 446 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 446 | 447 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -487,10 +491,10 @@ func TestCopyCaseD(t *testing.T) {
|
| 487 | 487 |
assert.NilError(t, err) |
| 488 | 488 |
} |
| 489 | 489 |
|
| 490 |
-// D. Symbol link following version: |
|
| 491 |
-// SRC specifies a file and DST exists as a directory. This should place |
|
| 492 |
-// a copy of the source file inside it using the basename from SRC. Ensure |
|
| 493 |
-// this works whether DST has a trailing path separator or not. |
|
| 490 |
+// D. Symbol link following version: SRC specifies a file and DST exists as a directory. |
|
| 491 |
+// |
|
| 492 |
+// This should place a copy of the source file inside it using the basename from |
|
| 493 |
+// SRC. Ensure this works whether DST has a trailing path separator or not. |
|
| 494 | 494 |
func TestCopyCaseDFSym(t *testing.T) {
|
| 495 | 495 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 496 | 496 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -538,10 +542,11 @@ func TestCopyCaseDFSym(t *testing.T) {
|
| 538 | 538 |
assert.NilError(t, err) |
| 539 | 539 |
} |
| 540 | 540 |
|
| 541 |
-// E. SRC specifies a directory and DST does not exist. This should create a |
|
| 542 |
-// directory at DST and copy the contents of the SRC directory into the DST |
|
| 543 |
-// directory. Ensure this works whether DST has a trailing path separator or |
|
| 544 |
-// not. |
|
| 541 |
+// E. SRC specifies a directory and DST does not exist. |
|
| 542 |
+// |
|
| 543 |
+// This should create a directory at DST and copy the contents of the SRC directory |
|
| 544 |
+// into the DST directory. Ensure this works whether DST has a trailing path |
|
| 545 |
+// separator or not. |
|
| 545 | 546 |
func TestCopyCaseE(t *testing.T) {
|
| 546 | 547 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 547 | 548 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -581,11 +586,11 @@ func TestCopyCaseE(t *testing.T) {
|
| 581 | 581 |
assert.NilError(t, err) |
| 582 | 582 |
} |
| 583 | 583 |
|
| 584 |
-// E. Symbol link following version: |
|
| 585 |
-// SRC specifies a directory and DST does not exist. This should create a |
|
| 586 |
-// directory at DST and copy the contents of the SRC directory into the DST |
|
| 587 |
-// directory. Ensure this works whether DST has a trailing path separator or |
|
| 588 |
-// not. |
|
| 584 |
+// E. Symbol link following version: SRC specifies a directory and DST does not exist. |
|
| 585 |
+// |
|
| 586 |
+// This should create a directory at DST and copy the contents of the SRC directory |
|
| 587 |
+// into the DST directory. Ensure this works whether DST has a trailing path |
|
| 588 |
+// separator or not. |
|
| 589 | 589 |
func TestCopyCaseEFSym(t *testing.T) {
|
| 590 | 590 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 591 | 591 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -626,8 +631,10 @@ func TestCopyCaseEFSym(t *testing.T) {
|
| 626 | 626 |
assert.NilError(t, err) |
| 627 | 627 |
} |
| 628 | 628 |
|
| 629 |
-// F. SRC specifies a directory and DST exists as a file. This should cause an |
|
| 630 |
-// error as it is not possible to overwrite a file with a directory. |
|
| 629 |
+// F. SRC specifies a directory and DST exists as a file. |
|
| 630 |
+// |
|
| 631 |
+// This should cause an error as it is not possible to overwrite a file with a |
|
| 632 |
+// directory. |
|
| 631 | 633 |
func TestCopyCaseF(t *testing.T) {
|
| 632 | 634 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 633 | 635 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -660,9 +667,10 @@ func TestCopyCaseF(t *testing.T) {
|
| 660 | 660 |
} |
| 661 | 661 |
} |
| 662 | 662 |
|
| 663 |
-// G. SRC specifies a directory and DST exists as a directory. This should copy |
|
| 664 |
-// the SRC directory and all its contents to the DST directory. Ensure this |
|
| 665 |
-// works whether DST has a trailing path separator or not. |
|
| 663 |
+// G. SRC specifies a directory and DST exists as a directory. |
|
| 664 |
+// |
|
| 665 |
+// This should copy the SRC directory and all its contents to the DST directory. |
|
| 666 |
+// Ensure this works whether DST has a trailing path separator or not. |
|
| 666 | 667 |
func TestCopyCaseG(t *testing.T) {
|
| 667 | 668 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 668 | 669 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -704,10 +712,10 @@ func TestCopyCaseG(t *testing.T) {
|
| 704 | 704 |
assert.NilError(t, err) |
| 705 | 705 |
} |
| 706 | 706 |
|
| 707 |
-// G. Symbol link version: |
|
| 708 |
-// SRC specifies a directory and DST exists as a directory. This should copy |
|
| 709 |
-// the SRC directory and all its contents to the DST directory. Ensure this |
|
| 710 |
-// works whether DST has a trailing path separator or not. |
|
| 707 |
+// G. Symbol link version: SRC specifies a directory and DST exists as a directory. |
|
| 708 |
+// |
|
| 709 |
+// This should copy the SRC directory and all its contents to the DST directory. |
|
| 710 |
+// Ensure this works whether DST has a trailing path separator or not. |
|
| 711 | 711 |
func TestCopyCaseGFSym(t *testing.T) {
|
| 712 | 712 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 713 | 713 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -750,10 +758,11 @@ func TestCopyCaseGFSym(t *testing.T) {
|
| 750 | 750 |
assert.NilError(t, err) |
| 751 | 751 |
} |
| 752 | 752 |
|
| 753 |
-// H. SRC specifies a directory's contents only and DST does not exist. This |
|
| 754 |
-// should create a directory at DST and copy the contents of the SRC |
|
| 755 |
-// directory (but not the directory itself) into the DST directory. Ensure |
|
| 756 |
-// this works whether DST has a trailing path separator or not. |
|
| 753 |
+// H. SRC specifies a directory's contents only and DST does not exist. |
|
| 754 |
+// |
|
| 755 |
+// This should create a directory at DST and copy the contents of the SRC |
|
| 756 |
+// directory (but not the directory itself) into the DST directory. Ensure |
|
| 757 |
+// this works whether DST has a trailing path separator or not. |
|
| 757 | 758 |
func TestCopyCaseH(t *testing.T) {
|
| 758 | 759 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 759 | 760 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -797,11 +806,11 @@ func TestCopyCaseH(t *testing.T) {
|
| 797 | 797 |
} |
| 798 | 798 |
} |
| 799 | 799 |
|
| 800 |
-// H. Symbol link following version: |
|
| 801 |
-// SRC specifies a directory's contents only and DST does not exist. This |
|
| 802 |
-// should create a directory at DST and copy the contents of the SRC |
|
| 803 |
-// directory (but not the directory itself) into the DST directory. Ensure |
|
| 804 |
-// this works whether DST has a trailing path separator or not. |
|
| 800 |
+// H. Symbol link following version: SRC specifies a directory's contents only and DST does not exist. |
|
| 801 |
+// |
|
| 802 |
+// This should create a directory at DST and copy the contents of the SRC |
|
| 803 |
+// directory (but not the directory itself) into the DST directory. Ensure |
|
| 804 |
+// this works whether DST has a trailing path separator or not. |
|
| 805 | 805 |
func TestCopyCaseHFSym(t *testing.T) {
|
| 806 | 806 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 807 | 807 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -846,9 +855,10 @@ func TestCopyCaseHFSym(t *testing.T) {
|
| 846 | 846 |
} |
| 847 | 847 |
} |
| 848 | 848 |
|
| 849 |
-// I. SRC specifies a directory's contents only and DST exists as a file. This |
|
| 850 |
-// should cause an error as it is not possible to overwrite a file with a |
|
| 851 |
-// directory. |
|
| 849 |
+// I. SRC specifies a directory's contents only and DST exists as a file. |
|
| 850 |
+// |
|
| 851 |
+// This should cause an error as it is not possible to overwrite a file with a |
|
| 852 |
+// directory. |
|
| 852 | 853 |
func TestCopyCaseI(t *testing.T) {
|
| 853 | 854 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 854 | 855 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -882,9 +892,10 @@ func TestCopyCaseI(t *testing.T) {
|
| 882 | 882 |
} |
| 883 | 883 |
|
| 884 | 884 |
// J. SRC specifies a directory's contents only and DST exists as a directory. |
| 885 |
-// This should copy the contents of the SRC directory (but not the directory |
|
| 886 |
-// itself) into the DST directory. Ensure this works whether DST has a |
|
| 887 |
-// trailing path separator or not. |
|
| 885 |
+// |
|
| 886 |
+// This should copy the contents of the SRC directory (but not the directory |
|
| 887 |
+// itself) into the DST directory. Ensure this works whether DST has a |
|
| 888 |
+// trailing path separator or not. |
|
| 888 | 889 |
func TestCopyCaseJ(t *testing.T) {
|
| 889 | 890 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 890 | 891 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -930,11 +941,11 @@ func TestCopyCaseJ(t *testing.T) {
|
| 930 | 930 |
assert.NilError(t, err) |
| 931 | 931 |
} |
| 932 | 932 |
|
| 933 |
-// J. Symbol link following version: |
|
| 934 |
-// SRC specifies a directory's contents only and DST exists as a directory. |
|
| 935 |
-// This should copy the contents of the SRC directory (but not the directory |
|
| 936 |
-// itself) into the DST directory. Ensure this works whether DST has a |
|
| 937 |
-// trailing path separator or not. |
|
| 933 |
+// J. Symbol link following version: SRC specifies a directory's contents only and DST exists as a directory. |
|
| 934 |
+// |
|
| 935 |
+// This should copy the contents of the SRC directory (but not the directory |
|
| 936 |
+// itself) into the DST directory. Ensure this works whether DST has a |
|
| 937 |
+// trailing path separator or not. |
|
| 938 | 938 |
func TestCopyCaseJFSym(t *testing.T) {
|
| 939 | 939 |
tmpDirA, tmpDirB := getTestTempDirs(t) |
| 940 | 940 |
defer removeAllPaths(tmpDirA, tmpDirB) |
| ... | ... |
@@ -17,8 +17,8 @@ import ( |
| 17 | 17 |
// Generate("foo.txt", "hello world", "emptyfile")
|
| 18 | 18 |
// |
| 19 | 19 |
// The above call will return an archive with 2 files: |
| 20 |
-// * ./foo.txt with content "hello world" |
|
| 21 |
-// * ./empty with empty content |
|
| 20 |
+// - ./foo.txt with content "hello world" |
|
| 21 |
+// - ./empty with empty content |
|
| 22 | 22 |
// |
| 23 | 23 |
// FIXME: stream content instead of buffering |
| 24 | 24 |
// FIXME: specify permissions and other archive metadata |
| ... | ... |
@@ -30,7 +30,7 @@ func NewArchiver(idMapping idtools.IdentityMapping) *archive.Archiver {
|
| 30 | 30 |
// Untar reads a stream of bytes from `archive`, parses it as a tar archive, |
| 31 | 31 |
// and unpacks it into the directory at `dest`. |
| 32 | 32 |
// The archive may be compressed with one of the following algorithms: |
| 33 |
-// identity (uncompressed), gzip, bzip2, xz. |
|
| 33 |
+// identity (uncompressed), gzip, bzip2, xz. |
|
| 34 | 34 |
func Untar(tarArchive io.Reader, dest string, options *archive.TarOptions) error {
|
| 35 | 35 |
return untarHandler(tarArchive, dest, options, true, dest) |
| 36 | 36 |
} |
| ... | ... |
@@ -39,6 +39,7 @@ func LogInit(logger DevmapperLogger) {
|
| 39 | 39 |
// because we are using callbacks, this function will be called for *every* log |
| 40 | 40 |
// in libdm (even debug ones because there's no way of setting the verbosity |
| 41 | 41 |
// level for an external logging callback). |
| 42 |
+// |
|
| 42 | 43 |
//export DevmapperLogCallback |
| 43 | 44 |
func DevmapperLogCallback(level C.int, file *C.char, line, dmErrnoOrClass C.int, message *C.char) {
|
| 44 | 45 |
msg := C.GoString(message) |
| ... | ... |
@@ -25,13 +25,14 @@ func ParseKeyValueOpt(opt string) (string, string, error) {
|
| 25 | 25 |
// set to `true`. Values larger than `maximum` cause an error if max is non zero, |
| 26 | 26 |
// in order to stop the map becoming excessively large. |
| 27 | 27 |
// Supported formats: |
| 28 |
-// 7 |
|
| 29 |
-// 1-6 |
|
| 30 |
-// 0,3-4,7,8-10 |
|
| 31 |
-// 0-0,0,1-7 |
|
| 32 |
-// 03,1-3 <- this is gonna get parsed as [1,2,3] |
|
| 33 |
-// 3,2,1 |
|
| 34 |
-// 0-2,3,1 |
|
| 28 |
+// |
|
| 29 |
+// 7 |
|
| 30 |
+// 1-6 |
|
| 31 |
+// 0,3-4,7,8-10 |
|
| 32 |
+// 0-0,0,1-7 |
|
| 33 |
+// 03,1-3 <- this is gonna get parsed as [1,2,3] |
|
| 34 |
+// 3,2,1 |
|
| 35 |
+// 0-2,3,1 |
|
| 35 | 36 |
func ParseUintListMaximum(val string, maximum int) (map[int]bool, error) {
|
| 36 | 37 |
return parseUintList(val, maximum) |
| 37 | 38 |
} |
| ... | ... |
@@ -42,13 +43,14 @@ func ParseUintListMaximum(val string, maximum int) (map[int]bool, error) {
|
| 42 | 42 |
// input string. It returns a `map[int]bool` with available elements from `val` |
| 43 | 43 |
// set to `true`. |
| 44 | 44 |
// Supported formats: |
| 45 |
-// 7 |
|
| 46 |
-// 1-6 |
|
| 47 |
-// 0,3-4,7,8-10 |
|
| 48 |
-// 0-0,0,1-7 |
|
| 49 |
-// 03,1-3 <- this is gonna get parsed as [1,2,3] |
|
| 50 |
-// 3,2,1 |
|
| 51 |
-// 0-2,3,1 |
|
| 45 |
+// |
|
| 46 |
+// 7 |
|
| 47 |
+// 1-6 |
|
| 48 |
+// 0,3-4,7,8-10 |
|
| 49 |
+// 0-0,0,1-7 |
|
| 50 |
+// 03,1-3 <- this is gonna get parsed as [1,2,3] |
|
| 51 |
+// 3,2,1 |
|
| 52 |
+// 0-2,3,1 |
|
| 52 | 53 |
func ParseUintList(val string) (map[int]bool, error) {
|
| 53 | 54 |
return parseUintList(val, 0) |
| 54 | 55 |
} |
| ... | ... |
@@ -13,7 +13,7 @@ |
| 13 | 13 |
// A handshake is send at /Plugin.Activate, and plugins are expected to return |
| 14 | 14 |
// a Manifest with a list of Docker subsystems which this plugin implements. |
| 15 | 15 |
// |
| 16 |
-// In order to use a plugins, you can use the ``Get`` with the name of the |
|
| 16 |
+// In order to use a plugins, you can use the `Get` with the name of the |
|
| 17 | 17 |
// plugin and the subsystem it implements. |
| 18 | 18 |
// |
| 19 | 19 |
// plugin, err := plugins.Get("example", "VolumeDriver")
|
| ... | ... |
@@ -14,16 +14,14 @@ import ( |
| 14 | 14 |
"github.com/sirupsen/logrus" |
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 |
-/* allowV1PluginsFallback determines daemon's support for V1 plugins. |
|
| 18 |
- * When the time comes to remove support for V1 plugins, flipping |
|
| 19 |
- * this bool is all that will be needed. |
|
| 20 |
- */ |
|
| 17 |
+// allowV1PluginsFallback determines daemon's support for V1 plugins. |
|
| 18 |
+// When the time comes to remove support for V1 plugins, flipping |
|
| 19 |
+// this bool is all that will be needed. |
|
| 21 | 20 |
const allowV1PluginsFallback = true |
| 22 | 21 |
|
| 23 |
-/* defaultAPIVersion is the version of the plugin API for volume, network, |
|
| 24 |
- IPAM and authz. This is a very stable API. When we update this API, then |
|
| 25 |
- pluginType should include a version. e.g. "networkdriver/2.0". |
|
| 26 |
-*/ |
|
| 22 |
+// defaultAPIVersion is the version of the plugin API for volume, network, |
|
| 23 |
+// IPAM and authz. This is a very stable API. When we update this API, then |
|
| 24 |
+// pluginType should include a version. e.g. "networkdriver/2.0". |
|
| 27 | 25 |
const defaultAPIVersion = "1.0" |
| 28 | 26 |
|
| 29 | 27 |
// GetV2Plugin retrieves a plugin by name, id or partial ID. |
| ... | ... |
@@ -102,9 +102,10 @@ func (state *pquotaState) updateMinProjID(minProjectID uint32) {
|
| 102 | 102 |
// This test will fail if the backing fs is not xfs. |
| 103 | 103 |
// |
| 104 | 104 |
// xfs_quota tool can be used to assign a project id to the driver home directory, e.g.: |
| 105 |
-// echo 999:/var/lib/docker/overlay2 >> /etc/projects |
|
| 106 |
-// echo docker:999 >> /etc/projid |
|
| 107 |
-// xfs_quota -x -c 'project -s docker' /<xfs mount point> |
|
| 105 |
+// |
|
| 106 |
+// echo 999:/var/lib/docker/overlay2 >> /etc/projects |
|
| 107 |
+// echo docker:999 >> /etc/projid |
|
| 108 |
+// xfs_quota -x -c 'project -s docker' /<xfs mount point> |
|
| 108 | 109 |
// |
| 109 | 110 |
// In that case, the home directory project id will be used as a "start offset" |
| 110 | 111 |
// and all containers will be assigned larger project ids (e.g. >= 1000). |
| ... | ... |
@@ -113,7 +114,6 @@ func (state *pquotaState) updateMinProjID(minProjectID uint32) {
|
| 113 | 113 |
// Then try to create a test directory with the next project id and set a quota |
| 114 | 114 |
// on it. If that works, continue to scan existing containers to map allocated |
| 115 | 115 |
// project ids. |
| 116 |
-// |
|
| 117 | 116 |
func NewControl(basePath string) (*Control, error) {
|
| 118 | 117 |
// |
| 119 | 118 |
// If we are running in a user namespace quota won't be supported for |
| ... | ... |
@@ -21,13 +21,13 @@ const extName = "VolumeDriver" |
| 21 | 21 |
// volumeDriver defines the available functions that volume plugins must implement. |
| 22 | 22 |
// This interface is only defined to generate the proxy objects. |
| 23 | 23 |
// It's not intended to be public or reused. |
| 24 |
-//nolint: deadcode |
|
| 24 |
+// nolint: deadcode,unused,varcheck |
|
| 25 | 25 |
type volumeDriver interface {
|
| 26 | 26 |
// Create a volume with the given name |
| 27 | 27 |
Create(name string, opts map[string]string) (err error) |
| 28 | 28 |
// Remove the volume with the given name |
| 29 | 29 |
Remove(name string) (err error) |
| 30 |
- // Get the mountpoint of the given volume |
|
| 30 |
+ // Path returns the mountpoint of the given volume. |
|
| 31 | 31 |
Path(name string) (mountpoint string, err error) |
| 32 | 32 |
// Mount the given volume and return the mountpoint |
| 33 | 33 |
Mount(name, id string) (mountpoint string, err error) |
| ... | ... |
@@ -22,9 +22,9 @@ func NewLCOWParser() Parser {
|
| 22 | 22 |
// rxLCOWDestination is the regex expression for the mount destination for LCOW |
| 23 | 23 |
// |
| 24 | 24 |
// Destination (aka container path): |
| 25 |
-// - Variation on hostdir but can be a drive followed by colon as well |
|
| 26 |
-// - If a path, must be absolute. Can include spaces |
|
| 27 |
-// - Drive cannot be c: (explicitly checked in code, not RegEx) |
|
| 25 |
+// - Variation on hostdir but can be a drive followed by colon as well |
|
| 26 |
+// - If a path, must be absolute. Can include spaces |
|
| 27 |
+// - Drive cannot be c: (explicitly checked in code, not RegEx) |
|
| 28 | 28 |
const rxLCOWDestination = `(?P<destination>/(?:[^\\/:*?"<>\r\n]+[/]?)*)` |
| 29 | 29 |
|
| 30 | 30 |
var ( |
| ... | ... |
@@ -571,7 +571,7 @@ func volumeExists(ctx context.Context, store *drivers.Store, v volume.Volume) (b |
| 571 | 571 |
// create asks the given driver to create a volume with the name/opts. |
| 572 | 572 |
// If a volume with the name is already known, it will ask the stored driver for the volume. |
| 573 | 573 |
// If the passed in driver name does not match the driver name which is stored |
| 574 |
-// for the given volume name, an error is returned after checking if the reference is stale. |
|
| 574 |
+// for the given volume name, an error is returned after checking if the reference is stale. |
|
| 575 | 575 |
// If the reference is stale, it will be purged and this create can continue. |
| 576 | 576 |
// It is expected that callers of this function hold any necessary locks. |
| 577 | 577 |
func (s *VolumeStore) create(ctx context.Context, name, driverName string, opts, labels map[string]string) (volume.Volume, bool, error) {
|
| ... | ... |
@@ -749,9 +749,9 @@ func (s *VolumeStore) getVolume(ctx context.Context, name, driverName string) (v |
| 749 | 749 |
|
| 750 | 750 |
// lookupVolume gets the specified volume from the specified driver. |
| 751 | 751 |
// This will only return errors related to communications with the driver. |
| 752 |
-// If the driver returns an error that is not communication related the |
|
| 753 |
-// error is logged but not returned. |
|
| 754 |
-// If the volume is not found it will return `nil, nil`` |
|
| 752 |
+// If the driver returns an error that is not communication related, the error |
|
| 753 |
+// is logged but not returned. |
|
| 754 |
+// If the volume is not found it will return `nil, nil` |
|
| 755 | 755 |
// TODO(@cpuguy83): plumb through the context to lower level components |
| 756 | 756 |
func lookupVolume(ctx context.Context, store *drivers.Store, driverName, volumeName string) (volume.Volume, error) {
|
| 757 | 757 |
if driverName == "" {
|