class Dropsonde::Metrics::Dependencies
Public Class Methods
cleanup()
click to toggle source
# File lib/dropsonde/metrics/dependencies.rb, line 83 def self.cleanup # run just after generating this metric end
description()
click to toggle source
# File lib/dropsonde/metrics/dependencies.rb, line 7 def self.description <<~EOF This group of metrics discovers dependencies between modules in all environments. It will omit dependencies on private modules. EOF end
example()
click to toggle source
# File lib/dropsonde/metrics/dependencies.rb, line 67 def self.example # this method is used to generate a table filled with randomized data to # make it easier to write data aggregation queries without access to the # actual private data that users have submitted. versions = ['>= 1.5.2', '>= 4.3.2', '>= 3.0.0 < 4.0.0', '>= 2.2.1 < 5.0.0', '>= 5.0.0 < 7.0.0', '>= 4.11.0'] [ :dependencies => Dropsonde::Cache.modules .sample(rand(250)) .map {|item| { :name => item, :version_requirement => versions.sample, }}, ] end
initialize_dependencies()
click to toggle source
# File lib/dropsonde/metrics/dependencies.rb, line 2 def self.initialize_dependencies # require any libraries needed here -- no need to load puppet; it's already initialized # All plugins are initialized before any metrics are generated. end
run()
click to toggle source
# File lib/dropsonde/metrics/dependencies.rb, line 45 def self.run # return an array of hashes representing the data to be merged into the combined checkin environments = Puppet.lookup(:environments).list.map{|e|e.name} modules = environments.map do |env| Puppet.lookup(:environments).get(env).modules end.flatten # we want only PUBLIC modules that PRIVATE modules depend on dependencies = modules.map do|mod| next unless mod.dependencies next if Dropsonde::Cache.forgeModule? mod # skip unless this is a private module # and return a list of all public modules it depends on mod.dependencies.select {|mod| Dropsonde::Cache.forgeModule? mod } end.flatten.compact [ { :dependencies => dependencies }, ] end
schema()
click to toggle source
# File lib/dropsonde/metrics/dependencies.rb, line 14 def self.schema # return an array of hashes of a partial schema to be merged into the complete schema # See https://cloud.google.com/bigquery/docs/schemas#specifying_a_json_schema_file [ { "fields": [ { "description": "The depended on module name", "mode": "NULLABLE", "name": "name", "type": "STRING" }, { "description": "The depended on module version requirement", "mode": "NULLABLE", "name": "version_requirement", "type": "STRING" } ], "description": "List of modules that private modules in all environments depend on.", "mode": "REPEATED", "name": "dependencies", "type": "RECORD" } ] end
setup()
click to toggle source
# File lib/dropsonde/metrics/dependencies.rb, line 41 def self.setup # run just before generating this metric end