-
Notifications
You must be signed in to change notification settings - Fork 1
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
PIN-5931: added SH feature flag and whitelist #1369
Changes from 5 commits
cd3f1c9
dff7352
cdf2742
426c72c
b097b53
946d8ab
c60a5c2
ac0830e
4ec2d1c
f19371a
b0072f5
a16b07f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16,8 +16,18 @@ const CatalogProcessConfig = CommonHTTPServiceConfig.and(ReadModelDbConfig) | |||||||||||||||
.object({ | ||||||||||||||||
ESERVICE_DOCUMENTS_PATH: z.string(), | ||||||||||||||||
PRODUCER_ALLOWED_ORIGINS: z.string(), | ||||||||||||||||
FEATURE_FLAG_SIGNALHUB_WHITELIST: z | ||||||||||||||||
.enum(["true", "false"]) | ||||||||||||||||
.transform((value) => value === "true"), | ||||||||||||||||
borgesis95 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
As suggested by @galales we should set a default in case the env variable is not set and I also agree to define dedicated featureFlags configs, you could do it like this maybe by creating a new file featureFlags that we will use to define all the flags' configs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think that it should be included inside the dedicated config since that variable is strictly related to Even if, for now, this config is used only in the catalog-process having all the featureFlags configs in commons would be easier for future development There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you've convinced me! moved var into feature flag config file 👍 |
||||||||||||||||
SIGNALHUB_WHITELIST: z | ||||||||||||||||
.string() | ||||||||||||||||
.uuid() | ||||||||||||||||
borgesis95 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
.transform((value) => value.split(",")) | ||||||||||||||||
.optional(), | ||||||||||||||||
}) | ||||||||||||||||
.transform((c) => ({ | ||||||||||||||||
featureFlagSignalhubWhitelist: c.FEATURE_FLAG_SIGNALHUB_WHITELIST, | ||||||||||||||||
signalhubWhitelist: c.SIGNALHUB_WHITELIST, | ||||||||||||||||
eserviceDocumentsPath: c.ESERVICE_DOCUMENTS_PATH, | ||||||||||||||||
producerAllowedOrigins: c.PRODUCER_ALLOWED_ORIGINS.split(",") | ||||||||||||||||
.map((origin) => origin.trim()) | ||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,6 +325,15 @@ async function parseAndCheckAttributes( | |
}; | ||
} | ||
|
||
function isOrganizationIdIncludesOnWhitelist( | ||
borgesis95 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
organizationId: TenantId, | ||
isSignalubEnabled: boolean | undefined | ||
): boolean | undefined { | ||
borgesis95 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return config.signalhubWhitelist?.includes(organizationId) | ||
? isSignalubEnabled | ||
: false; | ||
AsterITA marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
export function catalogServiceBuilder( | ||
dbInstance: DB, | ||
|
@@ -443,7 +452,12 @@ export function catalogServiceBuilder( | |
descriptors: [], | ||
createdAt: creationDate, | ||
riskAnalysis: [], | ||
isSignalHubEnabled: seed.isSignalHubEnabled, | ||
isSignalHubEnabled: config.featureFlagSignalhubWhitelist | ||
? isOrganizationIdIncludesOnWhitelist( | ||
authData.organizationId, | ||
seed.isSignalHubEnabled | ||
) | ||
: seed.isSignalHubEnabled, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the fallback be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if |
||
}; | ||
|
||
const eserviceCreationEvent = toCreateEventEServiceAdded( | ||
|
@@ -564,7 +578,12 @@ export function catalogServiceBuilder( | |
serverUrls: [], | ||
})) | ||
: eservice.data.descriptors, | ||
isSignalHubEnabled: eserviceSeed.isSignalHubEnabled, | ||
isSignalHubEnabled: config.featureFlagSignalhubWhitelist | ||
? isOrganizationIdIncludesOnWhitelist( | ||
authData.organizationId, | ||
eservice.data.isSignalHubEnabled | ||
) | ||
: eservice.data.isSignalHubEnabled, | ||
}; | ||
|
||
const event = toCreateEventEServiceUpdated( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to create a new config in common for feature flags, so every service can use the same flag.
Plus, feature flags could be optional and default to
false
. In my mind the idea is to enable only the ones needed, when needed.No strong opinions, let me know your thoughts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid to make the feature flag an optional value (with a default false) but I don't have an example of a situation where this behavior could cause problems.
I had to think about it