Skip to content

Commit

Permalink
fix: remove feature flag for execution order (#381)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
danez and kodiakhq[bot] committed May 5, 2023
1 parent 7993eed commit 125c82c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 109 deletions.
45 changes: 0 additions & 45 deletions node/__snapshots__/declaration.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,48 +44,3 @@ exports[`Ensure the order of edge functions with FF 1`] = `
},
]
`;

exports[`Ensure the order of edge functions without FF 1`] = `
[
{
"function": "user-toml-a",
"path": "/path1",
},
{
"function": "user-toml-c",
"path": "/path3",
},
{
"function": "user-toml-b",
"path": "/path2",
},
{
"function": "framework-manifest-a",
"path": "/path1",
},
{
"function": "framework-manifest-c",
"path": "/path3",
},
{
"function": "framework-manifest-b",
"path": "/path2",
},
{
"function": "framework-isc-c",
"path": "/path1",
},
{
"function": "framework-isc-c",
"path": "/path2",
},
{
"function": "user-isc-c",
"path": "/path1",
},
{
"function": "user-isc-c",
"path": "/path2",
},
]
`;
34 changes: 1 addition & 33 deletions node/declaration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,7 @@ test('Ensure the order of edge functions with FF', () => {
'framework-isc-c': { path: ['/path1', '/path2'] },
} as Record<string, FunctionConfig>

expect(
mergeDeclarations(tomlConfig, userFuncConfig, internalFuncConfig, deployConfigDeclarations, {
edge_functions_correct_order: true,
}),
).toMatchSnapshot()
})

test('Ensure the order of edge functions without FF', () => {
const deployConfigDeclarations: Declaration[] = [
{ function: 'framework-manifest-a', path: '/path1' },
{ function: 'framework-manifest-c', path: '/path3' },
{ function: 'framework-manifest-b', path: '/path2' },
]

const tomlConfig: Declaration[] = [
{ function: 'user-toml-a', path: '/path1' },
{ function: 'user-toml-c', path: '/path3' },
{ function: 'user-toml-b', path: '/path2' },
]

const userFuncConfig = {
'user-isc-c': { path: ['/path1', '/path2'] },
} as Record<string, FunctionConfig>

const internalFuncConfig = {
'framework-isc-c': { path: ['/path1', '/path2'] },
} as Record<string, FunctionConfig>

expect(
mergeDeclarations(tomlConfig, userFuncConfig, internalFuncConfig, deployConfigDeclarations, {
edge_functions_correct_order: false,
}),
).toMatchSnapshot()
expect(mergeDeclarations(tomlConfig, userFuncConfig, internalFuncConfig, deployConfigDeclarations)).toMatchSnapshot()
})

test('In-source config takes precedence over netlify.toml config', () => {
Expand Down
45 changes: 15 additions & 30 deletions node/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,25 @@ export const mergeDeclarations = (
userFunctionsConfig: Record<string, FunctionConfig>,
internalFunctionsConfig: Record<string, FunctionConfig>,
deployConfigDeclarations: Declaration[],
featureFlags: FeatureFlags = {},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_featureFlags: FeatureFlags = {},
// eslint-disable-next-line max-params
) => {
const functionsVisited: Set<string> = new Set()

let declarations: Declaration[] = getDeclarationsFromInput(
deployConfigDeclarations,
internalFunctionsConfig,
functionsVisited,
)

// eslint-disable-next-line unicorn/prefer-ternary
if (featureFlags.edge_functions_correct_order) {
declarations = [
// INTEGRATIONS
// 1. Declarations from the integrations deploy config
...getDeclarationsFromInput(deployConfigDeclarations, internalFunctionsConfig, functionsVisited),
// 2. Declarations from the integrations ISC
...createDeclarationsFromFunctionConfigs(internalFunctionsConfig, functionsVisited),

// USER
// 3. Declarations from the users toml config
...getDeclarationsFromInput(tomlDeclarations, userFunctionsConfig, functionsVisited),
// 4. Declarations from the users ISC
...createDeclarationsFromFunctionConfigs(userFunctionsConfig, functionsVisited),
]
} else {
declarations = [
...getDeclarationsFromInput(tomlDeclarations, userFunctionsConfig, functionsVisited),
...getDeclarationsFromInput(deployConfigDeclarations, internalFunctionsConfig, functionsVisited),
...createDeclarationsFromFunctionConfigs(internalFunctionsConfig, functionsVisited),
...createDeclarationsFromFunctionConfigs(userFunctionsConfig, functionsVisited),
]
}
const declarations: Declaration[] = [
// INTEGRATIONS
// 1. Declarations from the integrations deploy config
...getDeclarationsFromInput(deployConfigDeclarations, internalFunctionsConfig, functionsVisited),
// 2. Declarations from the integrations ISC
...createDeclarationsFromFunctionConfigs(internalFunctionsConfig, functionsVisited),

// USER
// 3. Declarations from the users toml config
...getDeclarationsFromInput(tomlDeclarations, userFunctionsConfig, functionsVisited),
// 4. Declarations from the users ISC
...createDeclarationsFromFunctionConfigs(userFunctionsConfig, functionsVisited),
]

return declarations
}
Expand Down
1 change: 0 additions & 1 deletion node/feature_flags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const defaultFlags = {
edge_functions_correct_order: false,
edge_functions_fail_unsupported_regex: false,
}

Expand Down

0 comments on commit 125c82c

Please sign in to comment.