Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to write arbitrary JSON to a file #671

Merged
merged 4 commits into from
Jun 20, 2017

Conversation

ghoneycutt
Copy link
Collaborator

No description provided.

@ghoneycutt
Copy link
Collaborator Author

@robbyt could you please have a look at these spec tests for the function

@robbyt
Copy link
Collaborator

robbyt commented Jun 19, 2017

@ghoneycutt please apply this patch:

diff --git a/spec/functions/sensu_sorted_json_spec.rb b/spec/functions/sensu_sorted_json_spec.rb
index df486c5..8b5e1d9 100644
--- a/spec/functions/sensu_sorted_json_spec.rb
+++ b/spec/functions/sensu_sorted_json_spec.rb
@@ -1,11 +1,18 @@
 require 'spec_helper'
-describe 'sensu_write_json' do
+describe 'sensu_sorted_json' do
+  it { is_expected.not_to eq(nil) }
+
   describe 'should error when expected' do
     it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, /0 for 1, 2 or 3/) }
     it { is_expected.to run.with_params(1,2,3,4).and_raise_error(Puppet::ParseError, /4 for 1, 2 or 3/) }
   end

-  valid_hash = {"bind_addr"=>"192.168.34.56","client_addr"=>"127.0.0.1","ports"=>{"http"=>-1,"https"=>8500,"rpc"=>8567},"start_join"=>["192.168.34.60","192.168.34.61","192.168.34.62"]}
+  valid_hash = {
+    "bind_addr"=>"192.168.34.56",
+    "client_addr"=>"127.0.0.1",
+    "ports"=>{"http"=>-1,"https"=>8500,"rpc"=>8567},
+    "start_join"=>["192.168.34.60","192.168.34.61","192.168.34.62"],
+  }

   valid_pretty_hash = <<-END.gsub(/^\s+\|/, '')
     |{
@@ -26,7 +33,7 @@ describe 'sensu_write_json' do

   describe 'should return correct results' do
     it 'should run with valid hash' do
-      should run.with_params(valid_hash).and_return(valid_pretty_hash)
+      is_expected.to run.with_params(valid_hash, true, 4).and_return(valid_pretty_hash)
     end
   end
 end

@ghoneycutt
Copy link
Collaborator Author

@robbyt Thanks for the patch

robbyt and others added 4 commits June 20, 2017 11:32
Add sensu::write_json defined resource type, used for writing custom
config files. Which makes use of the new sensu_sorted_json() function
for turning a hash into sorted JSON.
@ghoneycutt ghoneycutt merged commit e7dc01e into sensu:master Jun 20, 2017
@ghoneycutt ghoneycutt deleted the write_json branch June 20, 2017 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants