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

Handle file mode for kubeconfig files #42

Merged
merged 4 commits into from
Jul 5, 2023

Conversation

ananace
Copy link
Member

@ananace ananace commented Apr 13, 2023

Probably not the most optimal implementation, though it's best to at least ensure it's 0600 by default.

@ananace ananace added the enhancement New feature or request label Apr 13, 2023
@ananace ananace mentioned this pull request Apr 27, 2023
@ananace
Copy link
Member Author

ananace commented Apr 28, 2023

I don't suppose there's some vox pupuli module that's done file mode handling, since the code here is very fragile.
I tried to look at the Puppet file handling itself, but it looked to be difficult to use outside of the file resource itself.

Copy link
Member

@tuxmea tuxmea left a comment

Choose a reason for hiding this comment

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

Looks OK to me. @ananace can you please verify that mode => 'u-x+rw,g-rwx,o-rwx' does also work?

@ananace
Copy link
Member Author

ananace commented May 2, 2023

@tuxmea I can verify that such a mode most definitely does not work, since the code has no concept except for octal modes at the moment. Hence my asking if there was any examples for using the mode parsing code from the Puppet file type outside of it, since I very much want to support mode strings as well.

@tuxmea
Copy link
Member

tuxmea commented May 3, 2023

@ananace on any puppet installation, check /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/symbolic_file_mode.rb
This gets required by /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file/mode.rb and /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file.rb

@ananace
Copy link
Member Author

ananace commented May 3, 2023

@tuxmea Yes, those are the exact files I was asking about if anyone has actually used outside of said type. The symbolic file mode handling looks exactly like what I want after all, but they proved annoying to use in-place, and I wanted to avoid having to copy out Puppet code into module-local classes when they already exist.

@bastelfreak
Copy link
Member

@ananace is this ready for merge?

@ananace
Copy link
Member Author

ananace commented Jun 30, 2023

It should be, I was debating the handling of multiple kubeconfig contexts - or contexts in files created elsewhere, but I figure it's very unlikely that the default of 0600 is going to cause any issues for people - since it's what the K8s tooling itself expects anyway.

@ananace ananace merged commit edb7878 into voxpupuli:master Jul 5, 2023
@ananace ananace deleted the kubeconfig-chmod branch July 5, 2023 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants