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

Add support for user directive #245

Merged
merged 2 commits into from
Nov 25, 2016
Merged

Add support for user directive #245

merged 2 commits into from
Nov 25, 2016

Conversation

kadel
Copy link
Member

@kadel kadel commented Oct 27, 2016

This is little a bit user unfriendly :-(

Issue is that in docker-compose you can set user by user name or uid. But K8S allows you to set user only by its uid (has to be int).

This is why I added warning that tells user that user directive will be ignored if its not a number.
Here is user unfriendly part, in docker-compose even if you set user by it uid, it has to be string. (user: "2324") If you set it as int (user: 2324) libcompose parser will complain about this not being string.

So now Kompose requires user to be number but written as string :-(

fixes #244

if service.User != "" {
uid, err := strconv.ParseInt(service.User, 10, 64)
if err != nil {
logrus.Warn("Ignoring User directive. User has to specfied as uid (numeric).")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a little spelling error :)

Ignoring user directive. User to be specified as a UID (numeric).

securityContext.Privileged = &service.Privileged
}
if service.User != "" {
uid, err := strconv.ParseInt(service.User, 10, 64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these numbers? 10 and 64?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 is base of the number. (maybe i can change it to 0 that should do autodetection)
and 64 means that number has to fit into int64 (it will throw error if it is bigger than in64 :-) ) - runAsUser in Kubernetes SecurityContext is int64

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhhh, makes sense xD

@cdrage
Copy link
Member

cdrage commented Oct 27, 2016

Failing tests?

@kadel
Copy link
Member Author

kadel commented Oct 27, 2016

Failing tests?

yeah :-( It adds empty security context for every container ("securityContext": {}) I have to change that or update tests

@kadel kadel force-pushed the user branch 4 times, most recently from 3abe292 to e917947 Compare October 31, 2016 14:10
@kadel
Copy link
Member Author

kadel commented Oct 31, 2016

fixed and rebased

@ngtuna ngtuna added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 2, 2016
@ericchiang
Copy link

unit tests?

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 21, 2016
@kadel
Copy link
Member Author

kadel commented Nov 21, 2016

rebased and added test

@ngtuna
Copy link
Contributor

ngtuna commented Nov 24, 2016

@kadel It needs rebase again

@kadel
Copy link
Member Author

kadel commented Nov 25, 2016

rebased

@kadel kadel merged commit 6092df4 into kubernetes:master Nov 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. review needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User directive from docker-compose is siletly ignored
5 participants