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

Config file scope #151

Merged
merged 5 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Add the 'file' scope

## 12.0.0 - *2023-05-18*

- Remove service resource
Expand Down
7 changes: 4 additions & 3 deletions resources/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

property :key, String, name_property: true
property :value, String
property :scope, String, equal_to: %w(local global system), default: 'global', desired_state: false
property :scope, String, equal_to: %w(local global system file), default: 'global', desired_state: false
property :config_file, String, desired_state: false
property :path, String, desired_state: false
property :user, String, desired_state: false
property :group, String, desired_state: false
Expand All @@ -18,7 +19,7 @@

cmd_env = user ? { 'USER' => user, 'HOME' => home_dir } : nil
config_vals = Mixlib::ShellOut.new(
"git config --get --#{scope} #{key}",
"git config --get --#{scope} #{config_file} #{key}",
user: user,
group: group,
password: password,
Expand Down Expand Up @@ -47,7 +48,7 @@

action_class do
def config_cmd
"git config --#{new_resource.scope}"
"git config --#{new_resource.scope} #{new_resource.config_file}"
end

def cmd_env
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/cookbooks/test/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@
scope 'system'
options '--add'
end

git_config 'user.signingkey' do
value 'FA2D8E280A6DD5'
scope 'file'
config_file '~/.gitconfig.key'
end
4 changes: 4 additions & 0 deletions test/integration/resources/git_installed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@
its(%w(user name)) { should eq 'John Doe system' }
its(['url "https://github.com/"', 'insteadOf']) { should eq 'git://github.com/' }
end

describe ini('/root/.gitconfig.key') do
its(%w(user signingkey)) { should eq 'FA2D8E280A6DD5' }
end