splunk-pickaxe 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e30eda1563101ee3bf15dfaff58b4bcfcccc3d54
4
- data.tar.gz: 553fcc43e768862110d4acd75dcd596a77db4424
3
+ metadata.gz: 62373e733e325efa667b008d470ab7328a54d0b2
4
+ data.tar.gz: a550e3b13ef3c880242d007235ee5938f8a38b4b
5
5
  SHA512:
6
- metadata.gz: c7d145f55702162f5c336c5fea2b63120434249f29f0583351e765cfe1034777051913cdbc792078a647e807955173a2d5ffdf69c193afa8a53a759ea60b59b8
7
- data.tar.gz: 2982d1bdc9a7c8e8f1933311cd885d2130fd1e841e73dc1a592e2f45493135211e31b2542cb0a63e19d98f5b76fd3be2e4c7e77f2705dfd01c7b66fb772cb512
6
+ metadata.gz: d0c54ba54629fd768b88b648ce7a6dc696cacdb78e3080287a8a06b483c9bb40d411c4161d75bb4f549024f183b0689bd14aaa97172e471ef9223ceaaa12c903
7
+ data.tar.gz: 7f53828e1077ffca6f0b3f197a216d43f028c7d9dffc1f2efddb415409d4776942b204fbd09db1a87e212dabd5bd58347c6a41f54cd80ddee7c1088cdd71ea56
data/README.md CHANGED
@@ -43,7 +43,7 @@ Add some Splunk objects; see [example repo](example-repo) or below for manually
43
43
  defining Splunk objects. Alternatively, to retrieve _all_ Splunk objects from
44
44
  an environment, run:
45
45
 
46
- pickaxe get ENVIONMENT_NAME
46
+ pickaxe save ENVIRONMENT_NAME
47
47
 
48
48
  Where `ENVIRONMENT_NAME` is the name of one of the environments configured in
49
49
  your `.pickaxe.yml`. These map to different Splunk instances.
@@ -204,13 +204,69 @@ environments.
204
204
  Config
205
205
  ------
206
206
 
207
- The `.pickaxe.yml` file contains the config for your Splunk resources. You can add,
207
+ The `.pickaxe.yml` file contains the config for your Splunk resources and should
208
+ look like this,
209
+
210
+ ```yaml
211
+ namespace:
212
+ # The application name to create the splunk dashboards, alerts, reports, tags, etc...
213
+ app: my_splunk_app
214
+
215
+ environments:
216
+ dev:
217
+ url: https://logs-api.dev.my-splunk.com
218
+ staging:
219
+ url: https://logs-api.staging.my-splunk.com
220
+ prod:
221
+ url: https://logs-api.prod.my-splunk.com
222
+ # Optional and will default to the root emails config
223
+ emails:
224
+ - my.email@domain.com
225
+
226
+ # Used for any environments that don't specify emails config
227
+ emails:
228
+ - my.email@domain.com
229
+ ```
230
+
231
+ ### Backwards Compatibility
232
+
233
+ In previous version the config used to look like this,
234
+
235
+ ```yaml
236
+ namespace:
237
+ app: my_splunk_app
238
+
239
+ environments:
240
+ dev: https://logs-api.dev.my-splunk.com
241
+ staging: https://logs-api.staging.my-splunk.com
242
+ prod: https://logs-api.prod.my-splunk.com
243
+
244
+ emails:
245
+ - my.email@domain.com
246
+ ```
247
+
248
+ Specifically the value for each environment was a String that was the URL for
249
+ the Splunk API. The new config format has the environment value as a Hash like
250
+ this,
251
+
252
+ ```yaml
253
+ namespace:
254
+ app: my_splunk_app
255
+
256
+ environments:
257
+ dev:
258
+ url: https://logs-api.dev.my-splunk.com
259
+ staging:
260
+ url: https://logs-api.staging.my-splunk.com
261
+ prod:
262
+ url: https://logs-api.prod.my-splunk.com
263
+
264
+ emails:
265
+ - my.email@domain.com
266
+ ```
208
267
 
209
- * `environments` : A hash of environment names (key) to Splunk url
210
- * `namespace`:
211
- * `app`: The name of your Splunk application to deploy objects to
212
- * `sharing`: The sharing settings for the Splunk resources (default=`app`)
213
- * `emails`: An array of emails used for all reports and alerts (default=`[]`)
268
+ The previous format is still supported but deprecated and will be removed in the
269
+ future.
214
270
 
215
271
  Contributing
216
272
  ------------
@@ -9,11 +9,11 @@ require 'splunk/pickaxe/cookie_proxy'
9
9
  module Splunk
10
10
  module Pickaxe
11
11
  def self.configure(environment, username, password, args)
12
- config = Config.load(args.fetch(:repo_path, Dir.getwd))
12
+ config = Config.load(environment, args.fetch(:repo_path, Dir.getwd))
13
13
 
14
14
  raise "Unknown environment [#{environment}]. Expected #{config.environments.keys}" unless config.environments.key?(environment)
15
15
 
16
- uri = URI(config.environments[environment])
16
+ uri = URI(config.url)
17
17
 
18
18
  puts "Connecting to splunk [#{uri}]"
19
19
  service = Splunk.connect(
@@ -34,9 +34,10 @@ module Splunk
34
34
  f.puts 'namespace:'
35
35
  f.puts ' app: TODO'
36
36
  f.puts 'environments:'
37
- f.puts ' MY_ENV: SPLUNK_API_URL'
38
- f.puts 'emails:'
39
- f.puts ' - my.email@domain.com'
37
+ f.puts ' MY_ENV:'
38
+ f.puts ' url: SPLUNK_API_URL'
39
+ f.puts ' emails:'
40
+ f.puts ' - my.email@domain.com'
40
41
  end
41
42
  end
42
43
 
@@ -16,27 +16,37 @@ module Splunk
16
16
  'emails' => [],
17
17
  }.freeze
18
18
 
19
- def self.load(execution_path)
19
+ def self.load(environment, execution_path)
20
20
  config_path = File.join(execution_path, CONFIG_FILE)
21
21
  raise "Unable to load config file [#{config_path}]" unless File.exist? config_path
22
22
 
23
23
  # Merges DEFAULTS with yaml config
24
- Config.new deep_merge(DEFAULTS, YAML.load_file(config_path)), execution_path
24
+ Config.new deep_merge(DEFAULTS, YAML.load_file(config_path)), environment, execution_path
25
25
  end
26
26
 
27
- attr_reader :config, :namespace, :environments, :execution_path
27
+ attr_reader :namespace, :environment, :execution_path, :emails, :url
28
28
 
29
- def initialize(config, execution_path)
30
- unless config['namespace'].key? 'app'
31
- raise "Config must have a 'namespace / app' config"
32
- end
33
-
34
- raise "Must have at least one environment" unless config['environments'].size > 0
29
+ def initialize(config, environment, execution_path)
30
+ raise "Config must have a 'namespace / app' config" unless config['namespace'].key?('app')
31
+ raise "Environment [#{environment}] is not configured" unless config['environments'].has_key?(environment)
35
32
 
36
- @config = config
37
33
  @execution_path = execution_path
34
+ @environment = environment
38
35
 
39
- @environments = config['environments']
36
+ env_config = config['environments'][environment]
37
+
38
+ if env_config.is_a?(String)
39
+ # Support this for now to be passive but we will remove it later
40
+ puts "Your .pickaxe.yml is using a deprecated config format. Check https://github.com/cerner/splunk-pickaxe#backwards-compatibility for details"
41
+ @emails = config['emails']
42
+ @url = env_config
43
+ elsif env_config.is_a?(Hash)
44
+ raise "url config is required for environment [#{environment}]" unless env_config.has_key?('url')
45
+ @url = env_config['url']
46
+ @emails = env_config.has_key?('emails') ? env_config['emails'] : config['emails']
47
+ else
48
+ raise "Unexepcted value for environment [#{environment}] config. Expected String or Hash, saw #{config['environments'][environment]}"
49
+ end
40
50
 
41
51
  # Convert namespace config hash to hash with symbols for keys
42
52
  namespace_config = config['namespace'].each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; }
@@ -42,7 +42,7 @@ module Splunk
42
42
  def alert_defaults
43
43
  {
44
44
  # Who to email
45
- 'action.email.to' => pickaxe_config.config['emails'].join(','),
45
+ 'action.email.to' => pickaxe_config.emails.join(','),
46
46
 
47
47
  # How often to run alert (every hour)
48
48
  'cron_schedule' => '0 * * * *',
@@ -41,7 +41,7 @@ module Splunk
41
41
  def report_defaults
42
42
  {
43
43
  # Who to email
44
- 'action.email.to' => pickaxe_config.config['emails'].join(','),
44
+ 'action.email.to' => pickaxe_config.emails.join(','),
45
45
 
46
46
  # How often to run alert (every hour)
47
47
  'cron_schedule' => '0 * * * *',
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Splunk
4
4
  module Pickaxe
5
- VERSION = '2.2.0'
5
+ VERSION = '2.3.0'
6
6
  end
7
7
  end
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.2.0
4
+ version: 2.3.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: 2017-12-11 00:00:00.000000000 Z
11
+ date: 2018-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: splunk-sdk-ruby