kennel 1.47.0 → 1.48.0

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: a93854917f3c33bf9384862c47699e239045a9f1e85ad97e5622b1ea83e4ad13
4
- data.tar.gz: f570f7949f98046ca6bdf28e463ce50fcbd2759155805d8de8ab0ddc1cb21cf4
3
+ metadata.gz: 9283bb5d1301a656e0c1ca896ad6fb8bc91ecfedd621722ce9e3b6a50055e34e
4
+ data.tar.gz: fc1a556ee6e1a658da97b9a59792d6c7c789c834beae5cba39b8447a04818fe3
5
5
  SHA512:
6
- metadata.gz: 07154d3128ef64dc3b3d4e0aa7971e071e9498a6d4784bede12c5588cac6dcd7b535a6dce7dfce6bbbbee30fe5edae2dc5ec5fc9236a5de725339af3aefd9cf4
7
- data.tar.gz: ea83dad0e6d4b1a42877cf42958f410e29dc985677fc08ad61cbfce95804609df825a214c93c849b15cf7b18e3faf8278779ebf77c2b6cc46dc496cc8250d000
6
+ metadata.gz: ecc7e11d744f0a87941759927ef1e8d79b3b9ebccaf759c8c15c43ff7d7ef8524d38b4b488035d647a67b0841392f17c1c197cadf86d511ac72a2e118ba3d589
7
+ data.tar.gz: df0c1b18c9f82a8bd50f717f84f63d80a33aec84668bcbde144ab944359b0bee65295bd712d2457da9453ff2fdb07d8d16721baed947afb88d088f575cb7ab4a
@@ -19,7 +19,6 @@ require "kennel/models/base"
19
19
 
20
20
  # parts
21
21
  require "kennel/models/monitor"
22
- require "kennel/models/dash"
23
22
  require "kennel/models/dashboard"
24
23
 
25
24
  # settings
@@ -75,10 +75,6 @@ module Kennel
75
75
  actual.each do |a|
76
76
  id = a.fetch(:id)
77
77
  e = matching_expected(a)
78
-
79
- # check correct class, since we will have multiple actuals for each flavor (dash/screen/dashboard)
80
- next if e && e.class.api_resource != a[:api_resource]
81
-
82
78
  if e && @expected.delete(e)
83
79
  fill_details(a, cache) if e.class::API_LIST_INCOMPLETE
84
80
  diff = e.diff(a)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.47.0"
3
+ VERSION = "1.48.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.47.0
4
+ version: 1.48.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-16 00:00:00.000000000 Z
11
+ date: 2019-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -65,7 +65,6 @@ files:
65
65
  - lib/kennel/github_reporter.rb
66
66
  - lib/kennel/importer.rb
67
67
  - lib/kennel/models/base.rb
68
- - lib/kennel/models/dash.rb
69
68
  - lib/kennel/models/dashboard.rb
70
69
  - lib/kennel/models/monitor.rb
71
70
  - lib/kennel/models/project.rb
@@ -1,122 +0,0 @@
1
- # frozen_string_literal: true
2
- module Kennel
3
- module Models
4
- class Dash < Base
5
- include TemplateVariables
6
- include OptionalValidations
7
-
8
- API_LIST_INCOMPLETE = true
9
- SUPPORTED_GRAPH_OPTIONS = [:events, :markers, :precision].freeze
10
- READONLY_ATTRIBUTES = (Base::READONLY_ATTRIBUTES + [:resource, :created_by, :read_only, :new_id]).freeze
11
- DEFINITION_DEFAULTS = { autoscale: true }.freeze
12
- DASH_DEFAULTS = { template_variables: [] }.freeze
13
-
14
- settings :id, :title, :description, :graphs, :kennel_id, :definitions
15
-
16
- defaults(
17
- id: -> { nil },
18
- description: -> { "" },
19
- definitions: -> { [] },
20
- graphs: -> { [] },
21
- template_variables: -> { [] }
22
- )
23
-
24
- attr_reader :project
25
-
26
- def initialize(project, *args)
27
- @project = project
28
- super(*args)
29
- end
30
-
31
- def self.api_resource
32
- "dash"
33
- end
34
-
35
- def as_json
36
- return @json if @json
37
- @json = {
38
- id: id,
39
- title: "#{title}#{LOCK}",
40
- description: description,
41
- template_variables: render_template_variables,
42
- graphs: render_graphs
43
- }
44
-
45
- validate_json(@json) if validate
46
-
47
- @json
48
- end
49
-
50
- def self.normalize(expected, actual)
51
- super
52
-
53
- actual[:template_variables] ||= [] # is nil when it never had template variables
54
- ignore_default expected, actual, DASH_DEFAULTS
55
-
56
- graphs = actual[:graphs] || []
57
-
58
- graphs.each { |g| g[:definition].delete(:status) }
59
-
60
- ignore_request_defaults expected, actual, :graphs, :definition
61
-
62
- graphs.each_with_index do |a_g, i|
63
- a_d = a_g[:definition]
64
- e_d = expected.dig(:graphs, i, :definition) || {}
65
- ignore_default e_d, a_d, DEFINITION_DEFAULTS
66
- end
67
- end
68
-
69
- def url(id)
70
- Utils.path_to_url "/dash/#{id}"
71
- end
72
-
73
- private
74
-
75
- def validate_json(data)
76
- super
77
-
78
- validate_template_variables data, :graphs
79
-
80
- # check for fields that are unsettable
81
- data[:graphs].each do |g|
82
- if g[:definition].key?(:status)
83
- invalid! "remove definition status, it is unsettable and will always produce a diff"
84
- end
85
- end
86
- end
87
-
88
- def render_graphs
89
- definitions.map do |title, viz, type, queries, options = {}, ignored = nil|
90
- # validate inputs
91
- if ignored || (!title || !viz || !queries || !options.is_a?(Hash))
92
- raise ArgumentError, "Expected exactly 5 arguments for each definition (title, viz, type, queries, options)"
93
- end
94
- if options.each_key.any? { |k| !SUPPORTED_GRAPH_OPTIONS.include?(k) }
95
- raise ArgumentError, "Supported options are: #{SUPPORTED_GRAPH_OPTIONS.map(&:inspect).join(", ")}"
96
- end
97
-
98
- # build graph
99
- requests = Array(queries).map do |q|
100
- request = { q: q }
101
- request[:type] = type if type
102
- request
103
- end
104
-
105
- graph = { title: title, definition: { viz: viz, requests: requests } }
106
-
107
- # whitelist options that can be passed in, so we are flexible in the future
108
- SUPPORTED_GRAPH_OPTIONS.each do |key|
109
- graph[:definition][key] = options[key] if options[key]
110
- end
111
-
112
- # set default values so users do not have to pass them all the time
113
- if viz == "query_value"
114
- graph[:definition][:precision] ||= 2
115
- end
116
-
117
- graph
118
- end + graphs
119
- end
120
- end
121
- end
122
- end