Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support setting owner user ID / group ID #19

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@ Alternatively, you can also build from source by cloning the repo and running `g

```shell
-ca-certs-file string
The path to the local CA certificates file
The path to the local CA certificates file
-ca-certs-image-url string
The URL of an image to extract the CA certificates from
The URL of an image to extract the CA certificates from
-dest-image-url string
The URL of the image to push the modified image to
The URL of the image to push the modified image to
-image-cert-path string
The path to the certificate file in the image (optional) (default "/etc/ssl/certs/ca-certificates.crt")
The path to the certificate file in the image (optional) (default "/etc/ssl/certs/ca-certificates.crt")
-image-url string
The URL of the image to append the CA certificates to
The URL of the image to append the CA certificates to
-output-certs-path string
Output the (appended) certificates file from the image to a local file (optional)
Output the (appended) certificates file from the image to a local file (optional)
-owner-group-id int
The group ID of the owner of the certificate file in the image (optional)
-owner-user-id int
The user ID of the owner of the certificate file in the image (optional)
-platform string
The platform to build for (default linux/amd64) (default "linux/amd64")
The platform to build the image for (default "linux/amd64")
-replace-certs
Replace the certificates in the certificate file instead of appending them
Replace the certificates in the certificate file instead of appending them
```

## Example
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var (
imageCertPath string
outputCerts string
replaceCerts bool
ownerUserID int
ownerGroupID int
)

func init() {
Expand All @@ -38,6 +40,8 @@ func init() {
flag.StringVar(&platformStr, "platform", "linux/amd64", "The platform to build the image for")

flag.StringVar(&imageCertPath, "image-cert-path", "/etc/ssl/certs/ca-certificates.crt", "The path to the certificate file in the image (optional)")
flag.IntVar(&ownerUserID, "owner-user-id", 0, "The user ID of the owner of the certificate file in the image (optional)")
flag.IntVar(&ownerGroupID, "owner-group-id", 0, "The group ID of the owner of the certificate file in the image (optional)")
flag.StringVar(&outputCerts, "output-certs-path", "", "Output the (appended) certificates file from the image to a local file (optional)")
flag.BoolVar(&replaceCerts, "replace-certs", false, "Replace the certificates in the certificate file instead of appending them")
}
Expand Down Expand Up @@ -186,6 +190,8 @@ func newImage(old v1.Image, caCertBytes []byte) (v1.Image, error) {
Name: imageCertPath,
Mode: 0644,
Size: int64(len(newCaCertBytes)),
Uid: ownerUserID,
Gid: ownerGroupID,
})
if _, err := newTar.Write(newCaCertBytes); err != nil {
return nil, err
Expand Down
Loading