lib/teststrap.rb in teststrap-1.1.8 vs lib/teststrap.rb in teststrap-1.2.0
- old
+ new
@@ -12,41 +12,24 @@
desc "generate_tests", "generate test files"
def generate_tests
@cookbook_name = current_directory_name
puts "generating testfiles::"
copy_file ".gitignore"
+ copy_file ".rubocop.yml"
copy_file "Berksfile"
copy_file "chefignore"
copy_file "Gemfile"
copy_file "LICENSE"
+ copy_file "rubocop-disabled.yml"
copy_file "Strainerfile"
copy_file "Thorfile"
template "spec/default_spec.rb"
template "spec/chefspec_helper.rb"
template "test/integration/default/serverspec/localhost/default_spec.rb"
template "test/integration/default/serverspec/spec_helper.rb"
template ".kitchen.yml"
template "metadata.rb"
template "README.md"
- end
-
- desc "encrypt [data_path] [secret_path]", "encrypt plain databag item to encrypted databag item"
- def encrypt(data_path, secret_path)
- if !File.exist?(data_path)
- puts "file: #{data_path} doesn't exists"
- return nil
- end
-
- if !File.exist?(secret_path)
- puts "secret key file: #{secret_path} doesn't exists"
- return nil
- end
-
- plain_data = JSON.parse(File.read(data_path))
- secret = Chef::EncryptedDataBagItem.load_secret(secret_path)
- encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(plain_data, secret)
- puts JSON.pretty_generate(encrypted_data)
- return encrypted_data
end
no_commands do
def current_directory_name
Dir.pwd.split('/').last