Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

[Deployment] Update default branch #4

Merged
merged 4 commits into from
Aug 22, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [1.1.0](https://github.com/codenamephp/chef.cookbook.gitClient/tree/1.1.0) (2021-08-22)

[Full Changelog](https://github.com/codenamephp/chef.cookbook.gitClient/compare/1.0.0...1.1.0)

**Implemented enhancements:**

- Check if user exists for data bag [\#3](https://github.com/codenamephp/chef.cookbook.gitClient/pull/3) ([bastianschwarz](https://github.com/bastianschwarz))

## [1.0.0](https://github.com/codenamephp/chef.cookbook.gitClient/tree/1.0.0) (2021-08-21)

[Full Changelog](https://github.com/codenamephp/chef.cookbook.gitClient/compare/24fa20cfaa7dd71dc034ab6de7ea7507f79d8477...1.0.0)
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
maintainer_email 'bastian@codename-php.de'
license 'Apache-2.0'
description 'Cookbook to install apache2'
version '1.0.0'
version '1.1.0'
chef_version '>= 15.3'
issues_url 'https://github.com/codenamephp/chef.cookbook.gitClient/issues'
source_url 'https://github.com/codenamephp/chef.cookbook.gitClient'
Expand Down
2 changes: 1 addition & 1 deletion resources/config_users_from_data_bag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
begin
users_configs = search(new_resource.data_bag_name, 'codenamephp_git_client_config*:*')
.to_h { |user| [user[:id], user.dig(:codenamephp, :git_client, :config) || {}] }
.select { |_, configs| !configs.nil? && !configs.empty? }
.select { |username, configs| !configs.nil? && !configs.empty? && !shell_out("getent passwd #{username}").error? }

codenamephp_git_client_config_users 'Config users from databag' do
users_configs users_configs
Expand Down
12 changes: 11 additions & 1 deletion spec/resources/config_users_from_data_bag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
'id' => 'user2',
'codenamephp' => {
'git_client' => {
'config' => {},
'config' => {
'config' => { 'user2_config1' => 'user2_value1', 'user2_config2' => 'user2_value2' },
},
},
},
},
Expand All @@ -45,6 +47,14 @@
])
end

stubs_for_provider('codenamephp_git_client_config_users_from_data_bag[Manage git users]') do |provider|
allow(provider).to receive_shell_out()
allow(provider).to receive_shell_out('getent passwd user1', exitstatus: 0)
allow(provider).to receive_shell_out('getent passwd user2', exitstatus: 1)
allow(provider).to receive_shell_out('getent passwd user3', exitstatus: 0)
allow(provider).to receive_shell_out('getent passwd user4', exitstatus: 0)
end

recipe do
codenamephp_git_client_config_users_from_data_bag 'Manage git users'
end
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/data_bags/users/not_exist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "not-exist",
"codenamephp": {
"git_client": {
"config": {
"user.name": "egal",
"user.email": "egal@test.de"
}
}
}
}