gitlab-cloud-connector 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -3
- data/CHANGELOG.md +1 -1
- data/CONTRIBUTING.md +41 -0
- data/LICENSE +28 -0
- data/Makefile +33 -0
- data/README.md +16 -218
- data/Rakefile +1 -5
- data/config/config/add_ons/duo_enterprise.yml +2 -0
- data/config/config/add_ons/duo_pro.yml +2 -0
- data/config/config/backend_services/ai_gateway.yml +5 -0
- data/config/config/backend_services/duo_workflow_service.yml +5 -0
- data/config/config/license_types/premium.yml +2 -0
- data/config/config/license_types/ultimate.yml +2 -0
- data/config/config/unit_primitives/code_suggestions.yml +19 -0
- data/config/{cloud_connector/backend_services/ai_gateway → config}/unit_primitives/documentation_search.yml +11 -11
- data/config/{cloud_connector/backend_services/ai_gateway → config}/unit_primitives/duo_chat.yml +11 -11
- data/config/config/unit_primitives/explain_vulnerability.yml +19 -0
- data/config/config/unit_primitives/generate_commit_message.yml +19 -0
- data/config/config/unit_primitives/glab_ask_git_command.yml +19 -0
- data/config/config/unit_primitives/resolve_vulnerability.yml +19 -0
- data/config/config/unit_primitives/summarize_comments.yml +19 -0
- data/config/config/unit_primitives/troubleshoot_job.yml +19 -0
- data/lib/gitlab/cloud_connector/{backend_service.rb → version.rb} +1 -3
- metadata +40 -58
- data/.idea/.gitignore +0 -8
- data/.idea/gitlab-cloud-connector.iml +0 -127
- data/.idea/inspectionProfiles/Project_Default.xml +0 -9
- data/.idea/misc.xml +0 -4
- data/.idea/modules.xml +0 -8
- data/.idea/vcs.xml +0 -7
- data/Dangerfile +0 -5
- data/config/cloud_connector/backend_services/ai_gateway/unit_primitives/code_suggestions.yml +0 -19
- data/lib/gitlab/cloud_connector/auth/json_web_token.rb +0 -82
- data/lib/gitlab/cloud_connector/base_group.rb +0 -39
- data/lib/gitlab/cloud_connector/configuration.rb +0 -24
- data/lib/gitlab/cloud_connector/deliverable.rb +0 -31
- data/lib/gitlab/cloud_connector/delivered_by.rb +0 -10
- data/lib/gitlab/cloud_connector/purchasable_decorator.rb +0 -59
- data/lib/gitlab/cloud_connector/token_issuer.rb +0 -44
- data/lib/gitlab/cloud_connector/unit_primitives.rb +0 -195
- data/lib/gitlab/cloud_connector.rb +0 -68
- data/lib/gitlab/popen.rb +0 -68
- data/lib/utils/parse_helper.rb +0 -15
- data/lib/utils/strong_memoize.rb +0 -145
- data/sig/gitlab/cloud_connector.rbs +0 -0
metadata
CHANGED
@@ -1,115 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-cloud-connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikola Milojevic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: gitlab-styles
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
19
|
+
version: 12.0.1
|
20
|
+
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 12.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 13.0.6
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rubocop-rails
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "<"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 2.21.2
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "<"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 2.21.2
|
40
|
+
version: 13.0.6
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
42
|
+
name: rspec
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
47
|
+
version: '3.8'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
description:
|
70
|
-
|
54
|
+
version: '3.8'
|
55
|
+
description: This gem provides common CloudConnector configuration and libraries for
|
56
|
+
GitLab projects.
|
71
57
|
email:
|
72
58
|
- nmilojevic@gitlab.com
|
73
59
|
executables: []
|
74
60
|
extensions: []
|
75
61
|
extra_rdoc_files: []
|
76
62
|
files:
|
77
|
-
- ".idea/.gitignore"
|
78
|
-
- ".idea/gitlab-cloud-connector.iml"
|
79
|
-
- ".idea/inspectionProfiles/Project_Default.xml"
|
80
|
-
- ".idea/misc.xml"
|
81
|
-
- ".idea/modules.xml"
|
82
|
-
- ".idea/vcs.xml"
|
83
63
|
- ".rspec"
|
84
64
|
- ".rubocop.yml"
|
85
65
|
- CHANGELOG.md
|
86
|
-
-
|
66
|
+
- CONTRIBUTING.md
|
67
|
+
- LICENSE
|
68
|
+
- Makefile
|
87
69
|
- README.md
|
88
70
|
- Rakefile
|
89
|
-
- config/
|
90
|
-
- config/
|
91
|
-
- config/
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
95
|
-
-
|
96
|
-
-
|
97
|
-
-
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
- lib/
|
105
|
-
|
106
|
-
|
107
|
-
|
71
|
+
- config/config/add_ons/duo_enterprise.yml
|
72
|
+
- config/config/add_ons/duo_pro.yml
|
73
|
+
- config/config/backend_services/ai_gateway.yml
|
74
|
+
- config/config/backend_services/duo_workflow_service.yml
|
75
|
+
- config/config/license_types/premium.yml
|
76
|
+
- config/config/license_types/ultimate.yml
|
77
|
+
- config/config/unit_primitives/code_suggestions.yml
|
78
|
+
- config/config/unit_primitives/documentation_search.yml
|
79
|
+
- config/config/unit_primitives/duo_chat.yml
|
80
|
+
- config/config/unit_primitives/explain_vulnerability.yml
|
81
|
+
- config/config/unit_primitives/generate_commit_message.yml
|
82
|
+
- config/config/unit_primitives/glab_ask_git_command.yml
|
83
|
+
- config/config/unit_primitives/resolve_vulnerability.yml
|
84
|
+
- config/config/unit_primitives/summarize_comments.yml
|
85
|
+
- config/config/unit_primitives/troubleshoot_job.yml
|
86
|
+
- lib/gitlab/cloud_connector/version.rb
|
87
|
+
homepage: https://gitlab.com/gitlab-org/cloud-connector/gitlab-cloud-connector
|
88
|
+
licenses:
|
89
|
+
- MIT
|
108
90
|
metadata:
|
109
91
|
allowed_push_host: https://rubygems.org
|
110
|
-
homepage_uri: https://gitlab.com
|
111
|
-
source_code_uri: https://gitlab.com/gitlab-org/
|
112
|
-
changelog_uri: https://gitlab.com/gitlab-org/
|
92
|
+
homepage_uri: https://gitlab.com/gitlab-org/cloud-connector/gitlab-cloud-connector
|
93
|
+
source_code_uri: https://gitlab.com/gitlab-org/cloud-connector/gitlab-cloud-connector
|
94
|
+
changelog_uri: https://gitlab.com/gitlab-org/cloud-connector/gitlab-cloud-connector/-/releases
|
113
95
|
post_install_message:
|
114
96
|
rdoc_options: []
|
115
97
|
require_paths:
|
@@ -128,5 +110,5 @@ requirements: []
|
|
128
110
|
rubygems_version: 3.4.19
|
129
111
|
signing_key:
|
130
112
|
specification_version: 4
|
131
|
-
summary: GitLab cloud connector project
|
113
|
+
summary: GitLab cloud connector project.
|
132
114
|
test_files: []
|
data/.idea/.gitignore
DELETED
@@ -1,127 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="FacetManager">
|
4
|
-
<facet type="RailsFacetType" name="Ruby on Rails">
|
5
|
-
<configuration>
|
6
|
-
<RAILS_FACET_CONFIG_ID NAME="RAILS_FACET_SUPPORT_REMOVED" VALUE="false" />
|
7
|
-
<RAILS_FACET_CONFIG_ID NAME="RAILS_TESTS_SOURCES_PATCHED" VALUE="true" />
|
8
|
-
<RAILS_FACET_CONFIG_ID NAME="RAILS_FACET_APPLICATION_ROOT" VALUE="$MODULE_DIR$" />
|
9
|
-
</configuration>
|
10
|
-
</facet>
|
11
|
-
</component>
|
12
|
-
<component name="ModuleRunConfigurationManager">
|
13
|
-
<shared />
|
14
|
-
</component>
|
15
|
-
<component name="NewModuleRootManager">
|
16
|
-
<content url="file://$MODULE_DIR$">
|
17
|
-
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
18
|
-
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
19
|
-
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
20
|
-
<excludeFolder url="file://$MODULE_DIR$/.bundle" />
|
21
|
-
<excludeFolder url="file://$MODULE_DIR$/public/packs" />
|
22
|
-
<excludeFolder url="file://$MODULE_DIR$/vendor/bundle" />
|
23
|
-
<excludeFolder url="file://$MODULE_DIR$/vendor/cache" />
|
24
|
-
<excludeFolder url="file://$MODULE_DIR$/log" />
|
25
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
26
|
-
<excludeFolder url="file://$MODULE_DIR$/public/system" />
|
27
|
-
<excludeFolder url="file://$MODULE_DIR$/components" />
|
28
|
-
</content>
|
29
|
-
<orderEntry type="inheritedJdk" />
|
30
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
31
|
-
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, asdf: 3.2.1) [gem]" level="application" />
|
32
|
-
<orderEntry type="library" scope="PROVIDED" name="crass (v1.0.6, asdf: 3.2.1) [gem]" level="application" />
|
33
|
-
<orderEntry type="library" scope="PROVIDED" name="mail (v2.8.1, asdf: 3.2.1) [gem]" level="application" />
|
34
|
-
<orderEntry type="library" scope="PROVIDED" name="net-pop (v0.1.2, asdf: 3.2.1) [gem]" level="application" />
|
35
|
-
<orderEntry type="library" scope="PROVIDED" name="rack-test (v2.1.0, asdf: 3.2.1) [gem]" level="application" />
|
36
|
-
<orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.6.0, asdf: 3.2.1) [gem]" level="application" />
|
37
|
-
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, asdf: 3.2.1) [gem]" level="application" />
|
38
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-rails (v2.18.0, asdf: 3.2.1) [gem]" level="application" />
|
39
|
-
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.6, asdf: 3.2.1) [gem]" level="application" />
|
40
|
-
<orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.5, asdf: 3.2.1) [gem]" level="application" />
|
41
|
-
</component>
|
42
|
-
<component name="RModuleSettingsStorage">
|
43
|
-
<LOAD_PATH number="0" />
|
44
|
-
<I18N_FOLDERS number="1" string0="$MODULE_DIR$/config/locales" />
|
45
|
-
</component>
|
46
|
-
<component name="RailsGeneratorsCache">
|
47
|
-
<option name="generators">
|
48
|
-
<list>
|
49
|
-
<option value="active_record:migration" />
|
50
|
-
<option value="active_record:model" />
|
51
|
-
<option value="active_record:observer" />
|
52
|
-
<option value="active_record:session_migration" />
|
53
|
-
<option value="controller" />
|
54
|
-
<option value="erb:controller" />
|
55
|
-
<option value="erb:mailer" />
|
56
|
-
<option value="erb:scaffold" />
|
57
|
-
<option value="generator" />
|
58
|
-
<option value="helper" />
|
59
|
-
<option value="integration_test" />
|
60
|
-
<option value="mailer" />
|
61
|
-
<option value="metal" />
|
62
|
-
<option value="migration" />
|
63
|
-
<option value="model" />
|
64
|
-
<option value="model_subclass" />
|
65
|
-
<option value="observer" />
|
66
|
-
<option value="performance_test" />
|
67
|
-
<option value="plugin" />
|
68
|
-
<option value="resource" />
|
69
|
-
<option value="scaffold" />
|
70
|
-
<option value="scaffold_controller" />
|
71
|
-
<option value="session_migration" />
|
72
|
-
<option value="stylesheets" />
|
73
|
-
<option value="test_unit:controller" />
|
74
|
-
<option value="test_unit:helper" />
|
75
|
-
<option value="test_unit:integration" />
|
76
|
-
<option value="test_unit:mailer" />
|
77
|
-
<option value="test_unit:model" />
|
78
|
-
<option value="test_unit:observer" />
|
79
|
-
<option value="test_unit:performance" />
|
80
|
-
<option value="test_unit:plugin" />
|
81
|
-
<option value="test_unit:scaffold" />
|
82
|
-
</list>
|
83
|
-
</option>
|
84
|
-
<option name="myGenerators">
|
85
|
-
<list>
|
86
|
-
<option value="active_record:migration" />
|
87
|
-
<option value="active_record:model" />
|
88
|
-
<option value="active_record:observer" />
|
89
|
-
<option value="active_record:session_migration" />
|
90
|
-
<option value="controller" />
|
91
|
-
<option value="erb:controller" />
|
92
|
-
<option value="erb:mailer" />
|
93
|
-
<option value="erb:scaffold" />
|
94
|
-
<option value="generator" />
|
95
|
-
<option value="helper" />
|
96
|
-
<option value="integration_test" />
|
97
|
-
<option value="mailer" />
|
98
|
-
<option value="metal" />
|
99
|
-
<option value="migration" />
|
100
|
-
<option value="model" />
|
101
|
-
<option value="model_subclass" />
|
102
|
-
<option value="observer" />
|
103
|
-
<option value="performance_test" />
|
104
|
-
<option value="plugin" />
|
105
|
-
<option value="resource" />
|
106
|
-
<option value="scaffold" />
|
107
|
-
<option value="scaffold_controller" />
|
108
|
-
<option value="session_migration" />
|
109
|
-
<option value="stylesheets" />
|
110
|
-
<option value="test_unit:controller" />
|
111
|
-
<option value="test_unit:helper" />
|
112
|
-
<option value="test_unit:integration" />
|
113
|
-
<option value="test_unit:mailer" />
|
114
|
-
<option value="test_unit:model" />
|
115
|
-
<option value="test_unit:observer" />
|
116
|
-
<option value="test_unit:performance" />
|
117
|
-
<option value="test_unit:plugin" />
|
118
|
-
<option value="test_unit:scaffold" />
|
119
|
-
</list>
|
120
|
-
</option>
|
121
|
-
</component>
|
122
|
-
<component name="RakeTasksCache">
|
123
|
-
<option name="myRootTask">
|
124
|
-
<RakeTaskImpl id="rake" />
|
125
|
-
</option>
|
126
|
-
</component>
|
127
|
-
</module>
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<component name="InspectionProjectProfileManager">
|
2
|
-
<profile version="1.0">
|
3
|
-
<option name="myName" value="Project Default" />
|
4
|
-
<inspection_tool class="Rubocop" enabled="true" level="WARNING" enabled_by_default="true">
|
5
|
-
<option name="myUseStandardGemIfPossible" value="true" />
|
6
|
-
<option name="myRunRubocopOnSave" value="true" />
|
7
|
-
</inspection_tool>
|
8
|
-
</profile>
|
9
|
-
</component>
|
data/.idea/misc.xml
DELETED
data/.idea/modules.xml
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="ProjectModuleManager">
|
4
|
-
<modules>
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/gitlab-cloud-connector.iml" filepath="$PROJECT_DIR$/.idea/gitlab-cloud-connector.iml" />
|
6
|
-
</modules>
|
7
|
-
</component>
|
8
|
-
</project>
|
data/.idea/vcs.xml
DELETED
data/Dangerfile
DELETED
data/config/cloud_connector/backend_services/ai_gateway/unit_primitives/code_suggestions.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: code_suggestions
|
3
|
-
description:
|
4
|
-
backend: 'gitlab-ai-gateway'
|
5
|
-
cut_off_date: 2024-02-15 00:00:00 UTC
|
6
|
-
min_gitlab_version_for_free_access:
|
7
|
-
min_gitlab_version: '16.8'
|
8
|
-
min_backend_version:
|
9
|
-
delivered_by:
|
10
|
-
- code_suggestions
|
11
|
-
bundled_with:
|
12
|
-
- duo_pro
|
13
|
-
- duo_enterprise
|
14
|
-
introduced_by_url:
|
15
|
-
group: group::code suggestions
|
16
|
-
feature_category: code_suggestions
|
17
|
-
gitlab_realms:
|
18
|
-
- saas
|
19
|
-
- self-managed
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "active_support"
|
4
|
-
require "active_support/all"
|
5
|
-
|
6
|
-
module Gitlab
|
7
|
-
module CloudConnector
|
8
|
-
module Auth
|
9
|
-
class JsonWebToken
|
10
|
-
NOT_BEFORE_TIME = 5.seconds.to_i.freeze
|
11
|
-
DEFAULT_EXPIRES_IN = 3.days.to_i.freeze
|
12
|
-
NoSigningKeyError = Class.new(StandardError)
|
13
|
-
|
14
|
-
attr_reader :expires_at, :scopes
|
15
|
-
|
16
|
-
def initialize(audience:, subject:, scopes:, expires_at: nil, extra_claims: nil, gitlab_realm: nil)
|
17
|
-
@id = SecureRandom.uuid
|
18
|
-
@audience = audience
|
19
|
-
@subject = subject
|
20
|
-
@scopes = Array.wrap(scopes)
|
21
|
-
@issuer = issuer
|
22
|
-
@issued_at = Time.current.to_i
|
23
|
-
@not_before = @issued_at - NOT_BEFORE_TIME
|
24
|
-
@expires_at = expires_at || (@issued_at + expires_in)
|
25
|
-
@extra_claims = extra_claims
|
26
|
-
@gitlab_realm = gitlab_realm || ::Gitlab::CloudConnector.gitlab_realm
|
27
|
-
end
|
28
|
-
|
29
|
-
def encode
|
30
|
-
headers = { typ: 'JWT' }
|
31
|
-
|
32
|
-
JWT.encode(payload, key, 'RS256', headers)
|
33
|
-
end
|
34
|
-
|
35
|
-
def payload
|
36
|
-
reserved_claims = {
|
37
|
-
jti: @id,
|
38
|
-
aud: @audience,
|
39
|
-
sub: @subject,
|
40
|
-
iss: @issuer,
|
41
|
-
iat: @issued_at,
|
42
|
-
nbf: @not_before,
|
43
|
-
exp: @expires_at
|
44
|
-
}
|
45
|
-
|
46
|
-
custom_claims = {
|
47
|
-
gitlab_realm: @gitlab_realm,
|
48
|
-
scopes: @scopes,
|
49
|
-
extra_claims: @extra_claims
|
50
|
-
}
|
51
|
-
|
52
|
-
reserved_claims.merge(custom_claims)
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def expires_in
|
58
|
-
::Gitlab::CloudConnector.token_expires_in || DEFAULT_EXPIRES_IN
|
59
|
-
end
|
60
|
-
|
61
|
-
def issuer
|
62
|
-
issuer = Gitlab::CloudConnector.token_issuer
|
63
|
-
|
64
|
-
if issuer.is_a?(Proc)
|
65
|
-
p "lambda?"
|
66
|
-
issuer.call
|
67
|
-
else
|
68
|
-
issuer
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def key
|
73
|
-
key_data = Settings.value(:jwt_signing_key)
|
74
|
-
|
75
|
-
raise NoSigningKeyError unless key_data
|
76
|
-
|
77
|
-
OpenSSL::PKey::RSA.new(key_data)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'token_issuer'
|
4
|
-
|
5
|
-
module Gitlab
|
6
|
-
module CloudConnector
|
7
|
-
class BaseGroup
|
8
|
-
include TokenIssuer
|
9
|
-
|
10
|
-
attr_reader :name, :unit_primitives
|
11
|
-
|
12
|
-
def initialize(name, unit_primitives)
|
13
|
-
@name = name
|
14
|
-
@unit_primitives = unit_primitives
|
15
|
-
end
|
16
|
-
|
17
|
-
def cut_off_date
|
18
|
-
unit_primitives.values.map(&:cut_off_date).compact.max
|
19
|
-
end
|
20
|
-
|
21
|
-
def bundled_with
|
22
|
-
unit_primitives.values.flat_map(&:bundled_with).uniq
|
23
|
-
end
|
24
|
-
alias :add_ons :bundled_with
|
25
|
-
|
26
|
-
def feature_categories
|
27
|
-
unit_primitives.values.map(&:feature_category).uniq
|
28
|
-
end
|
29
|
-
|
30
|
-
def min_gitlab_version
|
31
|
-
unit_primitives.values.flat_map(&:min_gitlab_version).compact.min
|
32
|
-
end
|
33
|
-
|
34
|
-
def min_gitlab_version_for_free_access
|
35
|
-
unit_primitives.values.flat_map(&:min_gitlab_version_for_free_access).compact.min
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'unit_primitives'
|
4
|
-
require_relative 'purchasable_decorator'
|
5
|
-
|
6
|
-
module Gitlab
|
7
|
-
module CloudConnector
|
8
|
-
class Configuration
|
9
|
-
attr_reader :purchasable_decorator_class
|
10
|
-
attr_accessor :token_issuer, :token_subject, :gitlab_version, :token_expires_in, :gitlab_realm
|
11
|
-
|
12
|
-
def purchasable_decorator_class=(purchasable_decorator_class)
|
13
|
-
raise ArgumentError, 'Must be a class inheriting from Gitlab::CloudConnector::PurchasableDecorator' unless
|
14
|
-
purchasable_decorator_class < Gitlab::CloudConnector::PurchasableDecorator
|
15
|
-
|
16
|
-
@purchasable_decorator_class = purchasable_decorator_class
|
17
|
-
end
|
18
|
-
|
19
|
-
def purchasable_decorator_class
|
20
|
-
@purchasable_decorator_class ||= Gitlab::CloudConnector::PurchasableDecorator
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Gitlab
|
4
|
-
module CloudConnector
|
5
|
-
module Deliverable
|
6
|
-
def delivered_by
|
7
|
-
# TODO add memoization
|
8
|
-
result = Hash.new{ |h, k| h[k] = [] }
|
9
|
-
|
10
|
-
unit_primitives.values.each do |unit_primitive|
|
11
|
-
unit_primitive.delivered_by.each do |delivered_by|
|
12
|
-
result[delivered_by.to_sym] << unit_primitive
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
result.each do |delivered_by, unit_primitives|
|
17
|
-
result[delivered_by] = build_delivered_by(delivered_by, unit_primitives.index_by(&:key))
|
18
|
-
end
|
19
|
-
|
20
|
-
result
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def build_delivered_by(name, unit_primitives)
|
26
|
-
delivered_by = Gitlab::CloudConnector::DeliveredBy.new(name, unit_primitives)
|
27
|
-
Gitlab::CloudConnector.configuration.purchasable_decorator_class.new(delivered_by)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../utils/strong_memoize'
|
4
|
-
require_relative '../../utils/parse_helper'
|
5
|
-
require "active_support"
|
6
|
-
require "active_support/core_ext/module/delegation"
|
7
|
-
|
8
|
-
module Gitlab
|
9
|
-
module CloudConnector
|
10
|
-
class PurchasableDecorator
|
11
|
-
include ::Utils::StrongMemoize
|
12
|
-
include ::Utils::ParseHelper
|
13
|
-
|
14
|
-
delegate_missing_to :unit_primitive_or_group
|
15
|
-
|
16
|
-
def initialize(unit_primitive_or_group)
|
17
|
-
@unit_primitive_or_group = unit_primitive_or_group
|
18
|
-
end
|
19
|
-
|
20
|
-
def available_for?(_resource)
|
21
|
-
raise 'Not Implemented'
|
22
|
-
end
|
23
|
-
|
24
|
-
def free_access?
|
25
|
-
!cut_off_date&.past?
|
26
|
-
end
|
27
|
-
|
28
|
-
def available?(resource, gitlab_version, gitlab_realm)
|
29
|
-
return false unless gitlab_realms.include?(gitlab_realm)
|
30
|
-
|
31
|
-
supported_gitlab_version?(gitlab_version) && (free_access? || available_for?(resource))
|
32
|
-
end
|
33
|
-
|
34
|
-
def supported_gitlab_version?(gitlab_version)
|
35
|
-
min_gitlab_version = calculate_min_gitlab_version
|
36
|
-
|
37
|
-
return true unless min_gitlab_version
|
38
|
-
return false unless gitlab_version
|
39
|
-
# Extract only major and minor version (ignore -ee, -pre and patch suffixes)
|
40
|
-
gitlab_version = parse_version(gitlab_version)
|
41
|
-
|
42
|
-
gitlab_version >= min_gitlab_version
|
43
|
-
end
|
44
|
-
|
45
|
-
def calculate_min_gitlab_version
|
46
|
-
if free_access?
|
47
|
-
min_gitlab_version_for_free_access
|
48
|
-
else
|
49
|
-
min_gitlab_version
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
attr_reader :unit_primitive_or_group
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'auth/json_web_token'
|
4
|
-
|
5
|
-
module Gitlab
|
6
|
-
module CloudConnector
|
7
|
-
###
|
8
|
-
# Provides access information for GitLab services offered under Cloud Connector.
|
9
|
-
#
|
10
|
-
# Self-Managed GitLab instances sync with this service to get access to Cloud Connector
|
11
|
-
# features based on billing status and other information.
|
12
|
-
module TokenIssuer
|
13
|
-
|
14
|
-
attr_reader :subject, :extra_claims
|
15
|
-
|
16
|
-
def access_token(resource, gitlab_version: nil, gitlab_realm: nil, subject: nil, extra_claims: {})
|
17
|
-
subject ||= ::Gitlab::CloudConnector.token_subject
|
18
|
-
gitlab_version ||= ::Gitlab::CloudConnector.gitlab_version
|
19
|
-
gitlab_realm ||= ::Gitlab::CloudConnector.gitlab_realm
|
20
|
-
|
21
|
-
allowed_scopes = allowed_scopes(resource, gitlab_version, gitlab_realm)
|
22
|
-
|
23
|
-
return nil if allowed_scopes.empty?
|
24
|
-
|
25
|
-
::Gitlab::CloudConnector::Auth::JsonWebToken.new(
|
26
|
-
audience: allowed_backends,
|
27
|
-
subject: subject,
|
28
|
-
scopes: allowed_scopes,
|
29
|
-
extra_claims: extra_claims
|
30
|
-
)
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def allowed_backends
|
36
|
-
unit_primitives.values.map{ |unit_primitive| "gitlab-#{unit_primitive.backend_service.dasherize}"}.uniq
|
37
|
-
end
|
38
|
-
|
39
|
-
def allowed_scopes(resource, gitlab_version, gitlab_realm)
|
40
|
-
unit_primitives.values.select{ |unit_primitive| unit_primitive.available?(resource, gitlab_version, gitlab_realm) }.map(&:name)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|