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 --chown <uid>:<gid> #125

Closed
wants to merge 16 commits into from

Conversation

rhuss
Copy link
Contributor

@rhuss rhuss commented Apr 24, 2017

The parameter can be given in the form : but also username and
group names are supported if the os supports the lookup.
The safest way is to use numeric user ids.

The use case for this feature is when the processed templates are expected
to belong to a certain user/group. E.g. Wildfly Docker images, a prominent Java
EE application server write into the configuration files, too but runs with a non-root uid
and so needs the proper access. Depending on the uid under which the server
run and the files has been created, this has to be tuned.

Especially in a Docker context this might be helpful since Docker does not
support changing the ownership with ADD or COPY (its always added as root).
In order to avoid some postprocessing of the generated files (which might even
not be possible e.g. when running from a scratch image without any installed
shell), this options proves to be quite useful and add some flexibility
(on the cost of an additional feature, though).

This PR is based on #119 and add the commit rhuss@75a28b1

rhuss added 16 commits April 23, 2017 07:11
- Use these options when a whole directory hierarchy needs to be processed.
- Extracted file processing logic in an extra process.go

Partial solution to hairyhenderson#117
Don't know whether I touched this, but this test still repots an error. but with rc 1 instead of 2. Don't know if this ok.
Please review whether this is my fauls or whether this ok like this.
No error returned anymore, direct panic instead.
If not given, the default is the current working directory
Relates to PR hairyhenderson#119
Cant be used as a default to the CLI because it messes up the validation checks otherwise
… success

Thanks to the awesome IT suite for triggering this
Relates to hairyhenderson#119
sorry, this slipped through
The parameter can be given in the form <uid>:<gid> but also username and
group names are supported _if_ the os supports the lookup.
The safest way is to use numeric user ids.

The use case for this feature is when the processed templates are expected
to belong to a certain user/group. E.g. Wildfly Docker images, a prominent Java
EE application server write into the configuration files, too but runs with a non-root uid
and so needs the proper access. Depending on the uid under which the server
run and the files has been created, this has to be tuned.

Especially in a Docker context this might be helpful since Docker does not
support changing the ownership with ADD or COPY (its always added as root).
In order to avoid some postprocessing of the generated files (which might even
not be possible e.g. when running from a scratch image without any installed
shell), this options proves to be quite useful and add some flexibility
(on the cost of an additional feature, though).
@rhuss rhuss changed the title Add support for --chown <gid>:<uid> Add support for --chown <uid>:<gid> Apr 25, 2017
@hairyhenderson
Copy link
Owner

Thanks again, @rhuss!

Wouldn't it work to just run gomplate as the target user?

In a non-Docker context, it should work to instead just set the uid/gid to the same as the input file (assuming the input belongs to a different user, and assuming the gomplate process is running as a user privileged enough to set that).

I'm thinking this option is straying a little too far outside the scope of what I want gomplate to be responsible for (though, admittedly, I've never actually defined that 😉)...

@rhuss
Copy link
Contributor Author

rhuss commented Apr 25, 2017

Right, it's about a Docker context, right, where you don't always have influence on the user which executes your container.

But you are probably right, it's add too much complexity for little value (especially because this feature is also OS dependent and would need to be tested cross platform).

@rhuss rhuss closed this Apr 25, 2017
@hairyhenderson
Copy link
Owner

👍

@rhuss
Copy link
Contributor Author

rhuss commented Apr 25, 2017

@hairyhenderson btw, wonder whether original file permission shouldn't be respected or whether it always ok to have 0644 on the files created as it is done here I think this could be easily fixed.

@hairyhenderson
Copy link
Owner

@rhuss definitely I'd like original file permissions to be respected. Originally gomplate didn't even deal with files (just stdin/stdout), so that's one thing that I didn't consider. I'd appreciate an issue for that, and I'd certainly accept a PR for that, if you have the time 🙂 - otherwise I'd be happy to deal with it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants