gitlab-cloud-connector 1.7.0 → 1.9.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 +4 -4
- data/config/add_ons/duo_core.yml +2 -0
- data/config/unit_primitives/categorize_duo_chat_question.yml +5 -3
- data/config/unit_primitives/complete_code.yml +1 -1
- data/config/unit_primitives/duo_chat.yml +1 -1
- data/config/unit_primitives/generate_code.yml +1 -1
- data/lib/gitlab/cloud_connector/configuration.rb +15 -4
- data/lib/gitlab/cloud_connector/data_model/overridable.rb +48 -0
- data/lib/gitlab/cloud_connector/data_model/yaml_data_loader.rb +13 -5
- data/lib/gitlab/cloud_connector/version.rb +1 -1
- metadata +4 -3
- data/config/add_ons/duo_nano.yml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 590617586593b273bb29603802241e367e8121a0cedf14c046932f005642a78b
|
4
|
+
data.tar.gz: 82bc2a0cce424a91902fe13d7ff5fe58bae4a92d67d05c9c4abaf7be0a659995
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 225ed047b89eaaabe116899476e261773bad0cdd7f36fe335e6a248ed22f07b88286bffbf9724e1e432a0eb6f111a195304e49747382b10a658f0dd44078ea1e
|
7
|
+
data.tar.gz: 89821a3abbe51094c4368f5add6d2fd35fe60e481492331a7a22b07d8a4353639f6b36a980dde3d24c868d385269715b82c56ffd654febaf208cf3a4f2ce84eb
|
@@ -1,10 +1,12 @@
|
|
1
1
|
---
|
2
2
|
name: categorize_duo_chat_question
|
3
|
-
description: This should not be an unit primitive.
|
3
|
+
description: This should not be an unit primitive. It is used to categorize user questions for the purpose of product analytics.
|
4
4
|
cut_off_date: 2024-10-17T00:00:00+00:00
|
5
|
-
group: group::
|
6
|
-
feature_category:
|
5
|
+
group: group::duo_chat
|
6
|
+
feature_category: duo_chat
|
7
|
+
documentation_url: https://docs.gitlab.com/development/ai_features/duo_chat/#product-analysis
|
7
8
|
backend_services:
|
8
9
|
- ai_gateway
|
9
10
|
add_ons:
|
11
|
+
- duo_pro
|
10
12
|
- duo_enterprise
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'data_model/yaml_data_loader'
|
4
|
-
require_relative 'data_model/abstract_data_loader'
|
5
|
-
|
6
3
|
module Gitlab
|
7
4
|
module CloudConnector
|
8
5
|
module Configuration
|
9
6
|
DEFAULT_DATA_LOADER_CLASS = Gitlab::CloudConnector::DataModel::YamlDataLoader
|
10
7
|
INVALID_LOADER_MESSAGE = "Data loader must inherit from Gitlab::CloudConnector::DataModel::AbstractDataLoader"
|
8
|
+
INVALID_CONFIG_MESSAGE = "Override configuration must be a Hash or respond to :call"
|
11
9
|
|
12
10
|
InvalidDataLoaderError = Class.new(StandardError)
|
11
|
+
InvalidConfigError = Class.new(StandardError)
|
13
12
|
|
14
13
|
class << self
|
15
14
|
attr_writer :config_dir, :memoize_data
|
15
|
+
attr_reader :override_config
|
16
16
|
|
17
17
|
def config_dir
|
18
18
|
@config_dir ||= File.expand_path("../../../config", __dir__).freeze
|
@@ -27,10 +27,15 @@ module Gitlab
|
|
27
27
|
@data_loader_class = klass
|
28
28
|
end
|
29
29
|
|
30
|
+
def override_config=(value)
|
31
|
+
validate_override_config!(value)
|
32
|
+
@override_config = value
|
33
|
+
end
|
34
|
+
|
30
35
|
def memoize_data?
|
31
36
|
return @memoize_data unless @memoize_data.nil?
|
32
37
|
|
33
|
-
|
38
|
+
data_loader_class == DEFAULT_DATA_LOADER_CLASS
|
34
39
|
end
|
35
40
|
|
36
41
|
def configure
|
@@ -44,6 +49,12 @@ module Gitlab
|
|
44
49
|
|
45
50
|
raise InvalidDataLoaderError, INVALID_LOADER_MESSAGE
|
46
51
|
end
|
52
|
+
|
53
|
+
def validate_override_config!(value)
|
54
|
+
return if value.nil? || value.is_a?(Hash) || value.respond_to?(:call)
|
55
|
+
|
56
|
+
raise InvalidConfigError, INVALID_CONFIG_MESSAGE
|
57
|
+
end
|
47
58
|
end
|
48
59
|
end
|
49
60
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gitlab
|
4
|
+
module CloudConnector
|
5
|
+
module DataModel
|
6
|
+
module Overridable
|
7
|
+
OverrideLoadError = Class.new(StandardError)
|
8
|
+
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
def apply_overrides(base_data, model_class)
|
12
|
+
overrides = fetch_relevant_overrides(base_data, model_class)
|
13
|
+
return base_data unless overrides
|
14
|
+
|
15
|
+
base_data.merge(overrides)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def fetch_relevant_overrides(base_data, model_class)
|
21
|
+
data = load_override_data
|
22
|
+
return unless data
|
23
|
+
|
24
|
+
model_name = base_data[:name]&.to_sym
|
25
|
+
return unless model_name
|
26
|
+
|
27
|
+
model_type = model_class.model_name.tableize.to_sym
|
28
|
+
data.dig(model_type, model_name)
|
29
|
+
end
|
30
|
+
|
31
|
+
def load_override_data
|
32
|
+
config = Gitlab::CloudConnector::Configuration.override_config
|
33
|
+
|
34
|
+
data = config.respond_to?(:call) ? config.call : config
|
35
|
+
unless data.is_a?(Hash) || data.nil?
|
36
|
+
raise OverrideLoadError, "Invalid override config type: #{data.class}. Expected Hash or nil."
|
37
|
+
end
|
38
|
+
|
39
|
+
data
|
40
|
+
rescue StandardError => e
|
41
|
+
raise e if e.is_a?(OverrideLoadError)
|
42
|
+
|
43
|
+
raise OverrideLoadError, "Failed to load override config: #{e.class}: #{e.message}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -2,11 +2,14 @@
|
|
2
2
|
|
3
3
|
require 'yaml'
|
4
4
|
require_relative 'abstract_data_loader'
|
5
|
+
require_relative 'overridable'
|
5
6
|
|
6
7
|
module Gitlab
|
7
8
|
module CloudConnector
|
8
9
|
module DataModel
|
9
10
|
class YamlDataLoader < AbstractDataLoader
|
11
|
+
include Overridable
|
12
|
+
|
10
13
|
def load!
|
11
14
|
Dir.glob(data_files_path).map { |file| load_model_from_file(file) }
|
12
15
|
end
|
@@ -18,16 +21,21 @@ module Gitlab
|
|
18
21
|
end
|
19
22
|
|
20
23
|
def load_model_from_file(file_path)
|
21
|
-
|
22
|
-
|
23
|
-
permitted_classes: [Time],
|
24
|
-
symbolize_names: true
|
25
|
-
).deep_symbolize_keys!
|
24
|
+
raw_data = load_yaml_file(file_path)
|
25
|
+
data = apply_overrides(raw_data, model_class)
|
26
26
|
|
27
27
|
model_class.new(**data)
|
28
28
|
rescue StandardError => e
|
29
29
|
raise "Error loading file #{file_path}: #{e.message}"
|
30
30
|
end
|
31
|
+
|
32
|
+
def load_yaml_file(file_path)
|
33
|
+
YAML.safe_load(
|
34
|
+
File.read(file_path),
|
35
|
+
permitted_classes: [Time],
|
36
|
+
symbolize_names: true
|
37
|
+
) || {}
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
33
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-cloud-connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikola Milojevic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -96,8 +96,8 @@ files:
|
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
98
|
- config/add_ons/duo_amazon_q.yml
|
99
|
+
- config/add_ons/duo_core.yml
|
99
100
|
- config/add_ons/duo_enterprise.yml
|
100
|
-
- config/add_ons/duo_nano.yml
|
101
101
|
- config/add_ons/duo_pro.yml
|
102
102
|
- config/backend_services/ai_gateway.yml
|
103
103
|
- config/backend_services/ai_gateway_agent.yml
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- lib/gitlab/cloud_connector/data_model/abstract_data_loader.rb
|
170
170
|
- lib/gitlab/cloud_connector/data_model/associations.rb
|
171
171
|
- lib/gitlab/cloud_connector/data_model/base.rb
|
172
|
+
- lib/gitlab/cloud_connector/data_model/overridable.rb
|
172
173
|
- lib/gitlab/cloud_connector/data_model/yaml_data_loader.rb
|
173
174
|
- lib/gitlab/cloud_connector/json_web_token.rb
|
174
175
|
- lib/gitlab/cloud_connector/version.rb
|
data/config/add_ons/duo_nano.yml
DELETED