From 9b9227a423f75622f67f3225fcda3aa5d30eded0 Mon Sep 17 00:00:00 2001 From: Jeremy MAURO Date: Tue, 24 May 2022 18:28:37 +0200 Subject: [PATCH 1/4] feat(config_file): Add the 'file' scope STATE: In the 'git-config' documentation, there is the possibility to use the '--file ' scope. PROPOSED SOLUTION: - Add the 'file' scope in the resource 'scope' - Add the 'config_file' property Signed-off-by: Jeremy MAURO --- resources/config.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/config.rb b/resources/config.rb index 9bbb3a6..1ff0f7f 100644 --- a/resources/config.rb +++ b/resources/config.rb @@ -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 @@ -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, @@ -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 From 684d3b8ad224cda92414e1fd068eb183757a851b Mon Sep 17 00:00:00 2001 From: Jeremy MAURO Date: Tue, 24 May 2022 18:32:41 +0200 Subject: [PATCH 2/4] test(config_file): Add test for the new 'file' scope feature Signed-off-by: Jeremy MAURO --- test/fixtures/cookbooks/test/recipes/default.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/fixtures/cookbooks/test/recipes/default.rb b/test/fixtures/cookbooks/test/recipes/default.rb index fc6f89c..a8b17eb 100644 --- a/test/fixtures/cookbooks/test/recipes/default.rb +++ b/test/fixtures/cookbooks/test/recipes/default.rb @@ -49,3 +49,9 @@ scope 'system' options '--add' end + +git_config 'user.signingkey' do + value 'FA2D8E280A6DD5' + scope 'file' + config_file '~/.gitconfig.key' +end From c567b4fd519beba6c8388ddd8822e9a2cc062b9d Mon Sep 17 00:00:00 2001 From: Jeremy MAURO Date: Tue, 24 May 2022 18:41:14 +0200 Subject: [PATCH 3/4] test(config_file): Add integration test for 'config_file' Signed-off-by: Jeremy MAURO --- test/integration/resources/git_installed_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/integration/resources/git_installed_spec.rb b/test/integration/resources/git_installed_spec.rb index 32f2621..4922aba 100644 --- a/test/integration/resources/git_installed_spec.rb +++ b/test/integration/resources/git_installed_spec.rb @@ -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 From faf1870d8291c9de911b62561ccb3dc85ca89390 Mon Sep 17 00:00:00 2001 From: Jeremy MAURO Date: Tue, 24 May 2022 18:43:35 +0200 Subject: [PATCH 4/4] doc(config_file): Update the changelog to add 'config_file' feature Signed-off-by: Jeremy MAURO --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d78c066..b2b52d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Add the 'file' scope + ## 11.1.0 - *2022-08-09* - Standardise files with files in sous-chefs/repo-management