Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: code reference API #1395

Merged
merged 34 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7fd896b
feat: code reference table
Ubisoft-potato Dec 25, 2024
4fb7d47
feat: code ref service
Ubisoft-potato Dec 25, 2024
38ec000
chore: proto all
Ubisoft-potato Jan 3, 2025
664bcbe
chore: rebase main
Ubisoft-potato Jan 3, 2025
d336741
chore: remove command
Ubisoft-potato Jan 6, 2025
4e74300
chore: lint
Ubisoft-potato Jan 6, 2025
7b4f02a
chore: update copyright
Ubisoft-potato Jan 6, 2025
0ddddf7
chore: coderef api doc
Ubisoft-potato Jan 7, 2025
487dd66
chore: proto descriptor
Ubisoft-potato Jan 7, 2025
36b6c88
chore: rebase main
Ubisoft-potato Jan 7, 2025
2f9bfef
chore: openapi gen
Ubisoft-potato Jan 7, 2025
222e975
chore: rebase main
Ubisoft-potato Jan 7, 2025
fb8f36e
chore: gateway coderef api
Ubisoft-potato Jan 9, 2025
eb6771b
chore: rebase main
Ubisoft-potato Jan 9, 2025
2d791d3
chore: update gateway service charts
Ubisoft-potato Jan 10, 2025
25ba54b
chore: code ref api
Ubisoft-potato Jan 10, 2025
006f201
chore: rebase main
Ubisoft-potato Jan 13, 2025
2fdac9d
refactor: rename code_reference
Ubisoft-potato Jan 13, 2025
3ebb640
chore: update atlas checksum
Ubisoft-potato Jan 13, 2025
b7b0dfa
refactor: update repository_type handling in SQL queries to use CASE …
Ubisoft-potato Jan 13, 2025
97078e3
chore: gofmt
Ubisoft-potato Jan 15, 2025
2014c4f
refactor: change repository_type column to TINYINT with comments for …
Ubisoft-potato Jan 17, 2025
f0591e6
refactor: remove redundant order validation
Ubisoft-potato Jan 17, 2025
d033ed5
chore: repo type
Ubisoft-potato Jan 17, 2025
641aec3
chore: rebase main
Ubisoft-potato Jan 17, 2025
508fc37
test: coderef
Ubisoft-potato Jan 17, 2025
315c322
test: enhance code reference tests with additional fields and API key…
Ubisoft-potato Jan 17, 2025
aed3d7b
feat: add code_reference table to e2e data deletion and update tests …
Ubisoft-potato Jan 17, 2025
5d7847f
chore: rebase main
Ubisoft-potato Jan 17, 2025
0abf984
feat: add sourceUrl and fileExtension fields to code reference API an…
Ubisoft-potato Jan 20, 2025
134fe03
chore: rename code ref test
Ubisoft-potato Jan 20, 2025
e43fac8
chore: update tests
Ubisoft-potato Jan 22, 2025
bf6b77c
chore: solve conflict
Ubisoft-potato Jan 22, 2025
030a3d8
chore: mock gen
Ubisoft-potato Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
441 changes: 441 additions & 0 deletions api-description/apidocs.swagger.yaml

Large diffs are not rendered by default.

498 changes: 498 additions & 0 deletions api-description/web-api.swagger.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions hack/delete-e2e-data-mysql/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
{table: "tag", targetField: "name"},
{table: "ops_progressive_rollout", targetField: "feature_id"},
{table: "flag_trigger", targetField: "description"},
{table: "code_reference", targetField: "feature_id"},
{table: "feature", targetField: "id"},
{table: "api_key", targetField: "name"},
}
Expand Down
2 changes: 2 additions & 0 deletions manifests/bucketeer/charts/api/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ spec:
value: "{{ .Values.env.accountService }}"
- name: BUCKETEER_API_PUSH_SERVICE
value: "{{ .Values.env.pushService }}"
- name: BUCKETEER_API_CODE_REF_SERVICE
value: "{{ .Values.env.codeRefService }}"
- name: BUCKETEER_API_PORT
value: "{{ .Values.env.port }}"
- name: BUCKETEER_API_METRICS_PORT
Expand Down
12 changes: 12 additions & 0 deletions manifests/bucketeer/charts/api/templates/envoy-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ data:
retry_policy:
retry_on: 5xx
num_retries: 3
- match:
headers:
- name: content-type
string_match:
exact: application/grpc
prefix: /bucketeer.coderef.CodeReferenceService
route:
cluster: web
timeout: 15s
retry_policy:
retry_on: 5xx
num_retries: 3
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
Expand Down
3 changes: 2 additions & 1 deletion manifests/bucketeer/charts/api/values.yaml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions manifests/bucketeer/charts/web/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ spec:
- name: envoy-batch-descriptor-secret
secret:
secretName: {{ template "web.fullname" . }}-batch
- name: envoy-code-reference-descriptor-secret
secret:
secretName: {{ template "web.fullname" . }}-code-reference
{{- if .Values.serviceAccount.annotations }}
serviceAccountName: {{ template "web.fullname" . }}
{{- end }}
Expand Down Expand Up @@ -171,6 +174,8 @@ spec:
value: "{{ .Values.env.webConsoleServicePort }}"
- name: BUCKETEER_WEB_DASHBOARD_SERVICE_PORT
value: "{{ .Values.env.dashboardServicePort }}"
- name: BUCKETEER_WEB_CODE_REFERENCE_SERVICE_PORT
value: "{{ .Values.env.coderefServicePort }}"
- name: BUCKETEER_WEB_ACCOUNT_SERVICE
value: "{{ .Values.env.accountService }}"
- name: BUCKETEER_WEB_AUTH_SERVICE
Expand All @@ -185,6 +190,8 @@ spec:
value: "{{ .Values.env.featureService }}"
- name: BUCKETEER_WEB_AUTO_OPS_SERVICE
value: "{{ .Values.env.autoOpsService }}"
- name: BUCKETEER_WEB_CODE_REFERENCE_SERVICE
value: "{{ .Values.env.coderefService }}"
- name: BUCKETEER_WEB_TIMEZONE
value: "{{ .Values.env.timezone }}"
- name: BUCKETEER_WEB_METRICS_PORT
Expand Down Expand Up @@ -315,6 +322,9 @@ spec:
- name: envoy-batch-descriptor-secret
mountPath: /usr/local/batch-secret
readOnly: true
- name: envoy-code-reference-descriptor-secret
mountPath: /usr/local/code-reference-secret
readOnly: true
- name: service-cert-secret
mountPath: /usr/local/certs/service
readOnly: true
Expand Down
65 changes: 65 additions & 0 deletions manifests/bucketeer/charts/web/templates/envoy-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,38 @@ data:
explicit_http_config:
http2_protocol_options: {}
ignore_health_on_host_removal: true
- name: coderef
type: strict_dns
connect_timeout: 5s
dns_lookup_family: V4_ONLY
lb_policy: {{ .Values.envoy.lbPolicy }}
load_assignment:
cluster_name: coderef
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: localhost
port_value: 9105
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
'@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
common_tls_context:
alpn_protocols:
- h2
tls_certificates:
- certificate_chain:
filename: /usr/local/certs/service/tls.crt
private_key:
filename: /usr/local/certs/service/tls.key
typed_extension_protocol_options:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicit_http_config:
http2_protocol_options: {}
ignore_health_on_host_removal: true
- name: web_console
type: strict_dns
connect_timeout: 5s
Expand Down Expand Up @@ -647,6 +679,14 @@ data:
retry_policy:
retry_on: 5xx
num_retries: 3
- match:
prefix: /bucketeer.coderef.CodeReferenceService
route:
cluster: coderef
timeout: 15s
retry_policy:
retry_on: 5xx
num_retries: 3
- match:
prefix: /
headers:
Expand Down Expand Up @@ -811,6 +851,15 @@ data:
- bucketeer.batch.BatchService
print_options:
always_print_primitive_fields: true
- name: envoy.filters.http.grpc_json_transcoder
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.grpc_json_transcoder.v3.GrpcJsonTranscoder
auto_mapping: true
proto_descriptor: /usr/local/code-reference-secret/code_reference_proto_descriptor.pb
services:
- bucketeer.coderef.CodeReferenceService
print_options:
always_print_primitive_fields: true
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
Expand Down Expand Up @@ -940,6 +989,14 @@ data:
retry_policy:
retry_on: 5xx
num_retries: 3
- match:
prefix: /bucketeer.coderef.CodeReferenceService
route:
cluster: coderef
timeout: 15s
retry_policy:
retry_on: 5xx
num_retries: 3
- match:
prefix: /v3
route:
Expand Down Expand Up @@ -1091,6 +1148,14 @@ data:
num_retries: 3
retry_on: 5xx
timeout: 15s
- match:
prefix: /bucketeer.coderef.CodeReferenceService
route:
cluster: coderef
timeout: 15s
retry_policy:
num_retries: 3
retry_on: 5xx
stat_prefix: egress_http
stream_idle_timeout: 300s
transport_socket:
Expand Down
13 changes: 13 additions & 0 deletions manifests/bucketeer/charts/web/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,19 @@ data:
---
apiVersion: v1
kind: Secret
metadata:
name: {{ template "web.fullname" . }}-code-reference
labels:
app: {{ template "web.name" . }}
chart: {{ template "web.chart" . }}
release: {{ template "web.fullname" . }}
heritage: {{ .Release.Service }}
type: Opaque
data:
code_reference_proto_descriptor.pb: {{ required "Envoy code reference descriptor is required" .Values.envoy.coderefDescriptor | quote }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ template "web.fullname" . }}-batch
labels:
Expand Down
7 changes: 5 additions & 2 deletions manifests/bucketeer/charts/web/values.yaml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions migration/mysql/20250122261735_add_code_ref_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE code_reference (
id varchar(255) NOT NULL,
feature_id VARCHAR(255) NOT NULL,
file_path VARCHAR(512) NOT NULL,
line_number INT NOT NULL,
code_snippet TEXT NOT NULL,
content_hash VARCHAR(64) NOT NULL,
aliases JSON,
repository_name VARCHAR(255) NOT NULL,
repository_owner VARCHAR(255) NOT NULL,
repository_type TINYINT NOT NULL COMMENT '0:UNSPECIFIED, 1:GITHUB, 2:GITLAB, 3:BITBUCKET, 4:CUSTOM',
repository_branch VARCHAR(255) NOT NULL,
commit_hash VARCHAR(40) NOT NULL,
environment_id VARCHAR(255) NOT NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
PRIMARY KEY (id),
INDEX idx_file_path (file_path),
CONSTRAINT foreign_code_references_feature FOREIGN KEY (feature_id, environment_id)
REFERENCES feature (id, environment_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
3 changes: 2 additions & 1 deletion migration/mysql/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:1gFvYJwtEn7dAVsV68Nzh0bXhPLPHh6OHmeV2U7vjQU=
h1:VXTmzqYh41HnDCRZyYb9OvaSQx2m1+GLavQcpqgGCjQ=
20240626022133_initialization.sql h1:u9qmPkwWX7PN92qEcDDfR92lrMpwadQSMxUJgv6LjQ0=
20240708065726_update_audit_log_table.sql h1:k7gK8Njv1yHMsYXAQtSgMaSbXy4lxyZ9MPzbJyMyyoM=
20240815043128_update_auto_ops_rule_table.sql h1:6ib+XfS1uu9AUO3qESvkpUfOu3qUsLwHm9KHcrGEz0E=
Expand All @@ -23,3 +23,4 @@ h1:1gFvYJwtEn7dAVsV68Nzh0bXhPLPHh6OHmeV2U7vjQU=
20250115040347_update_account_v2_table.sql h1:nEzBj41mgpXbQGgbNaIZ9thMqvtfamLO9NHISpEwMm8=
20250116054703_remove_environment_namespace_column.sql h1:UNiN/syYAs8nUQOkMw3RRvDQBQU/kKYv7B3XBhL6qPM=
20250116060049_update_goal_table.sql h1:zEhXMf2hntdk2Im9klR76vx6PEAh+cJwk3fKgm2gGPs=
20250122261735_add_code_ref_table.sql h1:ZqE6Ekn3PnhBFdpuczJYo5KjwTvcgeqSnkuLCNeHoCA=
4 changes: 4 additions & 0 deletions pkg/api/api/api_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
accountclient "github.com/bucketeer-io/bucketeer/pkg/account/client"
"github.com/bucketeer-io/bucketeer/pkg/cache"
cachev3 "github.com/bucketeer-io/bucketeer/pkg/cache/v3"
coderefclient "github.com/bucketeer-io/bucketeer/pkg/coderef/client"
featureclient "github.com/bucketeer-io/bucketeer/pkg/feature/client"
featuredomain "github.com/bucketeer-io/bucketeer/pkg/feature/domain"
"github.com/bucketeer-io/bucketeer/pkg/log"
Expand Down Expand Up @@ -142,6 +143,7 @@ type grpcGatewayService struct {
featureClient featureclient.Client
accountClient accountclient.Client
pushClient pushclient.Client
codeRefClient coderefclient.Client
goalPublisher publisher.Publisher
evaluationPublisher publisher.Publisher
userPublisher publisher.Publisher
Expand All @@ -157,6 +159,7 @@ func NewGrpcGatewayService(
featureClient featureclient.Client,
accountClient accountclient.Client,
pushClient pushclient.Client,
codeRefClient coderefclient.Client,
gp publisher.Publisher,
ep publisher.Publisher,
up publisher.Publisher,
Expand All @@ -174,6 +177,7 @@ func NewGrpcGatewayService(
featureClient: featureClient,
accountClient: accountClient,
pushClient: pushClient,
codeRefClient: codeRefClient,
goalPublisher: gp,
evaluationPublisher: ep,
userPublisher: up,
Expand Down
4 changes: 3 additions & 1 deletion pkg/api/api/api_grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
accountclientmock "github.com/bucketeer-io/bucketeer/pkg/account/client/mock"
"github.com/bucketeer-io/bucketeer/pkg/cache"
cachev3mock "github.com/bucketeer-io/bucketeer/pkg/cache/v3/mock"
coderefclientmock "github.com/bucketeer-io/bucketeer/pkg/coderef/client/mock"
featureclientmock "github.com/bucketeer-io/bucketeer/pkg/feature/client/mock"
"github.com/bucketeer-io/bucketeer/pkg/log"
"github.com/bucketeer-io/bucketeer/pkg/metrics"
Expand Down Expand Up @@ -93,7 +94,7 @@ func TestWithLogger(t *testing.T) {

func TestNewGrpcGatewayService(t *testing.T) {
t.Parallel()
g := NewGrpcGatewayService(nil, nil, nil, nil, nil, nil, nil)
g := NewGrpcGatewayService(nil, nil, nil, nil, nil, nil, nil, nil)
assert.IsType(t, &grpcGatewayService{}, g)
}

Expand Down Expand Up @@ -3959,6 +3960,7 @@ func newGrpcGatewayServiceWithMock(t *testing.T, mockController *gomock.Controll
featureClient: featureclientmock.NewMockClient(mockController),
accountClient: accountclientmock.NewMockClient(mockController),
pushClient: pushclientmock.NewMockClient(mockController),
codeRefClient: coderefclientmock.NewMockClient(mockController),
goalPublisher: publishermock.NewMockPublisher(mockController),
userPublisher: publishermock.NewMockPublisher(mockController),
evaluationPublisher: publishermock.NewMockPublisher(mockController),
Expand Down
Loading
Loading