Skip to content

Commit

Permalink
Add support for user
Browse files Browse the repository at this point in the history
  • Loading branch information
kadel committed Oct 31, 2016
1 parent b068c5c commit 3abe292
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions pkg/transformer/kubernetes/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
"text/template"

Expand Down Expand Up @@ -284,12 +285,25 @@ func UpdateKubernetesObjects(name string, service kobject.ServiceConfig, objects
template.Spec.Containers[0].WorkingDir = service.WorkingDir
template.Spec.Containers[0].VolumeMounts = volumesMount
template.Spec.Volumes = volumes
// Configure the container privileged mode

securityContext := &api.SecurityContext{}
if service.Privileged == true {
template.Spec.Containers[0].SecurityContext = &api.SecurityContext{
Privileged: &service.Privileged,
securityContext.Privileged = &service.Privileged
}
if service.User != "" {
uid, err := strconv.ParseInt(service.User, 10, 64)
if err != nil {
logrus.Warn("Ignoring user directive. User to be specified as a UID (numeric).")
} else {
securityContext.RunAsUser = &uid
}

}
// update template only if securityContext is not empty
if *securityContext != (api.SecurityContext{}) {
template.Spec.Containers[0].SecurityContext = securityContext
}

template.Spec.Containers[0].Ports = ports
template.ObjectMeta.Labels = transformer.ConfigLabels(name)
// Configure the container restart policy.
Expand Down

0 comments on commit 3abe292

Please sign in to comment.