Skip to content

Commit

Permalink
doc fix: make file permission examples octal (testcontainers#1510)
Browse files Browse the repository at this point in the history
* doc fix: make file permission examples octal

Examples of file permissions should be in octal format. But in the code examples they are not.

* use new octal notation
  • Loading branch information
martin-mfg authored Aug 21, 2023
1 parent 589f926 commit 7021689
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/features/copy_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ nginxC, err := GenericContainer(ctx, GenericContainerRequest{
Started: true,
})

nginxC.CopyFileToContainer(ctx, "./testdata/hello.sh", "/hello_copy.sh", 700)
nginxC.CopyFileToContainer(ctx, "./testdata/hello.sh", "/hello_copy.sh", 0o700)
```

Or you can add a list of files in the `ContainerRequest` initialization, which can be copied before the container starts:
Expand All @@ -31,7 +31,7 @@ nginxC, err := GenericContainer(ctx, GenericContainerRequest{
{
HostFilePath: "./testdata/hello.sh",
ContainerFilePath: "/copies-hello.sh",
FileMode: 700,
FileMode: 0o700,
},
},
},
Expand Down Expand Up @@ -60,7 +60,7 @@ nginxC, err := GenericContainer(ctx, GenericContainerRequest{
{
HostFilePath: "./testdata", // a directory
ContainerFilePath: "/tmp/testdata", // important! its parent already exists
FileMode: 700,
FileMode: 0o700,
},
},
},
Expand All @@ -73,7 +73,7 @@ if err != nil {
// as the container is started, we can create the directory first
_, _, err = nginxC.Exec(ctx, []string{"mkdir", "-p", "/usr/lib/my-software/config"})
// because the container path is a directory, it will use the copy dir method as fallback
err = nginxC.CopyFileToContainer(ctx, "./files", "/usr/lib/my-software/config/files", 700)
err = nginxC.CopyFileToContainer(ctx, "./files", "/usr/lib/my-software/config/files", 0o700)
if err != nil {
// handle error
}
Expand All @@ -94,7 +94,7 @@ nginxC, err := GenericContainer(ctx, GenericContainerRequest{
{
HostFilePath: "./testdata", // a directory
ContainerFilePath: "/tmp/testdata", // important! its parent already exists
FileMode: 700,
FileMode: 0o700,
},
},
},
Expand All @@ -106,7 +106,7 @@ if err != nil {

// as the container is started, we can create the directory first
_, _, err = nginxC.Exec(ctx, []string{"mkdir", "-p", "/usr/lib/my-software/config"})
err = nginxC.CopyDirToContainer(ctx, "./plugins", "/usr/lib/my-software/config/plugins", 700)
err = nginxC.CopyDirToContainer(ctx, "./plugins", "/usr/lib/my-software/config/plugins", 0o700)
if err != nil {
// handle error
}
Expand Down

0 comments on commit 7021689

Please sign in to comment.