Skip to content

Commit

Permalink
Merge branch 'main' into feat/update-experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
hvn2k1 committed Jan 30, 2025
2 parents 7fbb3d8 + 3b2ceac commit f9912f6
Show file tree
Hide file tree
Showing 77 changed files with 5,012 additions and 2,756 deletions.
50 changes: 46 additions & 4 deletions api-description/web-api.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1532,11 +1532,11 @@ paths:
parameters:
- name: environmentId
in: query
required: false
required: true
type: string
- name: featureId
in: query
required: false
required: true
type: string
- name: repositoryName
in: query
Expand Down Expand Up @@ -1708,7 +1708,7 @@ paths:
type: string
- name: environmentId
in: query
required: false
required: true
type: string
tags:
- Code Reference
Expand Down Expand Up @@ -1768,7 +1768,7 @@ paths:
type: string
- name: environmentId
in: query
required: false
required: true
type: string
tags:
- Code Reference
Expand Down Expand Up @@ -5128,6 +5128,12 @@ definitions:
type: string
commitHash:
type: string
required:
- environmentId
- filePath
- lineNumber
- codeSnippet
- contentHash
ExperimentGoalReference:
type: object
properties:
Expand Down Expand Up @@ -6271,6 +6277,16 @@ definitions:
type: string
commitHash:
type: string
required:
- featureId
- environmentId
- filePath
- lineNumber
- codeSnippet
- contentHash
- repositoryName
- repositoryOwner
- repositoryType
coderefCreateCodeReferenceResponse:
type: object
properties:
Expand Down Expand Up @@ -7967,6 +7983,10 @@ definitions:
$ref: '#/definitions/notificationRecipient'
name:
type: string
featureFlagTags:
type: array
items:
type: string
notificationCreateSubscriptionRequest:
type: object
properties:
Expand All @@ -7982,6 +8002,10 @@ definitions:
$ref: '#/definitions/SubscriptionSourceType'
recipient:
$ref: '#/definitions/notificationRecipient'
featureFlagTags:
type: array
items:
type: string
required:
- environmentId
- name
Expand Down Expand Up @@ -8170,8 +8194,19 @@ definitions:
type: string
environmentName:
type: string
featureFlagTags:
type: array
items:
type: string
notificationUpdateAdminSubscriptionResponse:
type: object
notificationUpdateSubscriptionFeatureFlagTagsCommand:
type: object
properties:
featureFlagTags:
type: array
items:
type: string
notificationUpdateSubscriptionRequest:
type: object
properties:
Expand All @@ -8198,6 +8233,13 @@ definitions:
type: boolean
description: if true, the subscription is disabled, otherwise enabled.
title: disabled
featureFlagTags:
type: array
items:
type: string
updateSubscriptionFeatureTagsCommand:
$ref: '#/definitions/notificationUpdateSubscriptionFeatureFlagTagsCommand'
description: Deprecated. Use feature_flag_tags instead.
required:
- id
- environmentId
Expand Down
2 changes: 1 addition & 1 deletion manifests/bucketeer/charts/api/values.yaml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions manifests/bucketeer/charts/web/values.yaml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions migration/mysql/20250122261736_update_subscription_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE `subscription` ADD COLUMN `feature_flag_tags` JSON NOT NULL AFTER `name`;

-- Populate feature_flag_tags with an empty array
UPDATE `subscription` SET `feature_flag_tags` = '[]';
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:VXTmzqYh41HnDCRZyYb9OvaSQx2m1+GLavQcpqgGCjQ=
h1:w7fx0uljXF2/NlqThOynR/9BbVayje1TcjST6rEkRoI=
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 @@ -24,3 +24,4 @@ h1:VXTmzqYh41HnDCRZyYb9OvaSQx2m1+GLavQcpqgGCjQ=
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=
20250122261736_update_subscription_table.sql h1:+TyXXsVb1NxYHBNQsnBENojIxV5AFORw48dcG9D0gxQ=
2 changes: 1 addition & 1 deletion pkg/batch/jobs/deleter/tag_deleter.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (td *tagDeleter) deleteUnusedTags(
}

func (td *tagDeleter) deleteTag(ctx context.Context, tag *tagproto.Tag) error {
if err := td.tagStorage.DeleteTag(ctx, tag.Id, tag.EnvironmentId); err != nil {
if err := td.tagStorage.DeleteTag(ctx, tag.Id); err != nil {
td.logger.Error("Failed to delete the tag",
zap.Error(err),
zap.String("tagId", tag.Id),
Expand Down
22 changes: 11 additions & 11 deletions pkg/batch/jobs/deleter/tag_deleter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestRun(t *testing.T) {
nil,
)
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(
gomock.Any(), "tag-id-1", "env-id-1").Return(errors.New("internal error"))
gomock.Any(), "tag-id-1").Return(errors.New("internal error"))
},
expected: errInternal,
},
Expand Down Expand Up @@ -167,9 +167,9 @@ func TestRun(t *testing.T) {
nil,
)
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(
gomock.Any(), "tag-id-2", "env-id-1").Return(nil)
gomock.Any(), "tag-id-2").Return(nil)
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(
gomock.Any(), "tag-id-4", "env-id-2").Return(nil)
gomock.Any(), "tag-id-4").Return(nil)
},
expected: nil,
},
Expand Down Expand Up @@ -221,15 +221,15 @@ func TestRun(t *testing.T) {
nil,
)
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(
gomock.Any(), "tag-id-1", "env-id-1").Return(nil)
gomock.Any(), "tag-id-1").Return(nil)
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(
gomock.Any(), "tag-id-2", "env-id-1").Return(nil)
gomock.Any(), "tag-id-2").Return(nil)
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(
gomock.Any(), "tag-id-3", "env-id-1").Return(nil)
gomock.Any(), "tag-id-3").Return(nil)
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(
gomock.Any(), "tag-id-4", "env-id-2").Return(nil)
gomock.Any(), "tag-id-4").Return(nil)
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(
gomock.Any(), "tag-id-5", "env-id-2").Return(nil)
gomock.Any(), "tag-id-5").Return(nil)
},
expected: nil,
},
Expand Down Expand Up @@ -264,8 +264,8 @@ func TestDeleteUnusedTags(t *testing.T) {
{
desc: "err: internal error while deleting 2 entries, but only 1 one is deleted",
setup: func(td *tagDeleter) {
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(ctx, "tag-id-2", "env-id").Return(nil)
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(ctx, "tag-id-3", "env-id").
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(ctx, "tag-id-2").Return(nil)
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(ctx, "tag-id-3").
Return(errors.New("internal error"))
},
inputTags: []*tagproto.Tag{
Expand Down Expand Up @@ -297,7 +297,7 @@ func TestDeleteUnusedTags(t *testing.T) {
{
desc: "success",
setup: func(td *tagDeleter) {
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(ctx, "tag-id-2", "env-id").Return(nil)
td.tagStorage.(*tagstoragemock.MockTagStorage).EXPECT().DeleteTag(ctx, "tag-id-2").Return(nil)
},
inputTags: []*tagproto.Tag{
{
Expand Down
4 changes: 1 addition & 3 deletions pkg/coderef/api/code_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ func (s *CodeReferenceService) ListCodeReferences(
}
whereParts := []mysql.WherePart{
mysql.NewFilter("environment_id", "=", req.EnvironmentId),
}
if req.FeatureId != "" {
whereParts = append(whereParts, mysql.NewFilter("feature_id", "=", req.FeatureId))
mysql.NewFilter("feature_id", "=", req.FeatureId),
}
if req.RepositoryName != "" {
whereParts = append(whereParts, mysql.NewFilter("repository_name", "=", req.RepositoryName))
Expand Down
10 changes: 10 additions & 0 deletions pkg/coderef/api/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,16 @@ func validateGetCodeReferenceRequest(req *proto.GetCodeReferenceRequest, localiz
}

func validateListCodeReferencesRequest(req *proto.ListCodeReferencesRequest, localizer locale.Localizer) error {
if req.FeatureId == "" {
dt, err := statusMissingFeatureID.WithDetails(&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Message: localizer.MustLocalizeWithTemplate(locale.RequiredFieldTemplate, "feature_id"),
})
if err != nil {
return statusInternal.Err()
}
return dt.Err()
}
if req.EnvironmentId == "" {
dt, err := statusMissingEnvironmentID.WithDetails(&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Expand Down
8 changes: 8 additions & 0 deletions pkg/domainevent/domain/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,14 @@ func LocalizedMessage(eventType proto.Event_Type, localizer locale.Localizer) *p
localizer.MustLocalizeWithTemplate(locale.Notification),
),
}
case proto.Event_SUBSCRIPTION_FEATURE_FLAG_TAGS_UPDATED:
return &proto.LocalizedMessage{
Locale: localizer.GetLocale(),
Message: localizer.MustLocalizeWithTemplate(
locale.FeatureFlagTagsUpdatedTemplate,
localizer.MustLocalizeWithTemplate(locale.Notification),
),
}
case proto.Event_SUBSCRIPTION_UPDATED:
return &proto.LocalizedMessage{
Locale: localizer.GetLocale(),
Expand Down
1 change: 1 addition & 0 deletions pkg/locale/localizedata/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ MultipleUpdated: "{{ .Field_1 }} have been updated"
DescriptionUpdated: "{{ .Field_1 }} description has been updated"
Incremented: "{{ .Field_1 }} has been incremented"
NameUpdated: "{{ .Field_1 }} name has been updated"
FeatureFlagTagsUpdated: "{{ .Field_1 }} feature flag tags have been updated"
Started: "{{ .Field_1 }} has been started"
Stopped: "{{ .Field_1 }} has been stopped"
Finished: "{{ .Field_1 }} has been finished"
Expand Down
1 change: 1 addition & 0 deletions pkg/locale/localizedata/ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Changed: "{{ .Field_1 }}が変更されました"
DescriptionUpdated: "{{ .Field_1 }}の説明文が更新されました"
Incremented: "{{ .Field_1 }}が増加されました"
NameUpdated: "{{ .Field_1 }}の名前が更新されました"
FeatureFlagTagsUpdated: "{{ .Field_1 }} フィチャーフラグのタグが更新されました"
Updated: "{{ .Field_1 }}が更新されました"
MultipleUpdated: "{{ .Field_1 }}が更新されました"
Started: "{{ .Field_1 }}が開始されました"
Expand Down
55 changes: 28 additions & 27 deletions pkg/locale/localizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,33 +135,34 @@ const (

// domain events
const (
UnknownOperation = "UnknownOperation"
CreatedTemplate = "Created"
EnabledTemplate = "Enabled"
DisabledTemplate = "Disabled"
ArchivedTemplate = "Archived"
UnarchivedTemplate = "Unarchived"
DeletedTemplate = "Deleted"
AddedTemplate = "Added"
ConditionAddedTemplate = "ConditionAdded"
ConditionDeletedTemplate = "ConditionDeleted"
ChangedTemplate = "Changed"
DescriptionUpdatedTemplate = "DescriptionUpdated"
IncrementedTemplate = "Incremented"
NameUpdatedTemplate = "NameUpdated"
UpdatedTemplate = "Updated"
MultipleUpdatedTemplate = "MultipleUpdated"
StartedTemplate = "Started"
StoppedTemplate = "Stopped"
FinishedTemplate = "Finished"
ExecutedTemplate = "Executed"
UploadedTemplate = "Uploaded"
ResetTemplate = "Reset"
ClonedTemplate = "Cloned"
TrialConverted = "TrialConverted"
ValueAddedTemplate = "ValueAdded"
ValueUpdatedTemplate = "ValueUpdated"
ValueDeletedTemplate = "ValueDeleted"
UnknownOperation = "UnknownOperation"
CreatedTemplate = "Created"
EnabledTemplate = "Enabled"
DisabledTemplate = "Disabled"
ArchivedTemplate = "Archived"
UnarchivedTemplate = "Unarchived"
DeletedTemplate = "Deleted"
AddedTemplate = "Added"
ConditionAddedTemplate = "ConditionAdded"
ConditionDeletedTemplate = "ConditionDeleted"
ChangedTemplate = "Changed"
DescriptionUpdatedTemplate = "DescriptionUpdated"
IncrementedTemplate = "Incremented"
NameUpdatedTemplate = "NameUpdated"
FeatureFlagTagsUpdatedTemplate = "FeatureFlagTagsUpdated"
UpdatedTemplate = "Updated"
MultipleUpdatedTemplate = "MultipleUpdated"
StartedTemplate = "Started"
StoppedTemplate = "Stopped"
FinishedTemplate = "Finished"
ExecutedTemplate = "Executed"
UploadedTemplate = "Uploaded"
ResetTemplate = "Reset"
ClonedTemplate = "Cloned"
TrialConverted = "TrialConverted"
ValueAddedTemplate = "ValueAdded"
ValueUpdatedTemplate = "ValueUpdated"
ValueDeletedTemplate = "ValueDeleted"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/notification/api/admin_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *NotificationService) CreateAdminSubscription(
if err := s.validateCreateAdminSubscriptionRequest(req, localizer); err != nil {
return nil, err
}
subscription, err := domain.NewSubscription(req.Command.Name, req.Command.SourceTypes, req.Command.Recipient)
subscription, err := domain.NewSubscription(req.Command.Name, req.Command.SourceTypes, req.Command.Recipient, nil)
if err != nil {
s.logger.Error(
"Failed to create a new admin subscription",
Expand Down
2 changes: 1 addition & 1 deletion pkg/notification/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func putSubscription(t *testing.T, s storage.Client, kind, namespace string, dis
Type: proto.Recipient_SlackChannel,
SlackChannelRecipient: &proto.SlackChannelRecipient{WebhookUrl: "url"},
}
subscription, err := domain.NewSubscription("sname", sourceTypes, recipient)
subscription, err := domain.NewSubscription("sname", sourceTypes, recipient, []string{"tag"})
subscription.Disabled = disabled
require.NoError(t, err)
err = s.Put(context.Background(), key, subscription.Subscription)
Expand Down
Loading

0 comments on commit f9912f6

Please sign in to comment.