-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add migration description for ytAuthCluster -> allowPasswordAuth […
- Loading branch information
1 parent
66ccb44
commit d1a9b2b
Showing
3 changed files
with
66 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type {Request, Response} from 'express'; | ||
import {AppMiddleware} from '@gravity-ui/expresskit'; | ||
import {AppConfig} from '@gravity-ui/nodekit'; | ||
|
||
function checkConfigurationMiddleware(errors: Array<string>): AppMiddleware { | ||
return function checkConfiguration(_req: Request, res: Response) { | ||
res.setHeader('Content-Type', 'text/html; charset=utf-8'); | ||
const body = `Please fix the problems below:<br> | ||
<ol> | ||
${errors.map((i) => `<li>${i}</li>`).join('\n')} | ||
</ol> | ||
Please refer to the <a target='_blank' href='https://github.com/ytsaurus/ytsaurus-ui/tree/main/packages/ui#migration'>migration notices<a/> for more details. | ||
`; | ||
res.status(500).end(body); | ||
}; | ||
} | ||
|
||
export function createConfigurationErrorsMidleware(config: AppConfig) { | ||
const configurationErrors: Array<string> = []; | ||
if (process.env.YT_AUTH_CLUSTER_ID) { | ||
configurationErrors.push( | ||
'The YT_AUTH_CLUSTER_ID environment variable is no longer supported, please replace it with ALLOW_PASSWORD_AUTH', | ||
); | ||
} | ||
|
||
if ('ytAuthCluster' in config) { | ||
configurationErrors.push( | ||
'The config setting `config.ytAuthCluster` is no longer supported, please replace it with `config.allowPasswordAuth` or use ALLOW_PASSWORD_AUTH environment variable', | ||
); | ||
} | ||
|
||
return configurationErrors.length > 0 | ||
? checkConfigurationMiddleware([...configurationErrors]) | ||
: undefined; | ||
} |