gitlab-cloud-connector 0.1.0 → 0.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -3
  3. data/CONTRIBUTING.md +50 -0
  4. data/LICENSE +28 -0
  5. data/Makefile +33 -0
  6. data/README.md +11 -221
  7. data/Rakefile +1 -5
  8. data/config/add_ons/duo_enterprise.yml +2 -0
  9. data/config/add_ons/duo_pro.yml +2 -0
  10. data/config/backend_services/ai_gateway.yml +5 -0
  11. data/config/backend_services/duo_workflow_service.yml +5 -0
  12. data/config/backend_services/observability.yml +5 -0
  13. data/config/backend_services/security_gateway.yml +5 -0
  14. data/config/license_types/premium.yml +2 -0
  15. data/config/license_types/ultimate.yml +2 -0
  16. data/config/schemas/add_on_schema.json +15 -0
  17. data/config/schemas/backend_service_schema.json +26 -0
  18. data/config/schemas/license_type_schema.json +15 -0
  19. data/config/schemas/unit_primitive_schema.json +97 -0
  20. data/config/unit_primitives/ask_build.yml +15 -0
  21. data/config/unit_primitives/ask_commit.yml +15 -0
  22. data/config/unit_primitives/ask_epic.yml +15 -0
  23. data/config/unit_primitives/ask_issue.yml +15 -0
  24. data/config/unit_primitives/code_suggestions.yml +19 -0
  25. data/config/unit_primitives/complete_code.yml +19 -0
  26. data/config/unit_primitives/documentation_search.yml +19 -0
  27. data/config/unit_primitives/duo_chat.yml +19 -0
  28. data/config/unit_primitives/duo_workflow_execute_workflow.yml +13 -0
  29. data/config/unit_primitives/explain_code.yml +17 -0
  30. data/config/unit_primitives/explain_vulnerability.yml +17 -0
  31. data/config/unit_primitives/fix_code.yml +17 -0
  32. data/config/unit_primitives/generate_code.yml +19 -0
  33. data/config/unit_primitives/generate_commit_message.yml +17 -0
  34. data/config/unit_primitives/generate_issue_description.yml +15 -0
  35. data/config/unit_primitives/glab_ask_git_command.yml +17 -0
  36. data/config/unit_primitives/include_dependency_context.yml +15 -0
  37. data/config/unit_primitives/include_file_context.yml +17 -0
  38. data/config/unit_primitives/include_issue_context.yml +15 -0
  39. data/config/unit_primitives/include_merge_request_context.yml +15 -0
  40. data/config/unit_primitives/include_snippet_context.yml +17 -0
  41. data/config/unit_primitives/observability_all.yml +14 -0
  42. data/config/unit_primitives/refactor_code.yml +17 -0
  43. data/config/unit_primitives/resolve_vulnerability.yml +17 -0
  44. data/config/unit_primitives/security_scans.yml +13 -0
  45. data/config/unit_primitives/summarize_comments.yml +17 -0
  46. data/config/unit_primitives/summarize_review.yml +15 -0
  47. data/config/unit_primitives/troubleshoot_job.yml +17 -0
  48. data/config/unit_primitives/write_tests.yml +17 -0
  49. data/lib/cloud_connector.rb +10 -0
  50. data/lib/gitlab/cloud_connector/json_web_token.rb +59 -0
  51. data/lib/gitlab/cloud_connector/{backend_service.rb → version.rb} +1 -3
  52. metadata +85 -48
  53. data/.idea/.gitignore +0 -8
  54. data/.idea/gitlab-cloud-connector.iml +0 -127
  55. data/.idea/inspectionProfiles/Project_Default.xml +0 -9
  56. data/.idea/misc.xml +0 -4
  57. data/.idea/modules.xml +0 -8
  58. data/.idea/vcs.xml +0 -7
  59. data/CHANGELOG.md +0 -5
  60. data/Dangerfile +0 -5
  61. data/config/cloud_connector/backend_services/ai_gateway/unit_primitives/code_suggestions.yml +0 -19
  62. data/config/cloud_connector/backend_services/ai_gateway/unit_primitives/documentation_search.yml +0 -19
  63. data/config/cloud_connector/backend_services/ai_gateway/unit_primitives/duo_chat.yml +0 -19
  64. data/lib/gitlab/cloud_connector/auth/json_web_token.rb +0 -82
  65. data/lib/gitlab/cloud_connector/base_group.rb +0 -39
  66. data/lib/gitlab/cloud_connector/configuration.rb +0 -24
  67. data/lib/gitlab/cloud_connector/deliverable.rb +0 -31
  68. data/lib/gitlab/cloud_connector/delivered_by.rb +0 -10
  69. data/lib/gitlab/cloud_connector/purchasable_decorator.rb +0 -59
  70. data/lib/gitlab/cloud_connector/token_issuer.rb +0 -44
  71. data/lib/gitlab/cloud_connector/unit_primitives.rb +0 -195
  72. data/lib/gitlab/cloud_connector.rb +0 -68
  73. data/lib/gitlab/popen.rb +0 -68
  74. data/lib/utils/parse_helper.rb +0 -15
  75. data/lib/utils/strong_memoize.rb +0 -145
  76. data/sig/gitlab/cloud_connector.rbs +0 -0
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: code_suggestions
3
+ description: Helps you write code more efficiently by generating code and showing suggestions as you type.
4
+ cut_off_date: 2024-02-15T00:00:00+00:00
5
+ min_gitlab_version_for_free_access:
6
+ min_gitlab_version: '16.8'
7
+ unit_primitive_issue_url:
8
+ introduced_by_url:
9
+ documentation_url:
10
+ group: group::code suggestions
11
+ feature_category: code_suggestions
12
+ backend_services:
13
+ - ai_gateway
14
+ add_ons:
15
+ - duo_pro
16
+ - duo_enterprise
17
+ license_types:
18
+ - premium
19
+ - ultimate
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: complete_code
3
+ description: Helps you write code more efficiently by showing code suggestions as you type.
4
+ cut_off_date: 2024-02-15T00:00:00+00:00
5
+ min_gitlab_version_for_free_access:
6
+ min_gitlab_version: "16.8"
7
+ unit_primitive_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/497813
8
+ introduced_by_url: https://gitlab.com/gitlab-org/cloud-connector/gitlab-cloud-connector/-/merge_requests/46
9
+ documentation_url: https://docs.gitlab.com/ee/user/project/repository/code_suggestions/#code-completion
10
+ group: group::code suggestions
11
+ feature_category: code_suggestions
12
+ backend_services:
13
+ - ai_gateway
14
+ add_ons:
15
+ - duo_pro
16
+ - duo_enterprise
17
+ license_types:
18
+ - premium
19
+ - ultimate
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: documentation_search
3
+ description: Perform semantic search on gitlab documentations for a given query.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ min_gitlab_version_for_free_access: '16.8'
6
+ min_gitlab_version: '16.9'
7
+ unit_primitive_issue_url:
8
+ introduced_by_url:
9
+ documentation_url:
10
+ group: group::duo_chat
11
+ feature_category: duo_chat
12
+ backend_services:
13
+ - ai_gateway
14
+ add_ons:
15
+ - duo_pro
16
+ - duo_enterprise
17
+ license_types:
18
+ - premium
19
+ - ultimate
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: duo_chat
3
+ description: Ask various GitLab-related questions and tasks.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ min_gitlab_version_for_free_access: '16.8'
6
+ min_gitlab_version: '16.9'
7
+ unit_primitive_issue_url:
8
+ introduced_by_url:
9
+ documentation_url:
10
+ group: group::duo_chat
11
+ feature_category: duo_chat
12
+ backend_services:
13
+ - ai_gateway
14
+ add_ons:
15
+ - duo_pro
16
+ - duo_enterprise
17
+ license_types:
18
+ - premium
19
+ - ultimate
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: duo_workflow_execute_workflow
3
+ description: Automate tasks and help increase productivity in your development workflow by using GitLab Duo Workflow.
4
+ cut_off_date:
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::duo workflow
9
+ feature_category: duo_workflow
10
+ backend_services:
11
+ - duo_workflow_service
12
+ license_types:
13
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: explain_code
3
+ description: Explain function or method of the selected code.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::source code
9
+ feature_category: source_code_management
10
+ backend_services:
11
+ - ai_gateway
12
+ add_ons:
13
+ - duo_enterprise
14
+ - duo_pro
15
+ license_types:
16
+ - premium
17
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: explain_vulnerability
3
+ description: Explain a security vulnerability of the given CVE or code.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ min_gitlab_version_for_free_access: '17.2'
6
+ min_gitlab_version: '17.2'
7
+ unit_primitive_issue_url:
8
+ introduced_by_url:
9
+ documentation_url:
10
+ group: group::threat insights
11
+ feature_category: vulnerability_management
12
+ backend_services:
13
+ - ai_gateway
14
+ add_ons:
15
+ - duo_enterprise
16
+ license_types:
17
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: fix_code
3
+ description: Fix the selected code.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::duo_chat
9
+ feature_category: duo_chat
10
+ backend_services:
11
+ - ai_gateway
12
+ add_ons:
13
+ - duo_enterprise
14
+ - duo_pro
15
+ license_types:
16
+ - premium
17
+ - ultimate
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: generate_code
3
+ description: Helps you write code more efficiently by generating code as you type.
4
+ cut_off_date: 2024-02-15T00:00:00+00:00
5
+ min_gitlab_version_for_free_access:
6
+ min_gitlab_version: "16.8"
7
+ unit_primitive_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/497813
8
+ introduced_by_url: https://gitlab.com/gitlab-org/cloud-connector/gitlab-cloud-connector/-/merge_requests/46
9
+ documentation_url: https://docs.gitlab.com/ee/user/project/repository/code_suggestions/#code-generation
10
+ group: group::code suggestions
11
+ feature_category: code_suggestions
12
+ backend_services:
13
+ - ai_gateway
14
+ add_ons:
15
+ - duo_pro
16
+ - duo_enterprise
17
+ license_types:
18
+ - premium
19
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: generate_commit_message
3
+ description: Generate a Git commit message.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ min_gitlab_version_for_free_access: '17.2'
6
+ min_gitlab_version: '17.2'
7
+ unit_primitive_issue_url:
8
+ introduced_by_url:
9
+ documentation_url:
10
+ group: group::code review
11
+ feature_category: code_review_workflow
12
+ backend_services:
13
+ - ai_gateway
14
+ add_ons:
15
+ - duo_enterprise
16
+ license_types:
17
+ - ultimate
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: generate_issue_description
3
+ description: Generate an issue description.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::project management
9
+ feature_category: team_planning
10
+ backend_services:
11
+ - ai_gateway
12
+ add_ons:
13
+ - duo_enterprise
14
+ license_types:
15
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: glab_ask_git_command
3
+ description: Discover or recall git commands when and where you need them.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ min_gitlab_version_for_free_access: '17.2'
6
+ min_gitlab_version: '17.2'
7
+ unit_primitive_issue_url:
8
+ introduced_by_url:
9
+ documentation_url:
10
+ group: group::code review
11
+ feature_category: code_review_workflow
12
+ backend_services:
13
+ - ai_gateway
14
+ add_ons:
15
+ - duo_enterprise
16
+ license_types:
17
+ - ultimate
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: include_dependency_context
3
+ description: Include dependency context in the prompt.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::duo_chat
9
+ feature_category: duo_chat
10
+ backend_services:
11
+ - ai_gateway
12
+ add_ons:
13
+ - duo_enterprise
14
+ license_types:
15
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: include_file_context
3
+ description: Include file context in the prompt.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::duo_chat
9
+ feature_category: duo_chat
10
+ backend_services:
11
+ - ai_gateway
12
+ add_ons:
13
+ - duo_enterprise
14
+ - duo_pro
15
+ license_types:
16
+ - premium
17
+ - ultimate
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: include_issue_context
3
+ description: Include issue context in the prompt.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::duo_chat
9
+ feature_category: duo_chat
10
+ backend_services:
11
+ - ai_gateway
12
+ add_ons:
13
+ - duo_enterprise
14
+ license_types:
15
+ - ultimate
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: include_merge_request_context
3
+ description: Include merge request context in the prompt.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::duo_chat
9
+ feature_category: duo_chat
10
+ backend_services:
11
+ - ai_gateway
12
+ add_ons:
13
+ - duo_enterprise
14
+ license_types:
15
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: include_snippet_context
3
+ description: Include snippet context in the prompt.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::duo_chat
9
+ feature_category: duo_chat
10
+ backend_services:
11
+ - ai_gateway
12
+ add_ons:
13
+ - duo_enterprise
14
+ - duo_pro
15
+ license_types:
16
+ - premium
17
+ - ultimate
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: observability_all
3
+ description: Observability unit primitive.
4
+ cut_off_date:
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::platform insights
9
+ feature_category: observability
10
+ backend_services:
11
+ - observability
12
+ license_types:
13
+ - premium
14
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: refactor_code
3
+ description: Refactor the selected code.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::duo_chat
9
+ feature_category: duo_chat
10
+ backend_services:
11
+ - ai_gateway
12
+ add_ons:
13
+ - duo_enterprise
14
+ - duo_pro
15
+ license_types:
16
+ - premium
17
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: resolve_vulnerability
3
+ description: Write code that fixes the vulnerability.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ min_gitlab_version_for_free_access: '17.2'
6
+ min_gitlab_version: '17.2'
7
+ unit_primitive_issue_url:
8
+ introduced_by_url:
9
+ documentation_url:
10
+ group: group::threat insights
11
+ feature_category: vulnerability_management
12
+ backend_services:
13
+ - ai_gateway
14
+ add_ons:
15
+ - duo_enterprise
16
+ license_types:
17
+ - ultimate
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: security_scans
3
+ description: Used to check your source code for known vulnerabilities.
4
+ cut_off_date:
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::static analysis
9
+ feature_category: static_application_security_testing
10
+ backend_services:
11
+ - security_gateway
12
+ license_types:
13
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: summarize_comments
3
+ description: Summarize comments of the issue or epic.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ min_gitlab_version_for_free_access: '17.2'
6
+ min_gitlab_version: '17.2'
7
+ unit_primitive_issue_url:
8
+ introduced_by_url:
9
+ documentation_url:
10
+ group: group::project management
11
+ feature_category: team_planning
12
+ backend_services:
13
+ - ai_gateway
14
+ add_ons:
15
+ - duo_enterprise
16
+ license_types:
17
+ - ultimate
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: summarize_review
3
+ description: Summarize open reviews in merge requests.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::code review
9
+ feature_category: code_review_workflow
10
+ backend_services:
11
+ - ai_gateway
12
+ add_ons:
13
+ - duo_enterprise
14
+ license_types:
15
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: troubleshoot_job
3
+ description: Troubleshoot why a GitLab CI job failed and suggest a fix for it.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ min_gitlab_version_for_free_access: '17.2'
6
+ min_gitlab_version: '17.2'
7
+ unit_primitive_issue_url:
8
+ introduced_by_url:
9
+ documentation_url:
10
+ group: group::pipeline execution
11
+ feature_category: continuous_integration
12
+ backend_services:
13
+ - ai_gateway
14
+ add_ons:
15
+ - duo_enterprise
16
+ license_types:
17
+ - ultimate
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: write_tests
3
+ description: Write tests for the selected code.
4
+ cut_off_date: 2024-10-17T00:00:00+00:00
5
+ unit_primitive_issue_url:
6
+ introduced_by_url:
7
+ documentation_url:
8
+ group: group::duo_chat
9
+ feature_category: duo_chat
10
+ backend_services:
11
+ - ai_gateway
12
+ add_ons:
13
+ - duo_pro
14
+ - duo_enterprise
15
+ license_types:
16
+ - premium
17
+ - ultimate
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support'
4
+ require 'active_support/time'
5
+
6
+ module Gitlab
7
+ module CloudConnector
8
+ autoload(:JsonWebToken, 'gitlab/cloud_connector/json_web_token.rb')
9
+ end
10
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jwt'
4
+
5
+ module Gitlab
6
+ module CloudConnector
7
+ class JsonWebToken
8
+ SIGNING_ALGORITHM = 'RS256'
9
+ NOT_BEFORE_TIME_SEC = 5.seconds.to_i
10
+
11
+ attr_reader :issued_at, :expires_at
12
+
13
+ def initialize(issuer:, audience:, subject:, realm:, scopes:, ttl:, extra_claims: {})
14
+ @id = SecureRandom.uuid
15
+ @audience = audience
16
+ @subject = subject
17
+ @issuer = issuer
18
+ @issued_at = Time.current.to_i
19
+ @not_before = @issued_at - NOT_BEFORE_TIME_SEC
20
+ @expires_at = (@issued_at + ttl).to_i
21
+ @realm = realm
22
+ @scopes = scopes
23
+ @extra_claims = extra_claims
24
+ end
25
+
26
+ # jwk:
27
+ # The key (pair) as an instance of JWT::JWK.
28
+ #
29
+ # Returns a signed and Base64-encoded JSON Web Token string, to be
30
+ # written to the HTTP Authorization header field.
31
+ def encode(jwk)
32
+ header_fields = { typ: 'JWT', kid: jwk.kid }
33
+
34
+ JWT.encode(payload, jwk.signing_key, SIGNING_ALGORITHM, header_fields)
35
+ end
36
+
37
+ def payload
38
+ {
39
+ jti: @id,
40
+ aud: @audience,
41
+ sub: @subject,
42
+ iss: @issuer,
43
+ iat: @issued_at,
44
+ nbf: @not_before,
45
+ exp: @expires_at
46
+ }.merge(cloud_connector_claims)
47
+ end
48
+
49
+ private
50
+
51
+ def cloud_connector_claims
52
+ {
53
+ gitlab_realm: @realm,
54
+ scopes: @scopes
55
+ }.merge(@extra_claims)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module CloudConnector
5
- class BackendService < BaseGroup
6
- include Deliverable
7
- end
5
+ VERSION = '0.2.1'
8
6
  end
9
7
  end