gitlab-license 1.5.0 → 2.2.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
  SHA256:
3
- metadata.gz: 8e2099828f195390b3feec3baff3129202e17b50d2ef98e9db12a5627e149f9c
4
- data.tar.gz: 50d9e48ca255e0b4cf1e6155fc8eeffaaa25c8b1682c8c04f9910135bb16fa68
3
+ metadata.gz: b5090d0ea93ebe93a8ae432f94f6cafb36247511d024123140d010d241f2f133
4
+ data.tar.gz: 160af752702b9c305ecfe9d6405ec1dc4b1eff19e9bf3f89a8a7f79913013099
5
5
  SHA512:
6
- metadata.gz: 27d52f399c1640c873c34158daf4fc07a60c63df0bc1937e7559ffab7b1ebd3e2f590c98c47bde5e5855dc736d2b51efa35c1a4172a5dcde58fc7f50c8681b00
7
- data.tar.gz: c583ecccdbb22b0849e2101e4ddba8974ba078bf4f7ecda243d2ef529f5903ddce0e3a6c78376f77bf1b2933a6e5894b0da82bee5a05dcd00cad84f7cfb36304
6
+ metadata.gz: a6d58d7a27ff46ac88e7da9d92c7a3c5854777f8f49c7630a9b72b792b8ca75de3611893a5e9555fb45be94781d5bf760c10971e23f8916e00d0f19326a1e6ea
7
+ data.tar.gz: a5e5e07714819ab014a656953a99b5c8f32c4ed494c130a6b535f1810f967453aa0d71b38c28a00eb321bf0e28fe18f16bdb5fc953bd0e889025bd7ae558dc24
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  class License
3
- VERSION = '1.5.0'.freeze
3
+ VERSION = '2.2.0'.freeze
4
4
  end
5
5
  end
@@ -52,9 +52,9 @@ module Gitlab
52
52
  attr_reader :version
53
53
  attr_accessor :licensee, :starts_at, :expires_at, :notify_admins_at,
54
54
  :notify_users_at, :block_changes_at, :last_synced_at, :next_sync_at,
55
- :activated_at, :restrictions, :cloud_licensing_enabled, :auto_renew_enabled,
56
- :seat_reconciliation_enabled, :usage_ping_required_metrics_enabled,
57
- :generated_from_customers_dot
55
+ :activated_at, :restrictions, :cloud_licensing_enabled,
56
+ :offline_cloud_licensing_enabled, :auto_renew_enabled, :seat_reconciliation_enabled,
57
+ :operational_metrics_enabled, :generated_from_customers_dot
58
58
 
59
59
  alias_method :issued_at, :starts_at
60
60
  alias_method :issued_at=, :starts_at=
@@ -68,6 +68,8 @@ module Gitlab
68
68
  false
69
69
  elsif !starts_at || !starts_at.is_a?(Date)
70
70
  false
71
+ elsif !expires_at && !gl_team_license?
72
+ false
71
73
  elsif expires_at && !expires_at.is_a?(Date)
72
74
  false
73
75
  elsif notify_admins_at && !notify_admins_at.is_a?(Date)
@@ -84,6 +86,8 @@ module Gitlab
84
86
  false
85
87
  elsif restrictions && !restrictions.is_a?(Hash)
86
88
  false
89
+ elsif !cloud_licensing? && offline_cloud_licensing?
90
+ false
87
91
  else
88
92
  true
89
93
  end
@@ -137,6 +141,10 @@ module Gitlab
137
141
  cloud_licensing_enabled == true
138
142
  end
139
143
 
144
+ def offline_cloud_licensing?
145
+ offline_cloud_licensing_enabled == true
146
+ end
147
+
140
148
  def auto_renew?
141
149
  auto_renew_enabled == true
142
150
  end
@@ -145,14 +153,18 @@ module Gitlab
145
153
  seat_reconciliation_enabled == true
146
154
  end
147
155
 
148
- def usage_ping_required_metrics?
149
- usage_ping_required_metrics_enabled == true
156
+ def operational_metrics?
157
+ operational_metrics_enabled == true
150
158
  end
151
159
 
152
160
  def generated_from_customers_dot?
153
161
  generated_from_customers_dot == true
154
162
  end
155
163
 
164
+ def gl_team_license?
165
+ licensee['Company'].to_s.match?(/GitLab/i) && licensee['Email'].to_s.end_with?('@gitlab.com')
166
+ end
167
+
156
168
  def restricted?(key = nil)
157
169
  if key
158
170
  restricted? && restrictions.has_key?(key)
@@ -181,9 +193,10 @@ module Gitlab
181
193
  hash['activated_at'] = activated_at if activated?
182
194
 
183
195
  hash['cloud_licensing_enabled'] = cloud_licensing?
196
+ hash['offline_cloud_licensing_enabled'] = offline_cloud_licensing?
184
197
  hash['auto_renew_enabled'] = auto_renew?
185
198
  hash['seat_reconciliation_enabled'] = seat_reconciliation?
186
- hash['usage_ping_required_metrics_enabled'] = usage_ping_required_metrics?
199
+ hash['operational_metrics_enabled'] = operational_metrics?
187
200
 
188
201
  hash['generated_from_customers_dot'] = generated_from_customers_dot?
189
202
 
@@ -209,7 +222,7 @@ module Gitlab
209
222
  private
210
223
 
211
224
  def load_attributes(attributes)
212
- attributes = Hash[attributes.map { |k, v| [k.to_s, v] }]
225
+ attributes = attributes.transform_keys(&:to_s)
213
226
 
214
227
  version = attributes['version'] || 1
215
228
  raise ArgumentError, 'Version is too new' unless version && version == 1
@@ -230,9 +243,10 @@ module Gitlab
230
243
 
231
244
  %w[
232
245
  cloud_licensing_enabled
246
+ offline_cloud_licensing_enabled
233
247
  auto_renew_enabled
234
248
  seat_reconciliation_enabled
235
- usage_ping_required_metrics_enabled
249
+ operational_metrics_enabled
236
250
  generated_from_customers_dot
237
251
  ].each do |attr_name|
238
252
  public_send("#{attr_name}=", attributes[attr_name] == true)
@@ -240,7 +254,7 @@ module Gitlab
240
254
 
241
255
  restrictions = attributes['restrictions']
242
256
  if restrictions&.is_a?(Hash)
243
- restrictions = Hash[restrictions.map { |k, v| [k.to_sym, v] }]
257
+ restrictions = restrictions.transform_keys(&:to_sym)
244
258
  @restrictions = restrictions
245
259
  end
246
260
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-license
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douwe Maan
8
8
  - Stan Hu
9
9
  - Tyler Amos
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-05-06 00:00:00.000000000 Z
13
+ date: 2022-07-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -96,7 +96,7 @@ dependencies:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
98
  version: 1.38.1
99
- description:
99
+ description:
100
100
  email:
101
101
  - douwe@gitlab.com
102
102
  - stanhu@gitlab.com
@@ -125,7 +125,7 @@ homepage: https://dev.gitlab.org/gitlab/gitlab-license
125
125
  licenses:
126
126
  - MIT
127
127
  metadata: {}
128
- post_install_message:
128
+ post_install_message:
129
129
  rdoc_options: []
130
130
  require_paths:
131
131
  - lib
@@ -140,8 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.0.3
144
- signing_key:
143
+ rubygems_version: 3.2.33
144
+ signing_key:
145
145
  specification_version: 4
146
146
  summary: gitlab-license helps you generate, verify and enforce software licenses.
147
147
  test_files: []