splunk-pickaxe 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/splunk/pickaxe/cli.rb +1 -0
- data/lib/splunk/pickaxe/client.rb +7 -6
- data/lib/splunk/pickaxe/objects.rb +26 -15
- data/lib/splunk/pickaxe/objects/dashboards.rb +13 -2
- data/lib/splunk/pickaxe/objects/field_extractions.rb +13 -2
- data/lib/splunk/pickaxe/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7898620b6ba1c671085b79b5f22d767066dd23b0efe44f3286a8cecd34df1f5
|
4
|
+
data.tar.gz: 8677d479c6a7552f6c82a23a5b58a04ee5ba944c8fd2cb6a6085f6e9979e1bbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8c1c83a771dcc15ebe686c8130f3764ef2ccccb26fa3e00689b2888489a76540900281c8c0a242611b6f52c7556cd09670d3a3dc3b5d5cf4e3045afcdfb479e
|
7
|
+
data.tar.gz: 5a0258fb8382a92d505fbf97fb0b0cdeb1a9f68fdb4735c852428ec71e9c7c544c123b303d3bf7164a42f16d69bf41831195d19cece8dca4269f072c9db069b9
|
data/lib/splunk/pickaxe/cli.rb
CHANGED
@@ -61,6 +61,7 @@ module Splunk
|
|
61
61
|
option :password, type: :string, desc: 'The password to login to splunk with. If this is not provided it will ask for a password'
|
62
62
|
option :repo_path, type: :string, desc: 'The path to the repo. If this is not specified it is assumed you are executing from within the repo'
|
63
63
|
option :overwrite, type: :boolean, desc: 'Overwrite any local Splunk objects which differ from remote objects with the same name.'
|
64
|
+
option :local_save, type: :boolean, desc: 'Only retrieve local Splunk objects from remote'
|
64
65
|
def save(environment)
|
65
66
|
cli = HighLine.new
|
66
67
|
|
@@ -38,14 +38,15 @@ module Splunk
|
|
38
38
|
|
39
39
|
def save_all
|
40
40
|
overwrite = @args.fetch(:overwrite, false)
|
41
|
+
local_save = @args.fetch(:local_save, false)
|
41
42
|
|
42
|
-
@alerts.save overwrite
|
43
|
-
@dashboards.save overwrite
|
44
|
-
@eventtypes.save overwrite
|
45
|
-
@macros.save overwrite
|
46
|
-
@reports.save overwrite
|
43
|
+
@alerts.save overwrite, local_save
|
44
|
+
@dashboards.save overwrite, local_save
|
45
|
+
@eventtypes.save overwrite, local_save
|
46
|
+
@macros.save overwrite, local_save
|
47
|
+
@reports.save overwrite, local_save
|
47
48
|
# splunk-sdk doesn't seem to support iterating tags
|
48
|
-
@field_extractions.save overwrite
|
49
|
+
@field_extractions.save overwrite, local_save
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
@@ -89,32 +89,27 @@ module Splunk
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
def save(overwrite)
|
92
|
+
def save(overwrite, local_save)
|
93
93
|
puts "Saving all #{entity_dir.capitalize}"
|
94
94
|
|
95
95
|
dir = File.join(pickaxe_config.execution_path, entity_dir)
|
96
96
|
Dir.mkdir dir unless Dir.exist? dir
|
97
97
|
|
98
98
|
Splunk::Collection.new(service, splunk_resource)
|
99
|
-
.map { |e| save_config e, overwrite }
|
99
|
+
.map { |e| save_config e, overwrite, local_save }
|
100
100
|
end
|
101
101
|
|
102
|
-
def save_config(splunk_entity, overwrite)
|
102
|
+
def save_config(splunk_entity, overwrite, local_save)
|
103
103
|
file_path = entity_file_path splunk_entity
|
104
104
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
'name' => splunk_entity.name,
|
111
|
-
'config' => splunk_entity_keys
|
112
|
-
.map { |k| { k => splunk_entity.fetch(k) } }
|
113
|
-
.reduce({}) { |memo, setting| memo.update(setting) }
|
114
|
-
}.to_yaml)
|
115
|
-
puts overwritten ? ' Overwritten' : ' Created'
|
105
|
+
if local_save
|
106
|
+
if File.exist?(file_path)
|
107
|
+
puts "- #{splunk_entity.name}"
|
108
|
+
write_to_file(file_path, overwrite, splunk_entity)
|
109
|
+
end
|
116
110
|
else
|
117
|
-
puts
|
111
|
+
puts "- #{splunk_entity.name}"
|
112
|
+
write_to_file(file_path, overwrite, splunk_entity)
|
118
113
|
end
|
119
114
|
end
|
120
115
|
|
@@ -171,6 +166,22 @@ module Splunk
|
|
171
166
|
# Must be implemented by child class
|
172
167
|
nil
|
173
168
|
end
|
169
|
+
|
170
|
+
def write_to_file(file_path, overwrite, splunk_entity)
|
171
|
+
if overwrite || !File.exist?(file_path)
|
172
|
+
overwritten = overwrite && File.exist?(file_path)
|
173
|
+
|
174
|
+
File.write(file_path, {
|
175
|
+
'name' => splunk_entity.name,
|
176
|
+
'config' => splunk_entity_keys
|
177
|
+
.map { |k| { k => splunk_entity.fetch(k) } }
|
178
|
+
.reduce({}) { |memo, setting| memo.update(setting) }
|
179
|
+
}.to_yaml)
|
180
|
+
puts overwritten ? ' Overwritten' : ' Created'
|
181
|
+
else
|
182
|
+
puts ' Already exists'
|
183
|
+
end
|
184
|
+
end
|
174
185
|
end
|
175
186
|
end
|
176
187
|
end
|
@@ -44,10 +44,21 @@ module Splunk
|
|
44
44
|
['.xml']
|
45
45
|
end
|
46
46
|
|
47
|
-
def save_config(splunk_entity, overwrite)
|
47
|
+
def save_config(splunk_entity, overwrite, local_save)
|
48
48
|
file_path = entity_file_path splunk_entity
|
49
49
|
|
50
|
-
|
50
|
+
if local_save
|
51
|
+
if File.exist?(file_path)
|
52
|
+
puts "- #{splunk_entity['label']}"
|
53
|
+
write_to_file(file_path, overwrite, splunk_entity)
|
54
|
+
end
|
55
|
+
else
|
56
|
+
puts "- #{splunk_entity['label']}"
|
57
|
+
write_to_file(file_path, overwrite, splunk_entity)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def write_to_file(file_path, overwrite, splunk_entity)
|
51
62
|
if overwrite || !File.exist?(file_path)
|
52
63
|
overwritten = overwrite && File.exist?(file_path)
|
53
64
|
|
@@ -47,10 +47,21 @@ module Splunk
|
|
47
47
|
splunk_entity['value'] != splunk_config(entity)['value']
|
48
48
|
end
|
49
49
|
|
50
|
-
def save_config(splunk_entity, overwrite)
|
50
|
+
def save_config(splunk_entity, overwrite, local_save)
|
51
51
|
file_path = entity_file_path splunk_entity
|
52
52
|
|
53
|
-
|
53
|
+
if local_save
|
54
|
+
if File.exist?(file_path)
|
55
|
+
puts "- #{splunk_entity.name}"
|
56
|
+
write_to_file(file_path, overwrite, splunk_entity)
|
57
|
+
end
|
58
|
+
else
|
59
|
+
puts "- #{splunk_entity.name}"
|
60
|
+
write_to_file(file_path, overwrite, splunk_entity)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def write_to_file(file_path, overwrite, splunk_entity)
|
54
65
|
if overwrite || !File.exist?(file_path)
|
55
66
|
config = splunk_entity_keys
|
56
67
|
.map { |k| { k => splunk_entity.fetch(k) } }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: splunk-pickaxe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Baugher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: splunk-sdk-ruby
|