Skip to content

Commit

Permalink
Compatible with old chef-encrypted-attributes gems
Browse files Browse the repository at this point in the history
  • Loading branch information
zuazo committed Dec 10, 2014
1 parent aa65200 commit aea5660
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
9 changes: 8 additions & 1 deletion libraries/encrypted_attributes_helpers.rb
Expand Up @@ -26,7 +26,14 @@ module EncryptedAttributesHelpers

def encrypted_attributes_include
run_context.include_recipe 'encrypted_attributes'
require 'chef/encrypted_attributes'
begin
require 'chef/encrypted_attributes'
rescue LoadError
require 'chef-encrypted-attributes'
Chef::Log.warn(
'Old chef-encrypted-attributes gem detected, please upgrade ASAP.'
)
end
end

def attr_get_from_ary(attr_ary)
Expand Down
9 changes: 8 additions & 1 deletion recipes/default.rb
Expand Up @@ -51,4 +51,11 @@
end
end

require 'chef/encrypted_attributes'
begin
require 'chef/encrypted_attributes'
rescue LoadError
require 'chef-encrypted-attributes'
Chef::Log.warn(
'Old chef-encrypted-attributes gem detected, please upgrade ASAP.'
)
end
27 changes: 27 additions & 0 deletions spec/support/encrypted_attributes.rb
@@ -0,0 +1,27 @@
# encoding: UTF-8
#
# Author:: Xabier de Zuazo (<xabier@onddo.com>)
# Copyright:: Copyright (c) 2014 Onddo Labs, SL. (www.onddo.com)
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

begin
require 'chef/encrypted_attributes'
rescue LoadError
require 'chef-encrypted-attributes'
Chef::Log.warn(
'Old chef-encrypted-attributes gem detected, please upgrade ASAP.'
)
end
2 changes: 1 addition & 1 deletion spec/unit/encrypted_attributes_helpers_spec.rb
Expand Up @@ -18,7 +18,7 @@
#

require 'spec_helper'
require 'chef/encrypted_attributes'
require 'support/encrypted_attributes'
require 'encrypted_attributes_helpers.rb'

# A recipe which includes EncryptedAttributesHelpers
Expand Down

0 comments on commit aea5660

Please sign in to comment.