Only set the password when it is supplied
Here we make use of the `property_is_set?` function to gate the management of the password when the property has been supplied, and then treat `nil` to mean explicitly reset the password. In order to add confidence that it is working we add a new test cookbook, and add a spec/chef/resources/postgres_user_spec.rb to make use of it. We also add an explcit execute resource, to fixup user options if needed Sadly these tests reveal that the handling of nil values for properties fails when using chef 12. When extracted[1] we can see this works with chef 13, but as an upgrade is out of scope for now, we mark the example as pending. [1] https://gitlab.com/richardc/lwrp-nil-headache/
Showing
- files/gitlab-cookbooks/gitlab/libraries/helpers/base_pg_helper.rb 22 additions, 0 deletions...tlab-cookbooks/gitlab/libraries/helpers/base_pg_helper.rb
- files/gitlab-cookbooks/gitlab/resources/postgresql_user.rb 19 additions, 3 deletionsfiles/gitlab-cookbooks/gitlab/resources/postgresql_user.rb
- spec/chef/resources/postgresql_user_spec.rb 69 additions, 0 deletionsspec/chef/resources/postgresql_user_spec.rb
- spec/chef_helper.rb 1 addition, 1 deletionspec/chef_helper.rb
- spec/fixtures/cookbooks/test_gitlab_postgresql_user/metadata.rb 2 additions, 0 deletions...ixtures/cookbooks/test_gitlab_postgresql_user/metadata.rb
- spec/fixtures/cookbooks/test_gitlab_postgresql_user/recipes/create.rb 2 additions, 0 deletions...s/cookbooks/test_gitlab_postgresql_user/recipes/create.rb
- spec/fixtures/cookbooks/test_gitlab_postgresql_user/recipes/options_superuser.rb 3 additions, 0 deletions.../test_gitlab_postgresql_user/recipes/options_superuser.rb
- spec/fixtures/cookbooks/test_gitlab_postgresql_user/recipes/password_empty.rb 3 additions, 0 deletions...oks/test_gitlab_postgresql_user/recipes/password_empty.rb
- spec/fixtures/cookbooks/test_gitlab_postgresql_user/recipes/password_md5.rb 5 additions, 0 deletions...books/test_gitlab_postgresql_user/recipes/password_md5.rb
- spec/fixtures/cookbooks/test_gitlab_postgresql_user/recipes/password_nil.rb 3 additions, 0 deletions...books/test_gitlab_postgresql_user/recipes/password_nil.rb
- spec/fixtures/cookbooks/test_gitlab_postgresql_user/recipes/password_unspecified.rb 2 additions, 0 deletions...st_gitlab_postgresql_user/recipes/password_unspecified.rb
- spec/libraries/helpers/base_pg_helper_spec.rb 58 additions, 0 deletionsspec/libraries/helpers/base_pg_helper_spec.rb
Loading
Please register or sign in to comment