gitlab-cloud-connector 1.2.0 → 1.3.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: '08c7db0c9954f05f5d443707897e0b65510833196d84fe0232b8ea683dbe54e4'
4
- data.tar.gz: 2fab7c9d5729454622896fe48211341e993e27a1e924921de2358c9b38cccb8c
3
+ metadata.gz: 7b483b10874986b71ec2c3b91a53dfd4fdcbd78be20144aeb63e26fe521df83b
4
+ data.tar.gz: 50eaf9263b69b27d22a689be8943967a998a10c9944e17d0ea1ecc25b9c1d79a
5
5
  SHA512:
6
- metadata.gz: bb6be93bbb1f0bd7e3808832618fc2f1532b06ab3cbab62cf9a05eac234f3ff0b2b0ac4dddeb2d5b57e5c7337d8d80d36167817bf418c0d0fbb3cb29c88b531f
7
- data.tar.gz: e32d689a3358fd29e8fd7431f9a815b9fd9adb8056e102d1f8efd4918cd907f00a8e3ca0f84cbc89691c0903f27cbc9d1c272b4c96a9d68511ca560a37fe418c
6
+ metadata.gz: d0efcf11ce2879783ceb5d3a6027c8ab7f2e35e6b97690db1e6c7e366f1116765a09ee047ee3396bb7e94718a14eab7e20e2733e267ee934e9dce3fb72df03ea
7
+ data.tar.gz: 3d5ae9797a346b4d92fecbf8e5c8acc8f4a2136745ec4b5e138e5cb896a38972b87144f3fddd91620cd83bc347f7b7953be59d8a4ddd48a7910359fa4b585510
data/README.md CHANGED
@@ -34,16 +34,18 @@ add_ons:
34
34
  - duo_enterprise
35
35
  ```
36
36
 
37
- ### Working with DataModels
37
+ ### Working with DataModel
38
38
 
39
- `DataModels` are the core data structures in the Cloud Connector. Each model inherits from `DataModel::Base`. The data is loaded from YAML files into memory at runtime, making it efficient for read operations and relationship traversal.
39
+ `DataModel` contains the core data structures in the Ruby library.
40
+ Each model inherits from `DataModel::Base`. The data is loaded from YAML files into memory at runtime, making it efficient
41
+ for read operations and relationship traversal.
40
42
 
41
43
  ```ruby
42
44
  require 'gitlab/cloud_connector'
43
45
 
44
46
  # Find unit primitive by name
45
47
  # Note: value should be a symbol (e.g., `:duo_chat` instead of `'duo_chat'`).
46
- duo_chat = Gitlab::CloudConnector::DataModels::UnitPrimitive.find_by_name(:duo_chat)
48
+ duo_chat = Gitlab::CloudConnector::DataModel::UnitPrimitive.find_by_name(:duo_chat)
47
49
  duo_chat.description
48
50
  duo_chat.cut_off_date
49
51
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ask_merge_request
3
- description: Ask questions about GitLab merge reuest.
3
+ description: Ask questions about GitLab merge request.
4
4
  cut_off_date: 2024-10-17T00:00:00+00:00
5
5
  group: group::duo_chat
6
6
  feature_category: duo_chat
@@ -44,7 +44,7 @@ module Gitlab
44
44
  def generate_services_config(gitlab_realm)
45
45
  services_config = {}
46
46
 
47
- DataModels::Service.each do |service|
47
+ DataModel::Service.each do |service|
48
48
  next if service.gitlab_realm && !service.gitlab_realm&.include?(gitlab_realm)
49
49
 
50
50
  service_config = generate_service_config(service.unit_primitives, service.basic_unit_primitive)
@@ -55,7 +55,7 @@ module Gitlab
55
55
  end
56
56
 
57
57
  # Generate a stand-alone service for each unit primitive (except the ones in the ignore list)
58
- unit_primitives = DataModels::UnitPrimitive.reject { |up| IGNORE_UNIT_PRIMITIVES.include?(up.name) }
58
+ unit_primitives = DataModel::UnitPrimitive.reject { |up| IGNORE_UNIT_PRIMITIVES.include?(up.name) }
59
59
  unit_primitives.each do |unit_primitive|
60
60
  next if services_config[unit_primitive.name]
61
61
 
@@ -23,7 +23,7 @@ module Gitlab
23
23
 
24
24
  def load_association_records(association_name)
25
25
  names = Array(self[association_name])
26
- association_class = Gitlab::CloudConnector::DataModels.const_get(association_name.to_s.classify)
26
+ association_class = Gitlab::CloudConnector::DataModel.const_get(association_name.to_s.classify)
27
27
  association_class.select { |record| names.include?(record.name.to_s) }
28
28
  end
29
29
  end
@@ -4,8 +4,10 @@ require_relative 'data_model/base'
4
4
 
5
5
  module Gitlab
6
6
  module CloudConnector
7
- module DataModels
8
- class UnitPrimitive < DataModel::Base
7
+ module DataModel
8
+ autoload(:YamlDataLoader, 'gitlab/cloud_connector/data_model/yaml_data_loader')
9
+
10
+ class UnitPrimitive < Base
9
11
  has_and_belongs_to_many :backend_services
10
12
  has_and_belongs_to_many :add_ons
11
13
  has_and_belongs_to_many :license_types
@@ -15,21 +17,21 @@ module Gitlab
15
17
  :min_gitlab_version_for_free_access, :name, :unit_primitive_issue_url
16
18
  end
17
19
 
18
- class Service < DataModel::Base
20
+ class Service < Base
19
21
  has_and_belongs_to_many :unit_primitives
20
22
 
21
23
  attr_reader :basic_unit_primitive, :description, :gitlab_realm, :name
22
24
  end
23
25
 
24
- class BackendService < DataModel::Base
26
+ class BackendService < Base
25
27
  attr_reader :description, :group, :jwt_aud, :name, :project_url
26
28
  end
27
29
 
28
- class LicenseType < DataModel::Base
30
+ class LicenseType < Base
29
31
  attr_reader :description, :name
30
32
  end
31
33
 
32
- class AddOn < DataModel::Base
34
+ class AddOn < Base
33
35
  attr_reader :description, :name
34
36
  end
35
37
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module CloudConnector
5
- VERSION = '1.2.0'
5
+ VERSION = '1.3.0'
6
6
  end
7
7
  end
@@ -7,7 +7,7 @@ module Gitlab
7
7
  module CloudConnector
8
8
  autoload(:JsonWebToken, 'gitlab/cloud_connector/json_web_token')
9
9
  autoload(:Configuration, 'gitlab/cloud_connector/configuration')
10
- autoload(:DataModels, 'gitlab/cloud_connector/data_models')
10
+ autoload(:DataModel, 'gitlab/cloud_connector/data_model')
11
11
  autoload(:AvailableServicesGenerator, 'gitlab/cloud_connector/available_services_generator')
12
12
  end
13
13
  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.2.0
4
+ version: 1.3.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-03-12 00:00:00.000000000 Z
11
+ date: 2025-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -163,12 +163,11 @@ files:
163
163
  - lib/gitlab/cloud_connector.rb
164
164
  - lib/gitlab/cloud_connector/available_services_generator.rb
165
165
  - lib/gitlab/cloud_connector/configuration.rb
166
+ - lib/gitlab/cloud_connector/data_model.rb
166
167
  - lib/gitlab/cloud_connector/data_model/abstract_data_loader.rb
167
168
  - lib/gitlab/cloud_connector/data_model/associations.rb
168
169
  - lib/gitlab/cloud_connector/data_model/base.rb
169
- - lib/gitlab/cloud_connector/data_model/data_loader.rb
170
170
  - lib/gitlab/cloud_connector/data_model/yaml_data_loader.rb
171
- - lib/gitlab/cloud_connector/data_models.rb
172
171
  - lib/gitlab/cloud_connector/json_web_token.rb
173
172
  - lib/gitlab/cloud_connector/version.rb
174
173
  homepage: https://gitlab.com/gitlab-org/cloud-connector/gitlab-cloud-connector
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'yaml'
4
-
5
- module Gitlab
6
- module CloudConnector
7
- module DataModel
8
- class DataLoader
9
- def initialize(model_class)
10
- @model_class = model_class
11
- end
12
-
13
- def load!
14
- Dir.glob(data_files_path).map { |file| load_model_from_file(file) }
15
- end
16
-
17
- private
18
-
19
- attr_reader :model_class
20
-
21
- def data_files_path
22
- File.join(CloudConnector::Configuration.config_dir, model_class.model_name.tableize, '*.yml')
23
- end
24
-
25
- def load_model_from_file(file_path)
26
- data = YAML.safe_load(
27
- File.read(file_path),
28
- permitted_classes: [Time],
29
- symbolize_names: true
30
- ).deep_symbolize_keys!
31
-
32
- model_class.new(**data)
33
- rescue StandardError => e
34
- raise "Error loading file #{file_path}: #{e.message}"
35
- end
36
- end
37
- end
38
- end
39
- end