gitlab-license 2.0.0 → 2.2.1
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 +4 -4
- data/README.md +15 -4
- data/lib/gitlab/license/version.rb +1 -1
- data/lib/gitlab/license.rb +23 -5
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e97f77de6b6b6e0b4910b0b892cc038dcf0c9103b65fc80a2fb27298a6be1140
|
4
|
+
data.tar.gz: 5c2a31361536c8a6eb4b87511ed41bdd889bf56239f28cdee43d2287c924b41e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4724c22299fcfd99440b0f653db6cf58e884bdf52335733136793e716aaa830cc2c25a393d4d809af46e5f098c02b3432afaa4407180b523f9e8f2f400f35dc
|
7
|
+
data.tar.gz: 99989f3f28e4fd3c04b866780c5565458620dd9bb15ba6407cd41f586dae70b198271f66f7cb40853b026d8a02ca68c4db1f2a32eac14eb1e919a7c20fb0b5a8
|
data/README.md
CHANGED
@@ -18,6 +18,17 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install gitlab-license
|
20
20
|
|
21
|
+
## Release
|
22
|
+
|
23
|
+
To release a new version of this gem, follow these steps:
|
24
|
+
|
25
|
+
1. Bump the `VERSION` constant in [`lib/gitlab/license/version.rb`](https://dev.gitlab.org/gitlab/gitlab-license/-/blob/master/lib/gitlab/license/version.rb#L3). This is typically merged as part of the feature MR.
|
26
|
+
1. Create a [new release](https://dev.gitlab.org/gitlab/gitlab-license/-/releases) in the project (e.g. `v2.1.0`). For more details on creating a new release, refer to the [documentation](https://dev.gitlab.org/help/user/project/releases/index.md#create-a-release).
|
27
|
+
1. [Build the gem](https://guides.rubygems.org/command-reference/#gem-build) to be published: `gem build gitlab-license.gemspec`
|
28
|
+
1. [Publish the gem](https://guides.rubygems.org/publishing) to Rubygems: `gem push gitlab-license-2.1.0.gem`
|
29
|
+
- Note you will need to be added as an owner in Rubygems in order to publish.
|
30
|
+
- Once this is published, the new version of the gem can be installed in other projects like CustomersDot or GitLab via bundler or using `gem install` directly.
|
31
|
+
|
21
32
|
## Usage
|
22
33
|
|
23
34
|
```ruby
|
@@ -48,17 +59,17 @@ license.licensee = {
|
|
48
59
|
"Email" => "douwe@gitlab.com"
|
49
60
|
}
|
50
61
|
|
51
|
-
# The date the license starts.
|
62
|
+
# The date the license starts.
|
52
63
|
# Required.
|
53
64
|
license.starts_at = Date.new(2015, 4, 24)
|
54
|
-
# The date the license expires.
|
65
|
+
# The date the license expires.
|
55
66
|
# Not required, to allow lifetime licenses.
|
56
67
|
license.expires_at = Date.new(2016, 4, 23)
|
57
68
|
|
58
69
|
# The below dates are hardcoded in the license so that you can play with the
|
59
70
|
# period after which there are "repercussions" to license expiration.
|
60
71
|
|
61
|
-
# The date admins will be notified about the license's pending expiration.
|
72
|
+
# The date admins will be notified about the license's pending expiration.
|
62
73
|
# Not required.
|
63
74
|
license.notify_admins_at = Date.new(2016, 4, 19)
|
64
75
|
|
@@ -66,7 +77,7 @@ license.notify_admins_at = Date.new(2016, 4, 19)
|
|
66
77
|
# Not required.
|
67
78
|
license.notify_users_at = Date.new(2016, 4, 23)
|
68
79
|
|
69
|
-
# The date "changes" like code pushes, issue or merge request creation
|
80
|
+
# The date "changes" like code pushes, issue or merge request creation
|
70
81
|
# or modification and project creation will be blocked.
|
71
82
|
# Not required.
|
72
83
|
license.block_changes_at = Date.new(2016, 5, 7)
|
data/lib/gitlab/license.rb
CHANGED
@@ -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,
|
56
|
-
:
|
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? && !jh_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
|
@@ -153,6 +161,14 @@ module Gitlab
|
|
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
|
+
|
168
|
+
def jh_team_license?
|
169
|
+
licensee['Company'].to_s.match?(/GitLab/i) && licensee['Email'].to_s.end_with?('@jihulab.com')
|
170
|
+
end
|
171
|
+
|
156
172
|
def restricted?(key = nil)
|
157
173
|
if key
|
158
174
|
restricted? && restrictions.has_key?(key)
|
@@ -181,6 +197,7 @@ module Gitlab
|
|
181
197
|
hash['activated_at'] = activated_at if activated?
|
182
198
|
|
183
199
|
hash['cloud_licensing_enabled'] = cloud_licensing?
|
200
|
+
hash['offline_cloud_licensing_enabled'] = offline_cloud_licensing?
|
184
201
|
hash['auto_renew_enabled'] = auto_renew?
|
185
202
|
hash['seat_reconciliation_enabled'] = seat_reconciliation?
|
186
203
|
hash['operational_metrics_enabled'] = operational_metrics?
|
@@ -209,7 +226,7 @@ module Gitlab
|
|
209
226
|
private
|
210
227
|
|
211
228
|
def load_attributes(attributes)
|
212
|
-
attributes =
|
229
|
+
attributes = attributes.transform_keys(&:to_s)
|
213
230
|
|
214
231
|
version = attributes['version'] || 1
|
215
232
|
raise ArgumentError, 'Version is too new' unless version && version == 1
|
@@ -230,6 +247,7 @@ module Gitlab
|
|
230
247
|
|
231
248
|
%w[
|
232
249
|
cloud_licensing_enabled
|
250
|
+
offline_cloud_licensing_enabled
|
233
251
|
auto_renew_enabled
|
234
252
|
seat_reconciliation_enabled
|
235
253
|
operational_metrics_enabled
|
@@ -240,7 +258,7 @@ module Gitlab
|
|
240
258
|
|
241
259
|
restrictions = attributes['restrictions']
|
242
260
|
if restrictions&.is_a?(Hash)
|
243
|
-
restrictions =
|
261
|
+
restrictions = restrictions.transform_keys(&:to_sym)
|
244
262
|
@restrictions = restrictions
|
245
263
|
end
|
246
264
|
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: 2.
|
4
|
+
version: 2.2.1
|
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:
|
13
|
+
date: 2022-08-04 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.
|
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: []
|