Updating create-app so that cache store can be selected/configured.
Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
@@ -112,10 +112,19 @@ export default async (cmd: Command): Promise<void> => {
|
||||
// @ts-ignore
|
||||
choices: ['SQLite', 'PostgreSQL'],
|
||||
},
|
||||
{
|
||||
type: 'list',
|
||||
name: 'cacheType',
|
||||
message: chalk.blue('Select cache store for the backend [required]'),
|
||||
// @ts-ignore
|
||||
choices: ['in-memory', 'memcache'],
|
||||
},
|
||||
];
|
||||
const answers: Answers = await inquirer.prompt(questions);
|
||||
answers.dbTypePG = answers.dbType === 'PostgreSQL';
|
||||
answers.dbTypeSqlite = answers.dbType === 'SQLite';
|
||||
answers.cacheTypeMemory = answers.cacheType === 'in-memory';
|
||||
answers.cacheTypeMemcache = answers.cacheType === 'memcache';
|
||||
|
||||
const templateDir = paths.resolveOwn('templates/default-app');
|
||||
const tempDir = resolvePath(os.tmpdir(), answers.name);
|
||||
|
||||
@@ -34,6 +34,15 @@ backend:
|
||||
#ca: # if you have a CA file and want to verify it you can uncomment this section
|
||||
# $file: <file-path>/ca/server.crt
|
||||
{{/if}}
|
||||
{{#if cacheTypeMemory}}
|
||||
cache:
|
||||
store: memory
|
||||
{{/if}}
|
||||
{{#if cacheTypeMemcache}}
|
||||
cache:
|
||||
store: memcache
|
||||
connection: ${MEMCACHE_USER}:${MEMCACHE_PASSWORD}@${MEMCACHE_HOST}:$MEMCACHE_PORT}
|
||||
{{/if}}
|
||||
# workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir
|
||||
|
||||
integrations:
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
getRootLogger,
|
||||
useHotMemoize,
|
||||
notFoundHandler,
|
||||
CacheManager,
|
||||
SingleConnectionDatabaseManager,
|
||||
SingleHostDiscovery,
|
||||
UrlReaders,
|
||||
@@ -34,11 +35,13 @@ function makeCreateEnv(config: Config) {
|
||||
root.info(`Created UrlReader ${reader}`);
|
||||
|
||||
const databaseManager = SingleConnectionDatabaseManager.fromConfig(config);
|
||||
const cacheManager = CacheManager.fromConfig(config);
|
||||
|
||||
return (plugin: string): PluginEnvironment => {
|
||||
const logger = root.child({ type: 'plugin', plugin });
|
||||
const database = databaseManager.forPlugin(plugin);
|
||||
return { logger, database, config, reader, discovery };
|
||||
const cache = cacheManager.forPlugin(plugin);
|
||||
return { logger, database, cache, config, reader, discovery };
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Logger } from 'winston';
|
||||
import { Config } from '@backstage/config';
|
||||
import {
|
||||
PluginCacheManager,
|
||||
PluginDatabaseManager,
|
||||
PluginEndpointDiscovery,
|
||||
UrlReader,
|
||||
@@ -9,6 +10,7 @@ import {
|
||||
export type PluginEnvironment = {
|
||||
logger: Logger;
|
||||
database: PluginDatabaseManager;
|
||||
cache: PluginCacheManager;
|
||||
config: Config;
|
||||
reader: UrlReader
|
||||
discovery: PluginEndpointDiscovery;
|
||||
|
||||
Reference in New Issue
Block a user