puppet-community-rangefinder 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d27fe23607e34a37dc211d6526ea57f99ebf25f212af104e94c837c40a7bd8a
4
- data.tar.gz: c03245d149ba06bce93c0ccfc8a969a81aa20366cb85b2e3e96c7df01b6e3b9f
3
+ metadata.gz: a5fb940183c9ea99d93b015d05a74475499e9053a720d4e376712b39523fc76e
4
+ data.tar.gz: 9d609345c22b46ef5018ea80d9bf02e70ff2ce774c2e20d00eca5b62183614b7
5
5
  SHA512:
6
- metadata.gz: 4050af14e897cc9d52d87fbac5850ca651c0283c2c5e5452e798e18d161d27076db089b0b787da6b8cae254470823906bbb2d2044417b992dfc197e1e09d9b0f
7
- data.tar.gz: 6813a1cacb4bcb438c04c45c00f7113b5560be29749da273b90f8eb2b0dde7a6bc0d239fdfc54539610acc3592df562341bc4e52a68e0f774d2b8def4585170b
6
+ metadata.gz: fa4c71d46436dd4d7b5032a0da5c2948f687e8c783eb2d701c7aba6a7abdd6dd7e2ce02e7656989bc267fef0c780c73f31c54ae4b379217f6f4acfe7ef2fba52
7
+ data.tar.gz: cfd912d3b589d22c2533aac92c6f32b410ed2eef460b43f8a8fe802834fba8cde6a4888cdb5386a3de3e7df82c9bdd6bc736ff8c5c73ec70c3c699ca6fcd93ac
@@ -1,7 +1,13 @@
1
+ # v0.0.5
2
+
3
+ * Ported to use the public dataset by default now.
4
+
5
+
1
6
  # v0.0.4
2
7
 
3
8
  * Render stats for Puppetfile dependencies
4
9
 
10
+
5
11
  # v0.0.3
6
12
 
7
13
  * Added summary view for a list of files
data/README.md CHANGED
@@ -31,28 +31,6 @@ This currently knows how to interpret and look up:
31
31
 
32
32
  This is distributed as a Ruby gem. Simply `gem install puppet-community-rangefinder`
33
33
 
34
- ******************************************************************************
35
- * Note that this is only useful by members of the Puppet Ecosystem team *
36
- * because it uses BigQuery data that's not available publicly. *
37
- ******************************************************************************
38
-
39
-
40
- ## Configuration
41
-
42
- You must configure BigQuery credentials in the `~/.rangefinder.conf` file.
43
-
44
- Example configuration:
45
-
46
- ```
47
- ---
48
- :gcloud:
49
- :dataset: <dataset>
50
- :project: <project>
51
- :keyfile: ~/.rangefinder/credentials.json
52
- ```
53
-
54
- Contact [me](mailto:ben.ford@puppet.com) for credentials.
55
-
56
34
 
57
35
  ## Running
58
36
 
@@ -397,14 +375,35 @@ Breaking changes to this file MAY impact these modules:
397
375
  ```
398
376
 
399
377
 
378
+ ## Configuration
379
+
380
+ Rangefinder will use the public dataset by default. If you're developing on the
381
+ data pipeline, you may configure BigQuery credentials in the `~/.rangefinder.conf`
382
+ file to point at private datasets instead.
383
+
384
+ Example configuration:
385
+
386
+ ```
387
+ ---
388
+ :gcloud:
389
+ :dataset: <dataset>
390
+ :project: <project>
391
+ :keyfile: ~/.rangefinder/credentials.json
392
+ ```
393
+
394
+ Contact [me](mailto:ben.ford@puppet.com) for credentials.
395
+
396
+
400
397
  ## Limitations
401
398
 
402
399
  This is super early in development and has not yet been battle tested.
403
400
 
401
+
404
402
  ## Disclaimer
405
403
 
406
404
  I take no liability for the use of this tool.
407
405
 
406
+
408
407
  Contact
409
408
  -------
410
409
 
@@ -6,7 +6,17 @@ require 'optparse'
6
6
  require 'rangefinder'
7
7
 
8
8
  loglevel = Logger::WARN
9
- options = YAML.load_file(File.expand_path('~/.rangefinder.conf')) rescue {}
9
+ options = {
10
+ :gcloud => {
11
+ :noinit => true,
12
+ :dataset => 'community',
13
+ :project => 'dataops-puppet-public-data',
14
+ :keyfile => File.join(File.dirname(__FILE__), '..', 'assets', 'read-only-credentials.json')
15
+ }
16
+ }
17
+ overrides = YAML.load_file(File.expand_path('~/.rangefinder.conf')) rescue {}
18
+ options.merge!(overrides)
19
+
10
20
  OptionParser.new do |opts|
11
21
  opts.banner = "Usage: rangefinder <paths>
12
22
 
@@ -46,8 +56,9 @@ Note that non-namespaced items will always be near match only.
46
56
  end
47
57
 
48
58
  end.parse!
59
+ options[:gcloud][:keyfile] = File.expand_path(options[:gcloud][:keyfile])
49
60
  options[:filenames] = ARGV.map {|f| File.expand_path f} unless ARGV.empty?
50
- options[:filenames] ||= ['manifests/init.pp']
61
+ options[:filenames] ||= ['manifests']
51
62
  options[:render] ||= :human
52
63
 
53
64
  $logger = Logger.new($stderr)
@@ -12,7 +12,7 @@ class Rangefinder
12
12
  @bigquery = Rangefinder::Bigquery.new(options)
13
13
 
14
14
  if options[:filenames].size == 1 and File.directory?(options[:filenames].first)
15
- options[:filenames] = Dir.glob("#{options[:filenames].first}/*")
15
+ options[:filenames] = Dir.glob("#{options[:filenames].first}/**/*")
16
16
  end
17
17
  end
18
18
 
@@ -7,7 +7,6 @@ class Rangefinder::Bigquery
7
7
 
8
8
  raise "Required gCloud configuration missing" unless gcloud
9
9
 
10
- gcloud[:keyfile] = File.expand_path(gcloud[:keyfile])
11
10
  @bigquery = Google::Cloud::Bigquery.new(
12
11
  :project_id => gcloud[:project],
13
12
  :credentials => Google::Cloud::Bigquery::Credentials.new(gcloud[:keyfile]),
@@ -18,8 +17,8 @@ class Rangefinder::Bigquery
18
17
 
19
18
  def find(namespace, kind, name)
20
19
  sql = "SELECT DISTINCT module, i.source, m.source AS repo
21
- FROM `bto-dataops-datalake-prod.community.forge_itemized` AS i
22
- JOIN `bto-dataops-datalake-prod.community.forge_modules` AS m
20
+ FROM `#{@dataset.project_id}.#{@dataset.dataset_id}.forge_itemized` AS i
21
+ JOIN `#{@dataset.project_id}.#{@dataset.dataset_id}.forge_modules` AS m
23
22
  ON m.slug = i.module
24
23
  WHERE kind = @kind AND element = @name"
25
24
 
@@ -45,14 +44,14 @@ class Rangefinder::Bigquery
45
44
 
46
45
  def puppetfile_count(modname=nil)
47
46
  if modname
48
- sql = 'SELECT COUNT(DISTINCT repo_name) AS count
49
- FROM `bto-dataops-datalake-prod.community.github_puppetfile_usage`
50
- WHERE module = @name'
47
+ sql = "SELECT COUNT(DISTINCT repo_name) AS count
48
+ FROM `#{@dataset.project_id}.#{@dataset.dataset_id}.github_puppetfile_usage`
49
+ WHERE module = @name"
51
50
 
52
51
  data = @dataset.query(sql, params: {name: modname})
53
52
  else
54
- sql = 'SELECT COUNT(DISTINCT repo_name) AS count
55
- FROM `bto-dataops-datalake-prod.community.github_puppetfile_usage`'
53
+ sql = "SELECT COUNT(DISTINCT repo_name) AS count
54
+ FROM `#{@dataset.project_id}.#{@dataset.dataset_id}.github_puppetfile_usage`"
56
55
 
57
56
  data = @dataset.query(sql)
58
57
  end
@@ -1,3 +1,3 @@
1
1
  class Rangefinder
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-community-rangefinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Ford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-18 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet
@@ -48,11 +48,6 @@ description: |2
48
48
  Run this command with a space separated list of file paths in a module and it
49
49
  will infer what each file defines and then tell you what Forge modules use it.
50
50
 
51
- ******************************************************************************
52
- * Note that this is only useful by members of the Puppet Ecosystem team *
53
- * because it uses BigQuery data that's not available publicly. *
54
- ******************************************************************************
55
-
56
51
  Run `rangefinder --help` to get started.
57
52
  email: ben.ford@puppet.com
58
53
  executables:
@@ -89,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
84
  - !ruby/object:Gem::Version
90
85
  version: '0'
91
86
  requirements: []
92
- rubygems_version: 3.0.2
87
+ rubygems_version: 3.0.3
93
88
  signing_key:
94
89
  specification_version: 4
95
90
  summary: Predicts downstream impact of breaking file changes.