Skip to content

Commit

Permalink
fixing runAsUser parameter
Browse files Browse the repository at this point in the history
Signed-off-by: wejdross <lukaszwidera1993@gmail.com>
  • Loading branch information
wejdross committed Mar 30, 2023
1 parent f053233 commit 4fa05af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 7 additions & 4 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ var (
Destination: &restore.Cfg.RunAsUser,
Required: false,
Name: "runAsUser",
Value: 0,
Value: -1,
Usage: "Optional ; Set user UID, via cli or via env: ",
EnvVars: []string{
"RUNASUSER",
Expand Down Expand Up @@ -315,9 +315,6 @@ func RunRestore(ctx *cli.Context) error {
Spec: v1.RestoreSpec{
//Snapshot: snapshot,
RunnableSpec: v1.RunnableSpec{
PodSecurityContext: &corev1.PodSecurityContext{
RunAsUser: &restore.Cfg.RunAsUser,
},
Backend: &v1.Backend{
RepoPasswordSecretRef: &corev1.SecretKeySelector{
Key: restore.Cfg.SecretRefKey,
Expand Down Expand Up @@ -345,6 +342,12 @@ func RunRestore(ctx *cli.Context) error {
},
},
}
if restore.Cfg.RunAsUser != -1 {
restoreObject.Spec.PodSecurityContext = &corev1.PodSecurityContext{
RunAsUser: &restore.Cfg.RunAsUser,
}
}

if restore.Cfg.RestoreMethod == "s3" {
restoreObject.Spec.RestoreMethod = &s3
} else {
Expand Down
7 changes: 4 additions & 3 deletions docs/modules/ROOT/pages/how-tos/restore.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ Example usages:
--s3endpoint http://minio:9000 \
--s3bucket backups \
--s3secretRef minio-credentials \
--snapshot f0dd5684 \
--snapshot 5c3fc641 \
--claimName wordpress-pvc \
--runAsUser 0
Expand All @@ -300,7 +300,7 @@ Example usages:
--s3endpoint http://minio:9000 \
--s3bucket backups \
--s3secretRef minio-credentials \
--snapshot f0dd5684 \
--snapshot 5c3fc641 \
--claimName wordpress-pvc \
--runAsUser 0 \
--restoreToS3Bucket backup2 \
Expand Down Expand Up @@ -337,4 +337,5 @@ As a result of this CLI will be created k8up object restore.k8up.io, which will
kubectl get restores.k8up.io
kubectl get jobs
kubectl logs -f jobs/resotre-job-123
```
```

0 comments on commit 4fa05af

Please sign in to comment.