diff --git a/generators/azure-app-service/index.js b/generators/azure-app-service/index.js index a49004659d8c..fc3b053d0b7a 100644 --- a/generators/azure-app-service/index.js +++ b/generators/azure-app-service/index.js @@ -28,8 +28,6 @@ const { defaultConfig } = require('../generator-defaults'); // Global constants const constants = require('../generator-constants'); -const { OptionNames } = require('../../jdl/jhipster/application-options'); - const { MAVEN } = require('../../jdl/jhipster/build-tool-types'); const { GENERATOR_AZURE_APP_SERVICE } = require('../generator-list'); @@ -70,7 +68,7 @@ module.exports = class extends BaseBlueprintGenerator { _initializing() { return { - getConfig() { + sayHello() { if (!this.options.fromCli) { this.warning( `Deprecated: JHipster seems to be invoked using Yeoman command. Please use the JHipster CLI. Run ${chalk.red( @@ -79,8 +77,12 @@ module.exports = class extends BaseBlueprintGenerator { ); } this.log(chalk.bold('Azure App Service configuration is starting')); - this.baseName = this.config.get(OptionNames.BASE_NAME); - this.buildTool = this.config.get(OptionNames.BUILD_TOOL); + }, + getSharedConfig() { + this.loadAppConfig(); + this.loadServerConfig(); + }, + getConfig() { this.azureAppServiceResourceGroupName = ''; // This is not saved, as it is better to get the Azure default variable this.azureLocation = this.config.get('azureLocation'); this.azureAppServicePlan = this.config.get('azureAppServicePlan'); @@ -484,8 +486,11 @@ which is free for the first 30 days`); return this._default(); } - _loadPlatformConfig(config = _.defaults({}, this.jhipsterConfig, defaultConfig), dest = this) { - super.loadPlatformConfig(config, dest); + _computeDerivedConfig(config = _.defaults({}, this.jhipsterConfig, defaultConfig), dest = this) { + this.loadAppConfig(); + this.loadServerConfig(); + super.loadDerivedServerConfig(config, dest); + super.loadDerivedAppConfig(config, dest); dest.azureAppInsightsInstrumentationKeyEmpty = config.azureAppInsightsInstrumentationKey === ''; } @@ -493,7 +498,7 @@ which is free for the first 30 days`); _loading() { return { loadSharedConfig() { - this._loadPlatformConfig(); + this._computeDerivedConfig(); }, }; } diff --git a/generators/azure-spring-cloud/index.js b/generators/azure-spring-cloud/index.js index 6c7b1c7f7f65..7bb040b32820 100644 --- a/generators/azure-spring-cloud/index.js +++ b/generators/azure-spring-cloud/index.js @@ -23,16 +23,14 @@ const BaseBlueprintGenerator = require('../generator-base-blueprint'); const statistics = require('../statistics'); const constants = require('../generator-constants'); -const { OptionNames } = require('../../jdl/jhipster/application-options'); const cacheTypes = require('../../jdl/jhipster/cache-types'); const { MEMCACHED } = require('../../jdl/jhipster/cache-types'); const NO_CACHE_PROVIDER = cacheTypes.NO; -const { MAVEN, GRADLE } = require('../../jdl/jhipster/build-tool-types'); +const { MAVEN } = require('../../jdl/jhipster/build-tool-types'); const { GENERATOR_AZURE_SPRING_CLOUD } = require('../generator-list'); -const { JWT } = require('../../jdl/jhipster/authentication-types'); let useBlueprints; /* eslint-disable consistent-return */ @@ -58,37 +56,36 @@ module.exports = class extends BaseBlueprintGenerator { } _initializing() { - if (!this.options.fromCli) { - this.warning( - `Deprecated: JHipster seems to be invoked using Yeoman command. Please use the JHipster CLI. Run ${chalk.red( - 'jhipster ' - )} instead of ${chalk.red('yo jhipster:')}` - ); - } - this.log(chalk.bold('Azure Spring Cloud configuration is starting')); - this.env.options.appPath = this.config.get('appPath') || constants.CLIENT_MAIN_SRC_DIR; - this.baseName = this.config.get(OptionNames.BASE_NAME); - this.packageName = this.config.get(OptionNames.PACKAGE_NAME); - this.packageFolder = this.config.get(OptionNames.PACKAGE_FOLDER); - this.authenticationType = this.config.get(OptionNames.AUTHENTICATION_TYPE); - this.jwtSecretKey = this.config.get(OptionNames.JWT_SECRET_KEY); - this.cacheProvider = this.config.get(OptionNames.CACHE_PROVIDER) || NO_CACHE_PROVIDER; - this.enableHibernateCache = - this.config.get(OptionNames.ENABLE_HIBERNATE_CACHE) && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider); - this.databaseType = this.config.get(OptionNames.DATABASE_TYPE); - this.prodDatabaseType = this.config.get(OptionNames.PROD_DATABASE_TYPE); - this.searchEngine = this.config.get(OptionNames.SEARCH_ENGINE); - this.frontendAppName = this.getFrontendAppName(); - this.buildTool = this.config.get(OptionNames.BUILD_TOOL); - this.applicationType = this.config.get(OptionNames.APPLICATION_TYPE); - this.serviceDiscoveryType = this.config.get(OptionNames.SERVICE_DISCOVERY_TYPE); - this.azureSpringCloudResourceGroupName = ''; // This is not saved, as it is better to get the Azure default variable - this.azureSpringCloudServiceName = ''; // This is not saved, as it is better to get the Azure default variable - this.azureSpringCloudAppName = this.config.get('azureSpringCloudAppName'); - this.azureSpringCloudDeploymentType = this.config.get('azureSpringCloudDeploymentType'); + return { + sayHello() { + if (!this.options.fromCli) { + this.warning( + `Deprecated: JHipster seems to be invoked using Yeoman command. Please use the JHipster CLI. Run ${chalk.red( + 'jhipster ' + )} instead of ${chalk.red('yo jhipster:')}` + ); + } + this.log(chalk.bold('Azure Spring Cloud configuration is starting')); + }, + getSharedConfig() { + this.loadAppConfig(); + this.loadServerConfig(); + this.loadPlatformConfig(); + }, + getConfig() { + this.env.options.appPath = this.config.get('appPath') || constants.CLIENT_MAIN_SRC_DIR; + this.cacheProvider = this.cacheProvider || NO_CACHE_PROVIDER; + this.enableHibernateCache = this.enableHibernateCache && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider); + this.frontendAppName = this.getFrontendAppName(); + this.azureSpringCloudResourceGroupName = ''; // This is not saved, as it is better to get the Azure default variable + this.azureSpringCloudServiceName = ''; // This is not saved, as it is better to get the Azure default variable + this.azureSpringCloudAppName = this.config.get('azureSpringCloudAppName'); + this.azureSpringCloudDeploymentType = this.config.get('azureSpringCloudDeploymentType'); + }, + }; } - initializing() { + get initializing() { if (useBlueprints) return; return this._initializing(); } @@ -311,14 +308,32 @@ ${chalk.red('az extension add --name spring-cloud')}` } ); }, + }; + } + get default() { + if (useBlueprints) return; + return this._default(); + } + + _loading() { + return { derivedProperties() { this.isPackageNameJhipsterTech = this.packageName !== 'tech.jhipster'; - this.isAuthenticationTypeJwt = this.authenticationType === JWT; - this.buildToolMaven = this.buildTool === MAVEN; - this.buildToolGradle = this.buildTool === GRADLE; + this.loadDerivedServerConfig(); + this.loadDerivedPlatformConfig(); + this.loadDerivedAppConfig(); }, + }; + } + get loading() { + if (useBlueprints) return; + return this._loading(); + } + + _writing() { + return { copyAzureSpringCloudFiles() { if (this.abort) return; this.log(chalk.bold('\nCreating Azure Spring Cloud deployment files')); @@ -340,9 +355,9 @@ ${chalk.red('az extension add --name spring-cloud')}` }; } - get default() { + get writing() { if (useBlueprints) return; - return this._default(); + return this._writing(); } _end() { diff --git a/generators/azure-spring-cloud/templates/application-azure.yml.ejs b/generators/azure-spring-cloud/templates/application-azure.yml.ejs index 6cde9672dc85..34007f1124b9 100644 --- a/generators/azure-spring-cloud/templates/application-azure.yml.ejs +++ b/generators/azure-spring-cloud/templates/application-azure.yml.ejs @@ -32,9 +32,9 @@ logging: level: ROOT: INFO tech.jhipster: INFO - <%_ if (!isPackageNameJhipsterTech) { _%> +<%_ if (!isPackageNameJhipsterTech) { _%> <%= packageName %>: INFO - <%_ } _%> +<%_ } _%> eureka: client: @@ -55,7 +55,7 @@ spring: # =================================================================== jhipster: - <%_ if (isAuthenticationTypeJwt) { _%> +<%_ if (authenticationTypeJwt) { _%> security: authentication: jwt: @@ -68,4 +68,4 @@ jhipster: # Token is valid 24 hours token-validity-in-seconds: 86400 token-validity-in-seconds-for-remember-me: 2592000 - <%_ } _%> +<%_ } _%> diff --git a/generators/ci-cd/index.js b/generators/ci-cd/index.js index b42123bee5c9..925858c23718 100644 --- a/generators/ci-cd/index.js +++ b/generators/ci-cd/index.js @@ -23,27 +23,10 @@ const { defaultConfig } = require('../generator-defaults'); const prompts = require('./prompts'); const BaseBlueprintGenerator = require('../generator-base-blueprint'); const statistics = require('../statistics'); -const packagejs = require('../../package.json'); const constants = require('../generator-constants'); -const { OptionNames } = require('../../jdl/jhipster/application-options'); const { MAVEN, GRADLE } = require('../../jdl/jhipster/build-tool-types'); const { GENERATOR_CICD } = require('../generator-list'); -const { - BASE_NAME, - APPLICATION_TYPE, - DATABASE_TYPE, - PROD_DATABASE_TYPE, - SKIP_CLIENT, - SKIP_SERVER, - CLIENT_PACKAGE_MANAGER, - BUILD_TOOL, - REACTIVE, - CLIENT_FRAMEWORK, - TEST_FRAMEWORKS, - CACHE_PROVIDER, -} = OptionNames; - const REACT = constants.SUPPORTED_CLIENT_FRAMEWORKS.REACT; let useBlueprints; @@ -103,29 +86,25 @@ module.exports = class extends BaseBlueprintGenerator { validateFromCli() { this.checkInvocationFromCLI(); }, + sayHello() { this.log(chalk.white('🚀 Welcome to the JHipster CI/CD Sub-Generator 🚀')); }, + + getSharedConfig() { + this.loadAppConfig(); + this.loadClientConfig(); + this.loadServerConfig(); + this.loadPlatformConfig(); + }, + getConfig() { - this.jhipsterVersion = packagejs.version; const configuration = this.config; - this.baseName = configuration.get(BASE_NAME); this.dasherizedBaseName = _.kebabCase(this.baseName); - this.applicationType = configuration.get(APPLICATION_TYPE); - this.databaseType = configuration.get(DATABASE_TYPE); - this.prodDatabaseType = configuration.get(PROD_DATABASE_TYPE); - this.skipClient = configuration.get(SKIP_CLIENT); - this.skipServer = configuration.get(SKIP_SERVER); - this.clientPackageManager = configuration.get(CLIENT_PACKAGE_MANAGER); - this.buildTool = configuration.get(BUILD_TOOL); - this.reactive = configuration.get(REACTIVE); this.herokuAppName = configuration.get('herokuAppName'); if (this.herokuAppName === undefined) { this.herokuAppName = _.kebabCase(this.baseName); } - this.clientFramework = configuration.get(CLIENT_FRAMEWORK); - this.testFrameworks = configuration.get(TEST_FRAMEWORKS); - this.cacheProvider = configuration.get(CACHE_PROVIDER); this.autoconfigureTravis = this.options.autoconfigureTravis; this.autoconfigureJenkins = this.options.autoconfigureJenkins; this.autoconfigureGitlab = this.options.autoconfigureGitlab; @@ -134,10 +113,12 @@ module.exports = class extends BaseBlueprintGenerator { this.autoconfigureCircleCI = this.options.autoconfigureCircle; this.abort = false; }, + initConstants() { this.NODE_VERSION = constants.NODE_VERSION; this.NPM_VERSION = constants.NPM_VERSION; }, + getConstants() { this.DOCKER_DIR = constants.DOCKER_DIR; this.SERVER_MAIN_RES_DIR = constants.SERVER_MAIN_RES_DIR; @@ -194,9 +175,8 @@ module.exports = class extends BaseBlueprintGenerator { return this._configuring(); } - _loadPlatformConfig(config = _.defaults({}, this.jhipsterConfig, defaultConfig), dest = this) { - super.loadPlatformConfig(config, dest); - dest.cicdIntegrationsSnyk = config.cicdIntegrations || []; + _loadCiCdConfig(config = _.defaults({}, this.jhipsterConfig, defaultConfig), dest = this) { + dest.cicdIntegrations = dest.cicdIntegrations || config.cicdIntegrations || []; dest.cicdIntegrationsSnyk = dest.cicdIntegrations.includes('snyk'); dest.cicdIntegrationsSonar = dest.cicdIntegrations.includes('sonar'); dest.cicdIntegrationsHeroku = dest.cicdIntegrations.includes('heroku'); @@ -216,7 +196,9 @@ module.exports = class extends BaseBlueprintGenerator { this.loadServerConfig(); this.loadDerivedServerConfig(); this.loadTranslationConfig(); - this._loadPlatformConfig(); + this._loadCiCdConfig(); + this.loadPlatformConfig(); + this.loadDerivedPlatformConfig(); }, }; } diff --git a/generators/client/index.js b/generators/client/index.js index 4adbc133c60a..09cdbb50a20e 100644 --- a/generators/client/index.js +++ b/generators/client/index.js @@ -85,20 +85,23 @@ module.exports = class JHipsterClientGenerator extends BaseBlueprintGenerator { this.checkInvocationFromCLI(); }, - displayLogo() { - if (this.logo) { - this.printJHipsterLogo(); - } - }, - - setupClientConstants() { + setupConstants() { // Make constants available in templates + this.MAIN_SRC_DIR = this.CLIENT_MAIN_SRC_DIR; + this.TEST_SRC_DIR = this.CLIENT_TEST_SRC_DIR; + this.packagejs = packagejs; this.LOGIN_REGEX = constants.LOGIN_REGEX_JS; this.ANGULAR = ANGULAR; this.REACT = REACT; this.VUE = VUE; this.NODE_VERSION = constants.NODE_VERSION; }, + + displayLogo() { + if (this.logo) { + this.printJHipsterLogo(); + } + }, }; } @@ -194,6 +197,7 @@ module.exports = class JHipsterClientGenerator extends BaseBlueprintGenerator { this.loadDerivedClientConfig(); this.loadServerConfig(); this.loadDerivedServerConfig(); + this.loadPlatformConfig(); this.loadTranslationConfig(); }, diff --git a/generators/cloudfoundry/index.js b/generators/cloudfoundry/index.js index 2e8a2a9353f4..6848827f92ca 100644 --- a/generators/cloudfoundry/index.js +++ b/generators/cloudfoundry/index.js @@ -23,8 +23,8 @@ const glob = require('glob'); const prompts = require('./prompts'); const BaseBlueprintGenerator = require('../generator-base-blueprint'); const statistics = require('../statistics'); -const { OptionNames } = require('../../jdl/jhipster/application-options'); const { MEMCACHED } = require('../../jdl/jhipster/cache-types'); +const { GRADLE, MAVEN } = require('../../jdl/jhipster/build-tool-types'); const cacheProviders = require('../../jdl/jhipster/cache-types'); const databaseTypes = require('../../jdl/jhipster/database-types'); const constants = require('../generator-constants'); @@ -38,24 +38,38 @@ const exec = childProcess.exec; let useBlueprints; /* eslint-disable consistent-return */ module.exports = class extends BaseBlueprintGenerator { - initializing() { - this.log(chalk.bold('CloudFoundry configuration is starting')); - const configuration = this.config; - this.env.options.appPath = configuration.get('appPath') || constants.CLIENT_MAIN_SRC_DIR; - this.baseName = configuration.get(OptionNames.BASE_NAME); - this.buildTool = configuration.get(OptionNames.BUILD_TOOL); - this.packageName = configuration.get(OptionNames.PACKAGE_NAME); - this.packageFolder = configuration.get(OptionNames.PACKAGE_FOLDER); - this.cacheProvider = configuration.get(OptionNames.CACHE_PROVIDER) || NO_CACHE_PROVIDER; - this.enableHibernateCache = - configuration.get(OptionNames.ENABLE_HIBERNATE_CACHE) && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider); - this.databaseType = configuration.get(OptionNames.DATABASE_TYPE); - this.devDatabaseType = configuration.get(OptionNames.DEV_DATABASE_TYPE); - this.prodDatabaseType = configuration.get(OptionNames.PROD_DATABASE_TYPE); - this.frontendAppName = this.getFrontendAppName(); + constructor(args, options) { + super(args, options); useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_CLOUDFOUNDRY); } + _initializing() { + return { + sayHello() { + this.log(chalk.bold('CloudFoundry configuration is starting')); + }, + + getSharedConfig() { + this.loadAppConfig(); + this.loadClientConfig(); + this.loadServerConfig(); + this.loadPlatformConfig(); + }, + getConfig() { + const configuration = this.config; + this.env.options.appPath = configuration.get('appPath') || constants.CLIENT_MAIN_SRC_DIR; + this.cacheProvider = this.cacheProvider || NO_CACHE_PROVIDER; + this.enableHibernateCache = this.enableHibernateCache && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider); + this.frontendAppName = this.getFrontendAppName(); + }, + }; + } + + get initializing() { + if (useBlueprints) return; + return this._initializing(); + } + _prompting() { return prompts.prompting; } @@ -179,9 +193,9 @@ module.exports = class extends BaseBlueprintGenerator { const done = this.async(); let cloudfoundryDeployCommand = 'cf push -f ./deploy/cloudfoundry/manifest.yml -t 120 -p'; let jarFolder = ''; - if (this.buildTool === 'maven') { + if (this.buildTool === MAVEN) { jarFolder = ' target/'; - } else if (this.buildTool === 'gradle') { + } else if (this.buildTool === GRADLE) { jarFolder = ' build/libs/'; } if (os.platform() === 'win32') { diff --git a/generators/common/index.js b/generators/common/index.js index 02530b553bbe..40c0f1ea06fe 100644 --- a/generators/common/index.js +++ b/generators/common/index.js @@ -77,8 +77,8 @@ module.exports = class JHipsterCommonGenerator extends BaseBlueprintGenerator { this.loadClientConfig(); this.loadDerivedClientConfig(); this.loadServerConfig(); - this.loadDerivedServerConfig(); this.loadTranslationConfig(); + this.loadPlatformConfig(); }, loadPackageJson() { diff --git a/generators/cypress/index.js b/generators/cypress/index.js index ef2632bcb3df..e35066af5230 100644 --- a/generators/cypress/index.js +++ b/generators/cypress/index.js @@ -88,8 +88,8 @@ module.exports = class extends BaseBlueprintGenerator { this.loadClientConfig(); this.loadDerivedClientConfig(); this.loadServerConfig(); - this.loadDerivedServerConfig(); this.loadTranslationConfig(); + this.loadPlatformConfig(); }, }; } diff --git a/generators/database-changelog-liquibase/index.js b/generators/database-changelog-liquibase/index.js index d0792873c0b8..e4593874f526 100644 --- a/generators/database-changelog-liquibase/index.js +++ b/generators/database-changelog-liquibase/index.js @@ -60,8 +60,8 @@ module.exports = class extends BaseBlueprintGenerator { this.loadClientConfig(); this.loadDerivedClientConfig(); this.loadServerConfig(); - this.loadDerivedServerConfig(); this.loadTranslationConfig(); + this.loadPlatformConfig(); }, }; } diff --git a/generators/docker-base.js b/generators/docker-base.js index 384cc68b3d0c..c25375f19d6d 100644 --- a/generators/docker-base.js +++ b/generators/docker-base.js @@ -111,8 +111,10 @@ function loadConfigs() { if (this.fs.exists(`${path}/.yo-rc.json`)) { const config = this.getJhipsterConfig(`${path}/.yo-rc.json`).getAll(); _.defaults(config, defaultConfig); - - this.loadDerivedServerConfig(config, config); + this.loadServerConfig(config); + this.loadDerivedServerConfig(config); + this.loadDerivedPlatformConfig(config); + this.loadDerivedAppConfig(config); if (config.applicationType === MONOLITH) { this.monolithicNb++; @@ -141,7 +143,6 @@ function setClusteredApps() { function loadFromYoRc() { this.loadDeploymentConfig(); - this.loadDerivedDeploymentConfig(); this.useKafka = false; this.useMemcached = false; diff --git a/generators/docker-compose/index.js b/generators/docker-compose/index.js index 7feb4a3d8fcf..5681370cf343 100644 --- a/generators/docker-compose/index.js +++ b/generators/docker-compose/index.js @@ -268,6 +268,19 @@ module.exports = class extends BaseDockerGenerator { return this._preparing(); } + _loading() { + return { + loadPlatformConfig() { + this.loadDeploymentConfig(this); + }, + }; + } + + get loading() { + if (useBlueprints) return; + return this._loading(); + } + _writing() { return writeFiles(); } diff --git a/generators/docker-prompts.js b/generators/docker-prompts.js index fc45e1a5b82b..2a50f00ea537 100644 --- a/generators/docker-prompts.js +++ b/generators/docker-prompts.js @@ -254,11 +254,11 @@ async function askForServiceDiscovery() { return; } - if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryType === 'consul')) { + if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryType === CONSUL)) { this.serviceDiscoveryType = CONSUL; this.log(chalk.green('Consul detected as the service discovery and configuration provider used by your apps')); - } else if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryType === 'eureka')) { - this.serviceDiscoveryType = 'eureka'; + } else if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryType === EUREKA)) { + this.serviceDiscoveryType = EUREKA; this.log(chalk.green('JHipster registry detected as the service discovery and configuration provider used by your apps')); } else { this.log(chalk.yellow('Unable to determine the service discovery and configuration provider to use from your apps configuration.')); diff --git a/generators/entity/index.js b/generators/entity/index.js index 77bf701a3bd4..db4aa298ed95 100644 --- a/generators/entity/index.js +++ b/generators/entity/index.js @@ -495,6 +495,7 @@ class EntityGenerator extends BaseBlueprintGenerator { this.loadDerivedAppConfig(this.context); this.loadDerivedClientConfig(this.context); this.loadDerivedServerConfig(this.context); + this.loadDerivedPlatformConfig(this.context); loadRequiredConfigIntoEntity(this.context, this.jhipsterConfig); if (this.context.fields) { this.context.fields diff --git a/generators/gae/index.js b/generators/gae/index.js index d7198ac001b2..0e85de694910 100644 --- a/generators/gae/index.js +++ b/generators/gae/index.js @@ -16,16 +16,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable consistent-return */ const os = require('os'); const shelljs = require('shelljs'); const fs = require('fs'); const chalk = require('chalk'); const _ = require('lodash'); const { GENERATOR_GAE } = require('../generator-list'); -const BaseGenerator = require('../generator-base'); +const BaseBlueprintGenerator = require('../generator-base-blueprint'); const statistics = require('../statistics'); const dockerPrompts = require('../docker-prompts'); -const { OptionNames } = require('../../jdl/jhipster/application-options'); const constants = require('../generator-constants'); const cacheProviders = require('../../jdl/jhipster/cache-types'); const { MEMCACHED } = require('../../jdl/jhipster/cache-types'); @@ -34,24 +34,15 @@ const { MARIADB, MYSQL, POSTGRESQL } = require('../../jdl/jhipster/database-type const { MAVEN, GRADLE } = require('../../jdl/jhipster/build-tool-types'); const NO_CACHE_PROVIDER = cacheProviders.NO; -const { - APPLICATION_TYPE, - BASE_NAME, - BUILD_TOOL, - CACHE_PROVIDER, - CLIENT_PACKAGE_MANAGER, - DATABASE_TYPE, - ENABLE_HIBERNATE_CACHE, - PACKAGE_NAME, - PACKAGE_FOLDER, - PROD_DATABASE_TYPE, - SEARCH_ENGINE, - SERVICE_DISCOVERY_TYPE, - SKIP_CLIENT, -} = OptionNames; - -module.exports = class extends BaseGenerator { - get initializing() { + +let useBlueprints; +module.exports = class extends BaseBlueprintGenerator { + constructor(args, opts) { + super(args, opts); + useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_GAE); + } + + _initializing() { return { sayHello() { this.log(chalk.bold('Welcome to Google App Engine Generator')); @@ -97,24 +88,20 @@ module.exports = class extends BaseGenerator { ); }, + loadCommonConfig() { + this.loadAppConfig(); + this.loadServerConfig(); + this.loadPlatformConfig(); + this.loadClientConfig(); + }, + loadConfig() { const configuration = this.config; this.env.options.appPath = configuration.get('appPath') || constants.CLIENT_MAIN_SRC_DIR; - this.baseName = configuration.get(BASE_NAME); this.mainClass = this.getMainClassName(); - this.packageName = configuration.get(PACKAGE_NAME); - this.packageFolder = configuration.get(PACKAGE_FOLDER); - this.cacheProvider = configuration.get(CACHE_PROVIDER) || NO_CACHE_PROVIDER; - this.enableHibernateCache = - configuration.get(ENABLE_HIBERNATE_CACHE) && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider); - this.databaseType = configuration.get(DATABASE_TYPE); - this.prodDatabaseType = configuration.get(PROD_DATABASE_TYPE); - this.searchEngine = configuration.get(SEARCH_ENGINE); + this.cacheProvider = this.cacheProvider || NO_CACHE_PROVIDER; + this.enableHibernateCache = this.enableHibernateCache && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider); this.frontendAppName = this.getFrontendAppName(); - this.buildTool = configuration.get(BUILD_TOOL); - this.applicationType = configuration.get(APPLICATION_TYPE); - this.serviceDiscoveryType = configuration.get(SERVICE_DISCOVERY_TYPE); - this.gcpProjectId = configuration.get('gcpProjectId'); this.gcpCloudSqlInstanceName = configuration.get('gcpCloudSqlInstanceName'); this.gcpCloudSqlUserName = configuration.get('gcpCloudSqlUserName'); @@ -128,14 +115,17 @@ module.exports = class extends BaseGenerator { this.gaeMinInstances = configuration.get('gaeMinInstances'); this.gaeCloudSQLInstanceNeeded = configuration.get('gaeCloudSQLInstanceNeeded'); this.CLIENT_DIST_DIR = this.getResourceBuildDirectoryForBuildTool(this.config.buildTool) + constants.CLIENT_DIST_DIR; - this.skipClient = this.config.get(SKIP_CLIENT); - this.clientPackageManager = this.config.get(CLIENT_PACKAGE_MANAGER); this.dasherizedBaseName = _.kebabCase(this.baseName); }, }; } - get prompting() { + get initializing() { + if (useBlueprints) return; + return this._initializing(); + } + + _prompting() { return { askForPath() { if (this.abort) return undefined; @@ -616,11 +606,16 @@ module.exports = class extends BaseGenerator { }; } + get prompting() { + if (useBlueprints) return; + return this._prompting(); + } + get default() { return {}; } - get configuring() { + _configuring() { return { insight() { statistics.sendSubGenEvent('generator', GENERATOR_GAE); @@ -756,7 +751,12 @@ module.exports = class extends BaseGenerator { }; } - get writing() { + get configuring() { + if (useBlueprints) return; + return this._configuring(); + } + + _writing() { return { copyFiles() { if (this.abort) return; @@ -821,7 +821,12 @@ module.exports = class extends BaseGenerator { }; } - get end() { + get writing() { + if (useBlueprints) return; + return this._writing(); + } + + _end() { return { productionBuild() { if (this.abort) return; @@ -862,6 +867,11 @@ module.exports = class extends BaseGenerator { }; } + get end() { + if (useBlueprints) return; + return this._end(); + } + _defaultProjectId() { if (this.abort) return null; if (this.gcpProjectId) { diff --git a/generators/generator-base-docker.js b/generators/generator-base-docker.js index 3b554405f521..93729153cd93 100644 --- a/generators/generator-base-docker.js +++ b/generators/generator-base-docker.js @@ -26,12 +26,10 @@ const statistics = require('./statistics'); const constants = require('./generator-constants'); -const { CONSUL, EUREKA } = require('../jdl/jhipster/service-discovery-types'); const { OptionNames } = require('../jdl/jhipster/application-options'); -const { PROMETHEUS, ELK } = require('../jdl/jhipster/monitoring-types'); const { Options: DeploymentOptions } = require('../jdl/jhipster/deployment-options'); -const { JWT_SECRET_KEY, SERVICE_DISCOVERY_TYPE } = OptionNames; +const { JWT_SECRET_KEY } = OptionNames; module.exports = class extends BlueprintBaseGenerator { constructor(args, opts, features) { @@ -146,28 +144,10 @@ module.exports = class extends BlueprintBaseGenerator { dest.directoryPath = config.directoryPath; dest.gatewayType = config.gatewayType; dest.clusteredDbApps = config.clusteredDbApps; - dest.monitoring = config.monitoring; dest.dockerRepositoryName = config.dockerRepositoryName; dest.dockerPushCommand = config.dockerPushCommand; - dest.serviceDiscoveryType = config[SERVICE_DISCOVERY_TYPE]; dest.adminPassword = config.adminPassword; dest.jwtSecretKey = config[JWT_SECRET_KEY]; - - if (dest.serviceDiscoveryType === undefined) { - dest.serviceDiscoveryType = EUREKA; - } - - this.loadDerivedDeploymentConfig(config, dest); - } - - loadDerivedDeploymentConfig( - config = _.defaults({}, this.jhipsterConfig, DeploymentOptions.defaults(this.jhipsterConfig.deploymentType)), - dest = this - ) { - dest.serviceDiscoveryConsul = config.serviceDiscoveryType === CONSUL; - dest.serviceDiscoveryEureka = config.serviceDiscoveryType === EUREKA; - - dest.monitoringPrometheus = config.monitoring === PROMETHEUS; - dest.monitoringELK = config.monitoring === ELK; + this.loadPlatformConfig(config, dest); } }; diff --git a/generators/generator-base.js b/generators/generator-base.js index 9d8b6a5ae35d..69c6ee3e0dca 100644 --- a/generators/generator-base.js +++ b/generators/generator-base.js @@ -52,6 +52,7 @@ const { ORACLE, MYSQL, POSTGRESQL, MARIADB, MSSQL, SQL, MONGODB, COUCHBASE, NEO4 const NO_DATABASE = databaseTypes.NO; const { GENERATOR_BOOTSTRAP } = require('./generator-list'); +const { PROMETHEUS, ELK } = require('../jdl/jhipster/monitoring-types'); const { JWT, OAUTH2, SESSION } = require('../jdl/jhipster/authentication-types'); const { EHCACHE, REDIS, HAZELCAST, MEMCACHED } = require('../jdl/jhipster/cache-types'); const { GRADLE, MAVEN } = require('../jdl/jhipster/build-tool-types'); @@ -2610,6 +2611,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; dest.databaseType = config.databaseType; dest.devDatabaseType = config.devDatabaseType; dest.prodDatabaseType = config.prodDatabaseType; + dest.reactive = config.reactive; dest.searchEngine = config.searchEngine; dest.cacheProvider = config.cacheProvider; dest.enableHibernateCache = config.enableHibernateCache; @@ -2617,8 +2619,6 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; dest.enableSwaggerCodegen = config.enableSwaggerCodegen; dest.messageBroker = config.messageBroker; dest.websocket = config.websocket; - dest.serviceDiscoveryType = config.serviceDiscoveryType; - dest.embeddableLaunchScript = config.embeddableLaunchScript; this.loadDerivedServerConfig(dest); @@ -2639,8 +2639,14 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; dest.devDatabaseTypeH2Any = dest.devDatabaseTypeH2Disk || dest.devDatabaseTypeH2Memory; dest.devDatabaseTypeCouchbase = dest.devDatabaseType === COUCHBASE; - dest.prodDatabaseTypeMysql = dest.prodDatabaseType === MYSQL; + dest.prodDatabaseTypeCouchbase = dest.prodDatabaseType === COUCHBASE; + dest.prodDatabaseTypeH2Disk = dest.prodDatabaseType === H2_DISK; dest.prodDatabaseTypeMariadb = dest.prodDatabaseType === MARIADB; + dest.prodDatabaseTypeMongodb = dest.prodDatabaseType === MONGODB; + dest.prodDatabaseTypeMssql = dest.prodDatabaseType === MSSQL; + dest.prodDatabaseTypeMysql = dest.prodDatabaseType === MYSQL; + dest.prodDatabaseTypeNeo4j = dest.prodDatabaseType === NEO4J; + dest.prodDatabaseTypeOracle = dest.prodDatabaseType === ORACLE; dest.prodDatabaseTypePostgres = dest.prodDatabaseType === POSTGRESQL; dest.databaseTypeNo = dest.databaseType === NO_DATABASE; @@ -2661,11 +2667,8 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; dest.messageBrokerKafka = dest.messageBroker === KAFKA; - dest.serviceDiscoveryConsul = dest.serviceDiscoveryType === CONSUL; - dest.serviceDiscoveryEureka = dest.serviceDiscoveryType === EUREKA; - - dest.searchEngineElasticsearch = dest.searchEngine === ELASTICSEARCH; dest.searchEngineCouchbase = dest.searchEngine === COUCHBASE; + dest.searchEngineElasticsearch = dest.searchEngine === ELASTICSEARCH; dest.reactiveSqlTestContainers = dest.reactive && @@ -2673,7 +2676,18 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; [MYSQL, POSTGRESQL, MSSQL, MARIADB].includes(dest.devDatabaseType)); } - loadPlatformConfig(config = _.defaults({}, this.jhipsterConfig, defaultConfig), dest = this) {} + loadPlatformConfig(config = _.defaults({}, this.jhipsterConfig, defaultConfig), dest = this) { + dest.serviceDiscoveryType = config.serviceDiscoveryType; + dest.monitoring = config.monitoring; + this.loadDerivedPlatformConfig(dest); + } + + loadDerivedPlatformConfig(dest = this) { + dest.serviceDiscoveryConsul = dest.serviceDiscoveryType === CONSUL; + dest.serviceDiscoveryEureka = dest.serviceDiscoveryType === EUREKA; + dest.monitoringELK = dest.monitoring === ELK; + dest.monitoringPrometheus = dest.monitoring === PROMETHEUS; + } /** * Get all the generator configuration from the .yo-rc.json file @@ -2737,7 +2751,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; return { ...defaultApplicationOptions.getConfigForApplicationType(applicationType), ...defaultConfig }; } - setConfigDefaults(defaults = this.jhipsterConfig.applicationType !== MICROSERVICE ? defaultConfig : defaultConfigMicroservice) { + setConfigDefaults(defaults = this.jhipsterConfig.applicationType === MICROSERVICE ? defaultConfigMicroservice : defaultConfig) { const jhipsterVersion = packagejs.version; const baseName = this.getDefaultAppName(); const creationTimestamp = new Date().getTime(); diff --git a/generators/generator-list.js b/generators/generator-list.js index 957160fec525..53b73f77bf7d 100644 --- a/generators/generator-list.js +++ b/generators/generator-list.js @@ -38,6 +38,10 @@ const Generators = { GENERATOR_ENTITY_SERVER: 'entity-server', GENERATOR_EXPORT_JDL: 'export-jdl', GENERATOR_GAE: 'gae', + GENERATOR_HEROKU: 'heroku', + GENERATOR_KUBERNETES: 'kubernetes', + GENERATOR_KUBERNETES_HELM: 'kubernetes-helm', + GENERATOR_KUBERNETES_KNATIVE: 'kubernetes-knative', GENERATOR_INIT: 'init', GENERATOR_LANGUAGES: 'languages', GENERATOR_PAGE: 'page', diff --git a/generators/heroku/index.js b/generators/heroku/index.js index 50546f41a185..7b8bdae4b650 100644 --- a/generators/heroku/index.js +++ b/generators/heroku/index.js @@ -24,12 +24,19 @@ const ChildProcess = require('child_process'); const util = require('util'); const chalk = require('chalk'); const glob = require('glob'); - const BaseBlueprintGenerator = require('../generator-base-blueprint'); const statistics = require('../statistics'); - const constants = require('../generator-constants'); - +const cacheProviderOptions = require('../../jdl/jhipster/cache-types'); +const { MEMCACHED, REDIS } = require('../../jdl/jhipster/cache-types'); +const { OAUTH2 } = require('../../jdl/jhipster/authentication-types'); +const { GRADLE, MAVEN } = require('../../jdl/jhipster/build-tool-types'); +const { ELASTICSEARCH } = require('../../jdl/jhipster/search-engine-types'); +const { GENERATOR_HEROKU } = require('../generator-list'); +const { MARIADB, MYSQL, POSTGRESQL } = require('../../jdl/jhipster/database-types'); +const { EUREKA } = require('../../jdl/jhipster/service-discovery-types'); + +const NO_CACHE_PROVIDER = cacheProviderOptions.NO; const execCmd = util.promisify(ChildProcess.exec); let useBlueprints; @@ -58,7 +65,7 @@ module.exports = class extends BaseBlueprintGenerator { this.herokuSkipBuild = this.options.skipBuild; this.herokuSkipDeploy = this.options.skipDeploy || this.options.skipBuild; - useBlueprints = !this.fromBlueprint && this.instantiateBlueprints('heroku'); + useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_HEROKU); } _initializing() { @@ -67,24 +74,19 @@ module.exports = class extends BaseBlueprintGenerator { this.checkInvocationFromCLI(); }, + loadCommonConfig() { + this.loadAppConfig(); + this.loadServerConfig(); + this.loadPlatformConfig(); + }, + initializing() { this.log(chalk.bold('Heroku configuration is starting')); const configuration = this.config; this.env.options.appPath = configuration.get('appPath') || constants.CLIENT_MAIN_SRC_DIR; - this.baseName = configuration.get('baseName'); - this.packageName = configuration.get('packageName'); - this.packageFolder = configuration.get('packageFolder'); - this.cacheProvider = configuration.get('cacheProvider') || 'no'; - this.enableHibernateCache = configuration.get('enableHibernateCache') && !['no', 'memcached'].includes(this.cacheProvider); - this.databaseType = configuration.get('databaseType'); - this.prodDatabaseType = configuration.get('prodDatabaseType'); - this.searchEngine = configuration.get('searchEngine'); + this.cacheProvider = this.cacheProvider || NO_CACHE_PROVIDER; + this.enableHibernateCache = this.enableHibernateCache && ![NO_CACHE_PROVIDER, MEMCACHED].includes(this.cacheProvider); this.frontendAppName = this.getFrontendAppName(); - this.buildTool = configuration.get('buildTool'); - this.applicationType = configuration.get('applicationType'); - this.reactive = configuration.get('reactive') || false; - this.serviceDiscoveryType = configuration.get('serviceDiscoveryType'); - this.authenticationType = configuration.get('authenticationType'); this.herokuAppName = configuration.get('herokuAppName'); this.dynoSize = 'Free'; this.herokuDeployType = configuration.get('herokuDeployType'); @@ -221,7 +223,7 @@ module.exports = class extends BaseBlueprintGenerator { }, askForOkta() { if (this.abort) return null; - if (this.authenticationType !== 'oauth2') return null; + if (this.authenticationType !== OAUTH2) return null; if (this.useOkta) return null; const prompts = [ { @@ -309,10 +311,30 @@ module.exports = class extends BaseBlueprintGenerator { return this._configuring(); } + // Public API method used by the getter and also by Blueprints + _loading() { + return { + loadSharedConfig() { + this.loadAppConfig(); + this.loadDerivedAppConfig(); + this.loadClientConfig(); + this.loadDerivedClientConfig(); + this.loadServerConfig(); + this.loadTranslationConfig(); + this.loadPlatformConfig(); + }, + }; + } + + get loading() { + if (useBlueprints) return; + return this._loading(); + } + _default() { return { insight() { - statistics.sendSubGenEvent('generator', 'heroku'); + statistics.sendSubGenEvent('generator', GENERATOR_HEROKU); }, gitInit() { @@ -476,7 +498,7 @@ module.exports = class extends BaseBlueprintGenerator { }; this.log(chalk.bold('\nProvisioning addons')); - if (this.searchEngine === 'elasticsearch') { + if (this.searchEngine === ELASTICSEARCH) { ChildProcess.exec( `heroku addons:create bonsai:sandbox --as BONSAI --app ${this.herokuAppName}`, addonCreateCallback.bind(this, 'Elasticsearch') @@ -490,11 +512,11 @@ module.exports = class extends BaseBlueprintGenerator { } let dbAddOn; - if (this.prodDatabaseType === 'postgresql') { + if (this.prodDatabaseType === POSTGRESQL) { dbAddOn = 'heroku-postgresql --as DATABASE'; - } else if (this.prodDatabaseType === 'mysql') { + } else if (this.prodDatabaseType === MYSQL) { dbAddOn = 'jawsdb:kitefin --as DATABASE'; - } else if (this.prodDatabaseType === 'mariadb') { + } else if (this.prodDatabaseType === MARIADB) { dbAddOn = 'jawsdb-maria:kitefin --as DATABASE'; } @@ -508,9 +530,9 @@ module.exports = class extends BaseBlueprintGenerator { } let cacheAddOn; - if (this.cacheProvider === 'memcached') { + if (this.cacheProvider === MEMCACHED) { cacheAddOn = 'memcachier:dev --as MEMCACHIER'; - } else if (this.cacheProvider === 'redis') { + } else if (this.cacheProvider === REDIS) { cacheAddOn = 'heroku-redis:hobby-dev --as REDIS'; } @@ -529,12 +551,13 @@ module.exports = class extends BaseBlueprintGenerator { configureJHipsterRegistry() { if (this.abort || this.herokuAppExists) return undefined; - if (this.serviceDiscoveryType === 'eureka') { + if (this.serviceDiscoveryType === EUREKA) { const prompts = [ { type: 'input', name: 'herokuJHipsterRegistryApp', message: 'What is the name of your JHipster Registry Heroku application?', + default: 'jhipster-registry', }, { type: 'input', @@ -546,6 +569,7 @@ module.exports = class extends BaseBlueprintGenerator { type: 'input', name: 'herokuJHipsterRegistryPassword', message: 'What is your JHipster Registry password?', + default: 'password', }, ]; @@ -570,7 +594,16 @@ module.exports = class extends BaseBlueprintGenerator { } return undefined; }, + }; + } + get default() { + if (useBlueprints) return; + return this._default(); + } + + _writing() { + return { copyHerokuFiles() { if (this.abort) return; @@ -580,7 +613,7 @@ module.exports = class extends BaseBlueprintGenerator { this.template('application-heroku.yml.ejs', `${constants.SERVER_MAIN_RES_DIR}/config/application-heroku.yml`); this.template('Procfile.ejs', 'Procfile'); this.template('system.properties.ejs', 'system.properties'); - if (this.buildTool === 'gradle') { + if (this.buildTool === GRADLE) { this.template('heroku.gradle.ejs', 'gradle/heroku.gradle'); } if (this.useOkta) { @@ -595,14 +628,14 @@ module.exports = class extends BaseBlueprintGenerator { addHerokuBuildPlugin() { if (this.abort) return; - if (this.buildTool !== 'gradle') return; + if (this.buildTool !== GRADLE) return; this.addGradlePlugin('gradle.plugin.com.heroku.sdk', 'heroku-gradle', '1.0.4'); this.applyFromGradleScript('gradle/heroku'); }, addHerokuMavenProfile() { if (this.abort) return; - if (this.buildTool === 'maven') { + if (this.buildTool === MAVEN) { this.render('pom-profile.xml.ejs', profile => { this.addMavenProfile('heroku', ` ${profile.toString().trim()}`); }); @@ -611,9 +644,9 @@ module.exports = class extends BaseBlueprintGenerator { }; } - get default() { + get writing() { if (useBlueprints) return; - return this._default(); + return this._writing(); } _end() { @@ -697,7 +730,7 @@ module.exports = class extends BaseBlueprintGenerator { let buildpack = 'heroku/java'; let configVars = 'MAVEN_CUSTOM_OPTS="-Pprod,heroku -DskipTests" '; - if (this.buildTool === 'gradle') { + if (this.buildTool === GRADLE) { buildpack = 'heroku/gradle'; configVars = 'GRADLE_TASK="stage -Pprod -PnodeInstall" '; } @@ -766,7 +799,7 @@ module.exports = class extends BaseBlueprintGenerator { } else { this.log(chalk.bold('\nDeploying application')); let jarFileWildcard = 'target/*.jar'; - if (this.buildTool === 'gradle') { + if (this.buildTool === GRADLE) { jarFileWildcard = 'build/libs/*.jar'; } diff --git a/generators/heroku/templates/Procfile.ejs b/generators/heroku/templates/Procfile.ejs index 0ba778f1d224..e07fe2c20ac8 100644 --- a/generators/heroku/templates/Procfile.ejs +++ b/generators/heroku/templates/Procfile.ejs @@ -16,4 +16,4 @@ See the License for the specific language governing permissions and limitations under the License. -%> -web: java $JAVA_OPTS <% if (applicationType === 'gateway' || dynoSize === 'Free') { %>-Xmx256m<% } %> -jar <% if (buildTool === 'maven') { %>target<% } %><% if (buildTool === 'gradle') { %>build/libs<% } %>/*.jar --spring.profiles.active=prod,heroku <% if (prodDatabaseType === 'mongodb') { %>--spring.data.mongodb.database=$(echo "$MONGODB_URI" | sed "s/^.*:[0-9]*\///g")<% } %> +web: java $JAVA_OPTS <% if (applicationTypeGateway || dynoSize === 'Free') { %>-Xmx256m<% } %> -jar <% if (buildToolMaven) { %>target<% } %><% if (buildToolGradle) { %>build/libs<% } %>/*.jar --spring.profiles.active=prod,heroku<% if (prodDatabaseTypeMongodb) { %> --spring.data.mongodb.database=$(echo "$MONGODB_URI" | sed "s/^.*:[0-9]*\///g")<% } %> diff --git a/generators/heroku/templates/application-heroku.yml.ejs b/generators/heroku/templates/application-heroku.yml.ejs index 58adb9269a1c..e8450b050b84 100644 --- a/generators/heroku/templates/application-heroku.yml.ejs +++ b/generators/heroku/templates/application-heroku.yml.ejs @@ -29,30 +29,30 @@ # =================================================================== eureka: -<%_ if (applicationType !== 'gateway') { _%> +<%_ if (!applicationTypeGateway) { _%> instance: hostname: <%= herokuAppName %>.herokuapp.com non-secure-port: 80 prefer-ip-address: false <%_ } _%> -<%_ if (serviceDiscoveryType === 'eureka') { _%> +<%_ if (serviceDiscoveryEureka) { _%> client: service-url: defaultZone: ${JHIPSTER_REGISTRY_URL}/eureka/ <%_ } _%> -<%_ if (cacheProvider === 'memcached' || cacheProvider === 'redis') { _%> +<%_ if (cacheProviderMemcached || cacheProviderRedis) { _%> jhipster: cache: - <%_ if (cacheProvider === 'redis') { _%> + <%_ if (cacheProviderRedis) { _%> redis: server: ${REDIS_URL} cluster: false connectionPoolSize: 3 connectionMinimumIdleSize: 1 subscriptionConnectionPoolSize: 3 - <%_ } _%> - <%_ if (cacheProvider === 'memcached') { _%> + <%_ } _%> + <%_ if (cacheProviderMemcached) { _%> memcached: enabled: true servers: ${MEMCACHIER_SERVERS} @@ -62,10 +62,10 @@ jhipster: enabled: true username: ${MEMCACHIER_USERNAME} password: ${MEMCACHIER_PASSWORD} - <%_ } _%> + <%_ } _%> <%_ } _%> spring: -<%_ if (prodDatabaseType === 'postgresql' || prodDatabaseType === 'mysql' || prodDatabaseType === 'mariadb') { _%> +<%_ if (prodDatabaseTypePostgres || prodDatabaseTypeMysql || prodDatabaseTypeMariadb) { _%> datasource: type: com.zaxxer.hikari.HikariDataSource url: ${JDBC_DATABASE_URL} @@ -74,7 +74,7 @@ spring: hikari: maximumPoolSize: 8 <%_ } _%> -<%_ if (searchEngine === 'elasticsearch') { _%> +<%_ if (searchEngineElasticsearch) { _%> elasticsearch: rest: uris: ${BONSAI_URL} diff --git a/generators/heroku/templates/bootstrap-heroku.yml.ejs b/generators/heroku/templates/bootstrap-heroku.yml.ejs index c14589f96786..71cef0b86c81 100644 --- a/generators/heroku/templates/bootstrap-heroku.yml.ejs +++ b/generators/heroku/templates/bootstrap-heroku.yml.ejs @@ -16,10 +16,10 @@ # Spring Cloud Config bootstrap configuration for the "heroku" profile # =================================================================== -<%_ if (serviceDiscoveryType === 'eureka') { _%> +<%_ if (serviceDiscoveryEureka) { _%> spring: cloud: config: fail-fast: true uri: ${JHIPSTER_REGISTRY_URL}/config -<%_ } _%> \ No newline at end of file +<%_ } _%> diff --git a/generators/heroku/templates/pom-profile.xml.ejs b/generators/heroku/templates/pom-profile.xml.ejs index a0a4bffe6158..2636004dd76f 100644 --- a/generators/heroku/templates/pom-profile.xml.ejs +++ b/generators/heroku/templates/pom-profile.xml.ejs @@ -11,7 +11,7 @@ ${env.JDBC_DATABASE_USERNAME} ${env.JDBC_DATABASE_PASSWORD} - hibernate:spring:<%= packageName %>.domain?dialect=<% if (prodDatabaseType === 'mysql') { %>org.hibernate.dialect.MySQL8Dialect<% } else if (prodDatabaseType === 'mariadb') { %>org.hibernate.dialect.MariaDB103Dialect<% } else if (prodDatabaseType === 'postgresql') { %>tech.jhipster.domain.util.FixedPostgreSQL10Dialect<% } else if (prodDatabaseType === 'h2Disk') { %>org.hibernate.dialect.H2Dialect<% } else if (prodDatabaseType === 'oracle') { %>org.hibernate.dialect.Oracle12cDialect<% } else if (prodDatabaseType === 'mssql') { %>org.hibernate.dialect.SQLServer2012Dialect<% } %>&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy + hibernate:spring:<%= packageName %>.domain?dialect=<% if (prodDatabaseTypeMysql) { %>org.hibernate.dialect.MySQL8Dialect<% } else if (prodDatabaseTypeMariadb) { %>org.hibernate.dialect.MariaDB103Dialect<% } else if (prodDatabaseTypePostgres) { %>tech.jhipster.domain.util.FixedPostgreSQL10Dialect<% } else if (prodDatabaseTypeH2Disk) { %>org.hibernate.dialect.H2Dialect<% } else if (prodDatabaseTypeOracle) { %>org.hibernate.dialect.Oracle12cDialect<% } else if (prodDatabaseTypeMssql) { %>org.hibernate.dialect.SQLServer2012Dialect<% } %>&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy true debug false diff --git a/generators/kubernetes-base.js b/generators/kubernetes-base.js index 8885cad26a9c..3c987417b7e2 100644 --- a/generators/kubernetes-base.js +++ b/generators/kubernetes-base.js @@ -16,11 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +const _ = require('lodash'); + const shelljs = require('shelljs'); const chalk = require('chalk'); const crypto = require('crypto'); +const { defaultKubernetesConfig } = require('./kubernetes/kubernetes-constants'); const { loadFromYoRc } = require('./docker-base'); const constants = require('./generator-constants'); +const { MICROSERVICE } = require('../jdl/jhipster/application-types'); module.exports = { checkKubernetes, @@ -29,6 +33,7 @@ module.exports = { saveConfig, setupKubernetesConstants, setupHelmConstants, + derivedKubernetesPlatformProperties, }; function checkKubernetes() { @@ -79,24 +84,29 @@ function loadConfig() { } function saveConfig() { - this.config.set({ - appsFolders: this.appsFolders, - directoryPath: this.directoryPath, - clusteredDbApps: this.clusteredDbApps, - serviceDiscoveryType: this.serviceDiscoveryType, - jwtSecretKey: this.jwtSecretKey, - dockerRepositoryName: this.dockerRepositoryName, - dockerPushCommand: this.dockerPushCommand, - kubernetesNamespace: this.kubernetesNamespace, - kubernetesServiceType: this.kubernetesServiceType, - kubernetesUseDynamicStorage: this.kubernetesUseDynamicStorage, - kubernetesStorageClassName: this.kubernetesStorageClassName, - generatorType: this.generatorType, - ingressType: this.ingressType, - ingressDomain: this.ingressDomain, - monitoring: this.monitoring, - istio: this.istio, - }); + this.config.set( + _.defaults( + { + appsFolders: this.appsFolders, + directoryPath: this.directoryPath, + clusteredDbApps: this.clusteredDbApps, + serviceDiscoveryType: this.serviceDiscoveryType, + jwtSecretKey: this.jwtSecretKey, + dockerRepositoryName: this.dockerRepositoryName, + dockerPushCommand: this.dockerPushCommand, + kubernetesNamespace: this.kubernetesNamespace, + kubernetesServiceType: this.kubernetesServiceType, + kubernetesUseDynamicStorage: this.kubernetesUseDynamicStorage, + kubernetesStorageClassName: this.kubernetesStorageClassName, + generatorType: this.generatorType, + ingressType: this.ingressType, + ingressDomain: this.ingressDomain, + monitoring: this.monitoring, + istio: this.istio, + }, + defaultKubernetesConfig + ) + ); } function setupKubernetesConstants() { @@ -110,6 +120,14 @@ function setupKubernetesConstants() { this.KUBERNETES_RBAC_API_VERSION = constants.KUBERNETES_RBAC_API_VERSION; } +function derivedKubernetesPlatformProperties(dest = _.defaults({}, this, defaultKubernetesConfig)) { + dest.deploymentApplicationTypeMicroservice = dest.deploymentApplicationType === MICROSERVICE; + dest.ingressTypeNginx = dest.ingressType === 'nginx'; + dest.ingressTypeGke = dest.ingressType === 'gke'; + dest.kubernetesServiceTypeIngress = dest.kubernetesServiceType === 'Ingress'; + dest.kubernetesNamespaceDefault = dest.kubernetesNamespace === 'default'; +} + function setupHelmConstants() { this.HELM_KAFKA = constants.HELM_KAFKA; this.HELM_ELASTICSEARCH = constants.HELM_ELASTICSEARCH; diff --git a/generators/kubernetes-helm/index.js b/generators/kubernetes-helm/index.js index f55962a4d2a5..5176b833958c 100644 --- a/generators/kubernetes-helm/index.js +++ b/generators/kubernetes-helm/index.js @@ -16,23 +16,40 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable consistent-return */ const chalk = require('chalk'); const fs = require('fs'); const prompts = require('../kubernetes/prompts'); -const writeFiles = require('./files').writeFiles; +const { writeFiles } = require('./files'); const BaseDockerGenerator = require('../generator-base-docker'); +const { GENERATOR_KUBERNETES_HELM } = require('../generator-list'); +const { KAFKA } = require('../../jdl/jhipster/message-broker-types'); const { checkImages, generateJwtSecret, configureImageNames, setAppsFolderPaths } = require('../docker-base'); -const { checkKubernetes, checkHelm, loadConfig, saveConfig, setupKubernetesConstants, setupHelmConstants } = require('../kubernetes-base'); +const { + checkKubernetes, + checkHelm, + loadConfig, + saveConfig, + setupKubernetesConstants, + setupHelmConstants, + derivedKubernetesPlatformProperties, +} = require('../kubernetes-base'); const statistics = require('../statistics'); +let useBlueprints; module.exports = class extends BaseDockerGenerator { - get initializing() { + constructor(args, opts) { + super(args, opts); + useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_KUBERNETES_HELM); + } + + _initializing() { return { sayHello() { this.log(chalk.white(`${chalk.bold('⎈')} Welcome to the JHipster Kubernetes Helm Generator ${chalk.bold('⎈')}`)); this.log(chalk.white(`Files will be generated in folder: ${chalk.yellow(this.destinationRoot())}`)); }, - ...super.initializing, + ...super._initializing(), checkKubernetes, checkHelm, loadConfig, @@ -41,7 +58,12 @@ module.exports = class extends BaseDockerGenerator { }; } - get prompting() { + get initializing() { + if (useBlueprints) return; + return this._initializing(); + } + + _prompting() { return { askForApplicationType: prompts.askForApplicationType, askForPath: prompts.askForPath, @@ -60,10 +82,15 @@ module.exports = class extends BaseDockerGenerator { }; } - get configuring() { + get prompting() { + if (useBlueprints) return; + return this._prompting(); + } + + _configuring() { return { insight() { - statistics.sendSubGenEvent('generator', 'kubernetes-helm'); + statistics.sendSubGenEvent('generator', GENERATOR_KUBERNETES_HELM); }, checkImages, @@ -74,7 +101,7 @@ module.exports = class extends BaseDockerGenerator { setPostPromptProp() { this.appConfigs.forEach(element => { element.clusteredDb ? (element.dbPeerCount = 3) : (element.dbPeerCount = 1); - if (element.messageBroker === 'kafka') { + if (element.messageBroker === KAFKA) { this.useKafka = true; } }); @@ -83,49 +110,83 @@ module.exports = class extends BaseDockerGenerator { }; } - get writing() { - return writeFiles(); + get configuring() { + if (useBlueprints) return; + return this._configuring(); } - end() { - if (this.hasWarning) { - this.log(`\n${chalk.yellow.bold('WARNING!')} Helm configuration generated, but no Jib cache found`); - this.log('If you forgot to generate the Docker image for this application, please run:'); - this.log(this.warningMessage); - } else { - this.log(`\n${chalk.bold.green('Helm configuration successfully generated!')}`); - } + _loading() { + return { + loadSharedConfig() { + this.appConfigs.forEach(element => { + this.loadServerConfig(element); + this.loadDerivedServerConfig(element); + this.loadDerivedAppConfig(element); + }); + this.loadDeploymentConfig(this); + derivedKubernetesPlatformProperties(this); + }, + }; + } - this.log( - `${chalk.yellow.bold( - 'WARNING!' - )} You will need to push your image to a registry. If you have not done so, use the following commands to tag and push the images:` - ); - for (let i = 0; i < this.appsFolders.length; i++) { - const originalImageName = this.appConfigs[i].baseName.toLowerCase(); - const targetImageName = this.appConfigs[i].targetImageName; - if (originalImageName !== targetImageName) { - this.log(` ${chalk.cyan(`docker image tag ${originalImageName} ${targetImageName}`)}`); - } - this.log(` ${chalk.cyan(`${this.dockerPushCommand} ${targetImageName}`)}`); - } + get loading() { + if (useBlueprints) return; + return this._loading(); + } - this.log('\nYou can deploy all your apps by running the following script:'); - this.log(` ${chalk.cyan('bash helm-apply.sh')}`); + _writing() { + return writeFiles(); + } - this.log('\nYou can upgrade (after any changes) all your apps by running the following script:'); - this.log(` ${chalk.cyan('bash helm-upgrade.sh')}`); + get writing() { + if (useBlueprints) return; + return this._writing(); + } + + _end() { + return { + deploy() { + if (this.hasWarning) { + this.log(`\n${chalk.yellow.bold('WARNING!')} Helm configuration generated, but no Jib cache found`); + this.log('If you forgot to generate the Docker image for this application, please run:'); + this.log(this.warningMessage); + } else { + this.log(`\n${chalk.bold.green('Helm configuration successfully generated!')}`); + } + this.log( + `${chalk.yellow.bold( + 'WARNING!' + )} You will need to push your image to a registry. If you have not done so, use the following commands to tag and push the images:` + ); + for (let i = 0; i < this.appsFolders.length; i++) { + const originalImageName = this.appConfigs[i].baseName.toLowerCase(); + const targetImageName = this.appConfigs[i].targetImageName; + if (originalImageName !== targetImageName) { + this.log(` ${chalk.cyan(`docker image tag ${originalImageName} ${targetImageName}`)}`); + } + this.log(` ${chalk.cyan(`${this.dockerPushCommand} ${targetImageName}`)}`); + } + this.log('\nYou can deploy all your apps by running the following script:'); + this.log(` ${chalk.cyan('bash helm-apply.sh')}`); + this.log('\nYou can upgrade (after any changes) all your apps by running the following script:'); + this.log(` ${chalk.cyan('bash helm-upgrade.sh')}`); + // Make the apply script executable + try { + fs.chmodSync('helm-apply.sh', '755'); + fs.chmodSync('helm-upgrade.sh', '755'); + } catch (err) { + this.log( + `${chalk.yellow.bold( + 'WARNING!' + )}Failed to make 'helm-apply.sh', 'helm-upgrade.sh' executable, you may need to run 'chmod +x helm-apply.sh helm-upgrade.sh` + ); + } + }, + }; + } - // Make the apply script executable - try { - fs.chmodSync('helm-apply.sh', '755'); - fs.chmodSync('helm-upgrade.sh', '755'); - } catch (err) { - this.log( - `${chalk.yellow.bold( - 'WARNING!' - )}Failed to make 'helm-apply.sh', 'helm-upgrade.sh' executable, you may need to run 'chmod +x helm-apply.sh helm-upgrade.sh` - ); - } + get end() { + if (useBlueprints) return; + return this._end(); } }; diff --git a/generators/kubernetes-helm/templates/app/helpers.tpl.ejs b/generators/kubernetes-helm/templates/app/helpers.tpl.ejs index 68702417d49c..f000ed7050df 100644 --- a/generators/kubernetes-helm/templates/app/helpers.tpl.ejs +++ b/generators/kubernetes-helm/templates/app/helpers.tpl.ejs @@ -1,5 +1,5 @@ {{/* vim: set filetype=mustache: */}} -<%_ if (app.prodDatabaseType === 'mariadb') { _%> +<%_ if (app.prodDatabaseTypeMariadb) { _%> {{/* mariadb customisation */}} @@ -10,7 +10,7 @@ mariadb customisation {{- define "mariadb.fullname" -}} {{- default "<%= app.baseName.toLowerCase() %>-mariadb" -}} {{- end -}} -<%_ } else if (app.prodDatabaseType === 'mysql') { _%> +<%_ } else if (app.prodDatabaseTypeMysql) { _%> {{/* mysql customisation */}} @@ -21,7 +21,7 @@ mysql customisation {{- define "mysql.fullname" -}} {{- default "<%= app.baseName.toLowerCase() %>-mysql" -}} {{- end -}} -<%_ } else if (app.prodDatabaseType === 'postgresql') { _%> +<%_ } else if (app.prodDatabaseTypePostgres) { _%> {{/* postgresql customisation */}} @@ -32,7 +32,7 @@ postgresql customisation {{- define "postgresql.fullname" -}} {{- default "<%= app.baseName.toLowerCase() %>-postgresql" -}} {{- end -}} -<%_ } else if (app.prodDatabaseType === 'mongodb') { _%> +<%_ } else if (app.prodDatabaseTypeMongodb) { _%> {{/* mongodb customisation */}} @@ -43,7 +43,7 @@ mongodb customisation {{- define "mongodb-replicaset.fullname" -}} {{- default "<%= app.baseName.toLowerCase() %>-mongodb" -}} {{- end -}} -<%_ } else if (app.prodDatabaseType === 'couchbase') { _%> +<%_ } else if (app.prodDatabaseTypeCouchbase) { _%> {{/* couchdb customisation */}} diff --git a/generators/kubernetes-helm/templates/app/requirements.yml.ejs b/generators/kubernetes-helm/templates/app/requirements.yml.ejs index ff50e86f736c..0e9d184a96ae 100644 --- a/generators/kubernetes-helm/templates/app/requirements.yml.ejs +++ b/generators/kubernetes-helm/templates/app/requirements.yml.ejs @@ -1,20 +1,20 @@ dependencies: -<%_ if (app.prodDatabaseType === 'mysql') { _%> +<%_ if (app.prodDatabaseTypeMysql) { _%> - name: mysql version: <%= HELM_MYSQL %> repository: https://charts.helm.sh/stable condition: mysql.enabled -<%_ } else if (app.prodDatabaseType === 'postgresql') { _%> +<%_ } else if (app.prodDatabaseTypePostgres) { _%> - name: postgresql version: <%= HELM_POSTGRESQL %> repository: https://charts.helm.sh/stable condition: postgresql.enabled -<%_ } else if (app.prodDatabaseType === 'mariadb') { _%> +<%_ } else if (app.prodDatabaseTypeMariadb) { _%> - name: mariadb version: <%= HELM_MARIADB %> repository: https://charts.helm.sh/stable condition: mariadb.enabled -<%_ } else if (app.prodDatabaseType === 'mongodb') { _%> +<%_ } else if (app.prodDatabaseTypeMongodb) { _%> - name: mongodb-replicaset version: <%= HELM_MOGODB_REPLICASET %> repository: https://charts.helm.sh/stable diff --git a/generators/kubernetes-helm/templates/app/values.yml.ejs b/generators/kubernetes-helm/templates/app/values.yml.ejs index 2ba8bad8261f..f873373e93a7 100644 --- a/generators/kubernetes-helm/templates/app/values.yml.ejs +++ b/generators/kubernetes-helm/templates/app/values.yml.ejs @@ -1,4 +1,4 @@ -<%_ if (app.prodDatabaseType === 'mysql') { _%> +<%_ if (app.prodDatabaseTypeMysql) { _%> mysql: enabled: true mysqlDatabase: <%= app.baseName.toLowerCase() %> @@ -10,7 +10,7 @@ mysql: initializationFiles: grant.sql: |- grant all privileges on *.* to root@'%' identified by '' with grant option; -<%_ } else if (app.prodDatabaseType === 'postgresql') { _%> +<%_ } else if (app.prodDatabaseTypePostgres) { _%> postgresql: enabled: true postgresqlUsername: <%= app.baseName.toLowerCase() %> @@ -23,7 +23,7 @@ postgresql: podAnnotations: sidecar.istio.io/inject: "false" <%_ } _%> -<%_ } else if (app.prodDatabaseType === 'mariadb') { _%> +<%_ } else if (app.prodDatabaseTypeMariadb) { _%> mariadb: enabled: true replication: @@ -38,7 +38,7 @@ mariadb: annotations: sidecar.istio.io/inject: "false" <%_ } _%> -<%_ } else if (app.prodDatabaseType === 'mongodb') { _%> +<%_ } else if (app.prodDatabaseTypeMongodb) { _%> mongodb: enabled: true mongodb-replicaset: @@ -47,7 +47,7 @@ mongodb-replicaset: podAnnotations: sidecar.istio.io/inject: "false" <%_ } _%> -<%_ } else if (app.prodDatabaseType === 'couchbase') { _%> +<%_ } else if (app.prodDatabaseTypeCouchbase) { _%> couchdb: enabled: true allowAdminParty: true diff --git a/generators/kubernetes-helm/templates/csvc/helpers.tpl.ejs b/generators/kubernetes-helm/templates/csvc/helpers.tpl.ejs index 3fba5fad1ac1..18e67fa1df6c 100644 --- a/generators/kubernetes-helm/templates/csvc/helpers.tpl.ejs +++ b/generators/kubernetes-helm/templates/csvc/helpers.tpl.ejs @@ -23,7 +23,7 @@ Kafka and zookeeper customisation {{- default "jhipster-zookeeper" -}} {{- end -}} <%_ } _%> -<%_ if (monitoring === 'prometheus') { _%> +<%_ if (monitoringPrometheus) { _%> {{/* prometheus/grafana customisation */}} diff --git a/generators/kubernetes-helm/templates/csvc/requirements.yml.ejs b/generators/kubernetes-helm/templates/csvc/requirements.yml.ejs index 6d2bc74628d8..f80c8cd5eef4 100644 --- a/generators/kubernetes-helm/templates/csvc/requirements.yml.ejs +++ b/generators/kubernetes-helm/templates/csvc/requirements.yml.ejs @@ -5,7 +5,7 @@ dependencies: repository: https://charts.helm.sh/incubator condition: kafka.enabled <%_ } _%> -<%_ if (monitoring === 'prometheus') { _%> +<%_ if (monitoringPrometheus) { _%> - name: prometheus version: <%= HELM_PROMETHEUS %> repository: https://charts.helm.sh/stable diff --git a/generators/kubernetes-helm/templates/csvc/values.yml.ejs b/generators/kubernetes-helm/templates/csvc/values.yml.ejs index 0df2d67fff02..6478ed37c24f 100644 --- a/generators/kubernetes-helm/templates/csvc/values.yml.ejs +++ b/generators/kubernetes-helm/templates/csvc/values.yml.ejs @@ -14,7 +14,7 @@ kafka: sidecar.istio.io/inject: "false" <%_ } _%> <%_ } _%> -<%_ if (monitoring === 'prometheus') { _%> +<%_ if (monitoringPrometheus) { _%> prometheus: enabled: true server: @@ -36,7 +36,7 @@ grafana: podAnnotations: sidecar.istio.io/inject: "false" <%_ } _%> - <%_ if (!istio && kubernetesServiceType === 'Ingress') { _%> + <%_ if (!istio && kubernetesServiceTypeIngress) { _%> ingress: enabled: true hosts: diff --git a/generators/kubernetes-helm/templates/helm-apply.sh.ejs b/generators/kubernetes-helm/templates/helm-apply.sh.ejs index a7179b357314..c4545ccac9cb 100644 --- a/generators/kubernetes-helm/templates/helm-apply.sh.ejs +++ b/generators/kubernetes-helm/templates/helm-apply.sh.ejs @@ -55,7 +55,7 @@ helm install --name <%- appConfig.baseName.toLowerCase() %> ./<%- appConfig.bas fi <%_ }) _%> -<%_ if (istio && kubernetesServiceType === 'Ingress') { _%> +<%_ if (istio && kubernetesServiceTypeIngress) { _%> kubectl apply -f istio-${suffix}/ <%_ } _%> diff --git a/generators/kubernetes-helm/templates/helm-upgrade.sh.ejs b/generators/kubernetes-helm/templates/helm-upgrade.sh.ejs index b66cc08fc095..75a9ed7f02b6 100644 --- a/generators/kubernetes-helm/templates/helm-upgrade.sh.ejs +++ b/generators/kubernetes-helm/templates/helm-upgrade.sh.ejs @@ -30,7 +30,7 @@ helm dep up ./<%- appConfig.baseName.toLowerCase() %>-${suffix} helm upgrade --install <%- appConfig.baseName.toLowerCase() %> ./<%- appConfig.baseName.toLowerCase() %>-${suffix} --namespace <%- kubernetesNamespace %> <%_ }) _%> -<%_ if (istio && kubernetesServiceType === 'Ingress') { _%> +<%_ if (istio && kubernetesServiceTypeIngress) { _%> kubectl apply -f istio-${suffix}/ <%_ } _%> diff --git a/generators/kubernetes-knative/index.js b/generators/kubernetes-knative/index.js index 840aa1d08ade..775840f28b6c 100644 --- a/generators/kubernetes-knative/index.js +++ b/generators/kubernetes-knative/index.js @@ -16,24 +16,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable consistent-return */ const chalk = require('chalk'); const shelljs = require('shelljs'); const fs = require('fs'); const prompts = require('./prompts'); -const writeFiles = require('./files').writeFiles; +const { writeFiles } = require('./files'); const BaseDockerGenerator = require('../generator-base-docker'); +const { GENERATOR_KUBERNETES_KNATIVE } = require('../generator-list'); +const { MAVEN } = require('../../jdl/jhipster/build-tool-types'); +const { KAFKA } = require('../../jdl/jhipster/message-broker-types'); const { checkImages, generateJwtSecret, configureImageNames, setAppsFolderPaths } = require('../docker-base'); -const { checkHelm, checkKubernetes, loadConfig, saveConfig, setupKubernetesConstants, setupHelmConstants } = require('../kubernetes-base'); +const { + checkHelm, + checkKubernetes, + loadConfig, + saveConfig, + setupKubernetesConstants, + setupHelmConstants, + derivedKubernetesPlatformProperties, +} = require('../kubernetes-base'); const statistics = require('../statistics'); +let useBlueprints; module.exports = class extends BaseDockerGenerator { - get initializing() { + constructor(args, opts) { + super(args, opts); + useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_KUBERNETES_KNATIVE); + } + + _initializing() { return { sayHello() { this.log(chalk.white(`${chalk.bold('☸')} Welcome to the JHipster Kubernetes Knative Generator ${chalk.bold('☸')}`)); this.log(chalk.white(`Files will be generated in the folder: ${chalk.yellow(this.destinationRoot())}`)); }, - ...super.initializing, + ...super._initializing(), checkKubernetes, checkHelm, checkKnative() { @@ -63,7 +81,12 @@ module.exports = class extends BaseDockerGenerator { }; } - get prompting() { + get initializing() { + if (useBlueprints) return; + return this._initializing(); + } + + _prompting() { return { askForPath: prompts.askForPath, askForApps: prompts.askForApps, @@ -79,10 +102,15 @@ module.exports = class extends BaseDockerGenerator { }; } - get configuring() { + get prompting() { + if (useBlueprints) return; + return this._prompting(); + } + + _configuring() { return { insight() { - statistics.sendSubGenEvent('generator', 'k8s-knative'); + statistics.sendSubGenEvent('generator', GENERATOR_KUBERNETES_KNATIVE); }, checkImages, @@ -93,7 +121,7 @@ module.exports = class extends BaseDockerGenerator { setPostPromptProp() { this.appConfigs.forEach(element => { element.clusteredDb ? (element.dbPeerCount = 3) : (element.dbPeerCount = 1); - if (element.messageBroker === 'kafka') { + if (element.messageBroker === KAFKA) { this.useKafka = true; } }); @@ -102,78 +130,110 @@ module.exports = class extends BaseDockerGenerator { }; } - get writing() { - return writeFiles(); + get configuring() { + if (useBlueprints) return; + return this._configuring(); } - end() { - if (this.hasWarning) { - this.log(`\n${chalk.yellow.bold('WARNING!')} Kubernetes Knative configuration generated, but no Jib cache found`); - this.log('If you forgot to generate the Docker image for this application, please run:'); - this.log(this.warningMessage); - } else { - this.log(`\n${chalk.bold.green('Kubernetes Knative configuration successfully generated!')}`); - } - - this.log( - `\n${chalk.yellow.bold( - 'WARNING!' - )} You will need to push your image to a registry. If you have not done so, use the following commands to tag and push the images:` - ); - for (let i = 0; i < this.appsFolders.length; i++) { - const originalImageName = this.appConfigs[i].baseName.toLowerCase(); - const targetImageName = this.appConfigs[i].targetImageName; - if (originalImageName !== targetImageName) { - this.log(` ${chalk.cyan(`docker image tag ${originalImageName} ${targetImageName}`)}`); - } - this.log(` ${chalk.cyan(`${this.dockerPushCommand} ${targetImageName}`)}`); - } + _loading() { + return { + loadSharedConfig() { + this.appConfigs.forEach(element => { + this.loadServerConfig(element); + this.loadDerivedServerConfig(element); + this.loadDerivedAppConfig(element); + }); + this.loadDeploymentConfig(this); + derivedKubernetesPlatformProperties(this); + }, + }; + } - if (this.dockerRepositoryName) { - this.log(`\n${chalk.green.bold('INFO!')} Alternatively, you can use Jib to build and push image directly to a remote registry:`); - this.appsFolders.forEach((appsFolder, index) => { - const appConfig = this.appConfigs[index]; - let runCommand = ''; - if (appConfig.buildTool === 'maven') { - runCommand = `./mvnw -ntp -Pprod verify jib:build -Djib.to.image=${appConfig.targetImageName}`; - } else { - runCommand = `./gradlew bootJar -Pprod jibBuild -Djib.to.image=${appConfig.targetImageName}`; - } - this.log(` ${chalk.cyan(`${runCommand}`)} in ${this.destinationPath(this.directoryPath + appsFolder)}`); - }); - } + get loading() { + if (useBlueprints) return; + return this._loading(); + } - this.log('\nYou can deploy all your apps by running the following script:'); + _writing() { + return writeFiles(); + } - if (this.generatorType === 'k8s') { - this.log(` ${chalk.cyan('bash kubectl-knative-apply.sh')}`); + get writing() { + if (useBlueprints) return; + return this._writing(); + } - // Make the apply script executable - try { - fs.chmodSync('kubectl-knative-apply.sh', '755'); - } catch (err) { + _end() { + return { + deploy() { + if (this.hasWarning) { + this.log(`\n${chalk.yellow.bold('WARNING!')} Kubernetes Knative configuration generated, but no Jib cache found`); + this.log('If you forgot to generate the Docker image for this application, please run:'); + this.log(this.warningMessage); + } else { + this.log(`\n${chalk.bold.green('Kubernetes Knative configuration successfully generated!')}`); + } this.log( - `${chalk.yellow.bold( + `\n${chalk.yellow.bold( 'WARNING!' - )}Failed to make 'kubectl-knative-apply.sh' executable, you may need to run 'chmod +x kubectl-knative-apply.sh'` + )} You will need to push your image to a registry. If you have not done so, use the following commands to tag and push the images:` ); - } - } else { - this.log(` ${chalk.cyan('bash helm-knative-apply.sh or ./helm-knative-apply.sh')}`); - this.log('\nYou can upgrade (after any changes) all your apps by running the following script:'); - this.log(` ${chalk.cyan('bash helm-knative-upgrade.sh or ./helm-knative-upgrade.sh')}`); + for (let i = 0; i < this.appsFolders.length; i++) { + const originalImageName = this.appConfigs[i].baseName.toLowerCase(); + const targetImageName = this.appConfigs[i].targetImageName; + if (originalImageName !== targetImageName) { + this.log(` ${chalk.cyan(`docker image tag ${originalImageName} ${targetImageName}`)}`); + } + this.log(` ${chalk.cyan(`${this.dockerPushCommand} ${targetImageName}`)}`); + } + if (this.dockerRepositoryName) { + this.log(`\n${chalk.green.bold('INFO!')} Alternatively, you can use Jib to build and push image directly to a remote registry:`); + this.appsFolders.forEach((appsFolder, index) => { + const appConfig = this.appConfigs[index]; + let runCommand = ''; + if (appConfig.buildTool === MAVEN) { + runCommand = `./mvnw -ntp -Pprod verify jib:build -Djib.to.image=${appConfig.targetImageName}`; + } else { + runCommand = `./gradlew bootJar -Pprod jibBuild -Djib.to.image=${appConfig.targetImageName}`; + } + this.log(` ${chalk.cyan(`${runCommand}`)} in ${this.destinationPath(this.directoryPath + appsFolder)}`); + }); + } + this.log('\nYou can deploy all your apps by running the following script:'); + if (this.generatorType === 'k8s') { + this.log(` ${chalk.cyan('bash kubectl-knative-apply.sh')}`); + // Make the apply script executable + try { + fs.chmodSync('kubectl-knative-apply.sh', '755'); + } catch (err) { + this.log( + `${chalk.yellow.bold( + 'WARNING!' + )}Failed to make 'kubectl-knative-apply.sh' executable, you may need to run 'chmod +x kubectl-knative-apply.sh'` + ); + } + } else { + this.log(` ${chalk.cyan('bash helm-knative-apply.sh or ./helm-knative-apply.sh')}`); + this.log('\nYou can upgrade (after any changes) all your apps by running the following script:'); + this.log(` ${chalk.cyan('bash helm-knative-upgrade.sh or ./helm-knative-upgrade.sh')}`); + // Make the apply script executable + try { + fs.chmodSync('helm-knative-apply.sh', '755'); + fs.chmodSync('helm-knative-upgrade.sh', '755'); + } catch (err) { + this.log( + `${chalk.yellow.bold( + 'WARNING!' + )}Failed to make 'helm-knative-apply.sh', 'helm-knative-upgrade.sh' executable, you may need to run 'chmod +x helm-knative-apply.sh helm-knative-upgrade.sh` + ); + } + } + }, + }; + } - // Make the apply script executable - try { - fs.chmodSync('helm-knative-apply.sh', '755'); - fs.chmodSync('helm-knative-upgrade.sh', '755'); - } catch (err) { - this.log( - `${chalk.yellow.bold( - 'WARNING!' - )}Failed to make 'helm-knative-apply.sh', 'helm-knative-upgrade.sh' executable, you may need to run 'chmod +x helm-knative-apply.sh helm-knative-upgrade.sh` - ); - } - } + get end() { + if (useBlueprints) return; + return this._end(); } }; diff --git a/generators/kubernetes/files.js b/generators/kubernetes/files.js index be09793e9892..c8283f29c334 100644 --- a/generators/kubernetes/files.js +++ b/generators/kubernetes/files.js @@ -17,6 +17,15 @@ * limitations under the License. */ +const { ELASTICSEARCH } = require('../../jdl/jhipster/search-engine-types'); +const { GATEWAY, MONOLITH } = require('../../jdl/jhipster/application-types'); +const { JWT } = require('../../jdl/jhipster/authentication-types'); +const { PROMETHEUS } = require('../../jdl/jhipster/monitoring-types'); +const { CONSUL, EUREKA } = require('../../jdl/jhipster/service-discovery-types'); +const databaseTypes = require('../../jdl/jhipster/database-types'); + +const NO_DATABASE = databaseTypes.NO; + module.exports = { writeFiles, }; @@ -32,23 +41,23 @@ function writeFiles() { this.template('deployment.yml.ejs', `${appOut}/${appName}-deployment.yml`); this.template('service.yml.ejs', `${appOut}/${appName}-service.yml`); // If we choose microservice with no DB, it is trying to move _no.yml as prodDatabaseType is getting tagged as 'string' type - if (this.app.prodDatabaseType !== 'no') { + if (this.app.prodDatabaseType !== NO_DATABASE) { this.template(`db/${this.app.prodDatabaseType}.yml.ejs`, `${appOut}/${appName}-${this.app.prodDatabaseType}.yml`); } - if (this.app.searchEngine === 'elasticsearch') { + if (this.app.searchEngine === ELASTICSEARCH) { this.template('db/elasticsearch.yml.ejs', `${appOut}/${appName}-elasticsearch.yml`); } - if (this.app.applicationType === 'gateway' || this.app.applicationType === 'monolith') { + if (this.app.applicationType === GATEWAY || this.app.applicationType === MONOLITH) { if (this.istio) { this.template('istio/gateway.yml.ejs', `${appOut}/${appName}-gateway.yml`); } else if (this.kubernetesServiceType === 'Ingress') { this.template('ingress.yml.ejs', `${appOut}/${appName}-ingress.yml`); } } - if (!this.app.serviceDiscoveryType && this.app.authenticationType === 'jwt') { + if (!this.app.serviceDiscoveryType && this.app.authenticationType === JWT) { this.template('secret/jwt-secret.yml.ejs', `${appOut}/jwt-secret.yml`); } - if (this.monitoring === 'prometheus') { + if (this.monitoring === PROMETHEUS) { this.template('monitoring/jhipster-prometheus-sm.yml.ejs', `${appOut}/${appName}-prometheus-sm.yml`); } if (this.istio) { @@ -75,7 +84,7 @@ function writeFiles() { writePrometheusGrafanaFiles() { const monitOut = 'monitoring'.concat('-', suffix); - if (this.monitoring === 'prometheus') { + if (this.monitoring === PROMETHEUS) { this.template('monitoring/jhipster-prometheus-crd.yml.ejs', `${monitOut}/jhipster-prometheus-crd.yml`); this.template('monitoring/jhipster-prometheus-cr.yml.ejs', `${monitOut}/jhipster-prometheus-cr.yml`); this.template('monitoring/jhipster-grafana.yml.ejs', `${monitOut}/jhipster-grafana.yml`); @@ -88,10 +97,10 @@ function writeFiles() { writeRegistryFiles() { const registryOut = 'registry'.concat('-', suffix); - if (this.serviceDiscoveryType === 'eureka') { + if (this.serviceDiscoveryType === EUREKA) { this.template('registry/jhipster-registry.yml.ejs', `${registryOut}/jhipster-registry.yml`); this.template('registry/application-configmap.yml.ejs', `${registryOut}/application-configmap.yml`); - } else if (this.serviceDiscoveryType === 'consul') { + } else if (this.serviceDiscoveryType === CONSUL) { this.template('registry/consul.yml.ejs', `${registryOut}/consul.yml`); this.template('registry/consul-config-loader.yml.ejs', `${registryOut}/consul-config-loader.yml`); this.template('registry/application-configmap.yml.ejs', `${registryOut}/application-configmap.yml`); diff --git a/generators/kubernetes/index.js b/generators/kubernetes/index.js index f0d1f2882ec0..dbd164996f03 100644 --- a/generators/kubernetes/index.js +++ b/generators/kubernetes/index.js @@ -16,30 +16,51 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable consistent-return */ const chalk = require('chalk'); const fs = require('fs'); const prompts = require('./prompts'); -const writeFiles = require('./files').writeFiles; +const { writeFiles } = require('./files'); const BaseDockerGenerator = require('../generator-base-docker'); +const { KAFKA } = require('../../jdl/jhipster/message-broker-types'); +const { GENERATOR_KUBERNETES } = require('../generator-list'); +const { MAVEN } = require('../../jdl/jhipster/build-tool-types'); const { checkImages, generateJwtSecret, configureImageNames, setAppsFolderPaths } = require('../docker-base'); -const { checkKubernetes, loadConfig, saveConfig, setupKubernetesConstants } = require('../kubernetes-base'); +const { + checkKubernetes, + loadConfig, + saveConfig, + setupKubernetesConstants, + derivedKubernetesPlatformProperties, +} = require('../kubernetes-base'); const statistics = require('../statistics'); +let useBlueprints; module.exports = class extends BaseDockerGenerator { - get initializing() { + constructor(args, opts) { + super(args, opts); + useBlueprints = !this.fromBlueprint && this.instantiateBlueprints(GENERATOR_KUBERNETES); + } + + _initializing() { return { sayHello() { this.log(chalk.white(`${chalk.bold('⎈')} Welcome to the JHipster Kubernetes Generator ${chalk.bold('⎈')}`)); this.log(chalk.white(`Files will be generated in folder: ${chalk.yellow(this.destinationRoot())}`)); }, - ...super.initializing, + ...super._initializing(), checkKubernetes, loadConfig, setupKubernetesConstants, }; } - get prompting() { + get initializing() { + if (useBlueprints) return; + return this._initializing(); + } + + _prompting() { return { askForApplicationType: prompts.askForApplicationType, askForPath: prompts.askForPath, @@ -60,10 +81,15 @@ module.exports = class extends BaseDockerGenerator { }; } - get configuring() { + get prompting() { + if (useBlueprints) return; + return this._prompting(); + } + + _configuring() { return { insight() { - statistics.sendSubGenEvent('generator', 'kubernetes'); + statistics.sendSubGenEvent('generator', GENERATOR_KUBERNETES); }, checkImages, @@ -74,7 +100,7 @@ module.exports = class extends BaseDockerGenerator { setPostPromptProp() { this.appConfigs.forEach(element => { element.clusteredDb ? (element.dbPeerCount = 3) : (element.dbPeerCount = 1); - if (element.messageBroker === 'kafka') { + if (element.messageBroker === KAFKA) { this.useKafka = true; } }); @@ -83,69 +109,106 @@ module.exports = class extends BaseDockerGenerator { }; } - get writing() { + get configuring() { + if (useBlueprints) return; + return this._configuring(); + } + + _loading() { + return { + loadSharedConfig() { + this.appConfigs.forEach(element => { + this.loadServerConfig(element); + this.loadDerivedServerConfig(element); + this.loadDerivedAppConfig(element); + }); + this.loadDeploymentConfig(this); + derivedKubernetesPlatformProperties(this); + }, + }; + } + + get loading() { + if (useBlueprints) return; + return this._loading(); + } + + _writing() { return writeFiles(); } - end() { - if (this.hasWarning) { - this.log(`\n${chalk.yellow.bold('WARNING!')} Kubernetes configuration generated, but no Jib cache found`); - this.log('If you forgot to generate the Docker image for this application, please run:'); - this.log(this.warningMessage); - } else { - this.log(`\n${chalk.bold.green('Kubernetes configuration successfully generated!')}`); - } - - this.log( - `\n${chalk.yellow.bold( - 'WARNING!' - )} You will need to push your image to a registry. If you have not done so, use the following commands to tag and push the images:` - ); - for (let i = 0; i < this.appsFolders.length; i++) { - const originalImageName = this.appConfigs[i].baseName.toLowerCase(); - const targetImageName = this.appConfigs[i].targetImageName; - if (originalImageName !== targetImageName) { - this.log(` ${chalk.cyan(`docker image tag ${originalImageName} ${targetImageName}`)}`); - } - this.log(` ${chalk.cyan(`${this.dockerPushCommand} ${targetImageName}`)}`); - } - - if (this.dockerRepositoryName) { - this.log(`\n${chalk.green.bold('INFO!')} Alternatively, you can use Jib to build and push image directly to a remote registry:`); - this.appsFolders.forEach((appsFolder, index) => { - const appConfig = this.appConfigs[index]; - let runCommand = ''; - if (appConfig.buildTool === 'maven') { - runCommand = `./mvnw -ntp -Pprod verify jib:build -Djib.to.image=${appConfig.targetImageName}`; + get writing() { + if (useBlueprints) return; + return this._writing(); + } + + _end() { + return { + deploy() { + if (this.hasWarning) { + this.log(`\n${chalk.yellow.bold('WARNING!')} Kubernetes configuration generated, but no Jib cache found`); + this.log('If you forgot to generate the Docker image for this application, please run:'); + this.log(this.warningMessage); } else { - runCommand = `./gradlew bootJar -Pprod jib -Djib.to.image=${appConfig.targetImageName}`; + this.log(`\n${chalk.bold.green('Kubernetes configuration successfully generated!')}`); } - this.log(` ${chalk.cyan(`${runCommand}`)} in ${this.destinationPath(this.directoryPath + appsFolder)}`); - }); - } - - this.log('\nYou can deploy all your apps by running the following kubectl command:'); - this.log(` ${chalk.cyan('bash kubectl-apply.sh -f')}`); - this.log('\n[OR]'); - this.log('\nIf you want to use kustomize configuration, then run the following command:'); - this.log(` ${chalk.cyan('bash kubectl-apply.sh -k')}`); - if (this.gatewayNb + this.monolithicNb >= 1) { - const namespaceSuffix = this.kubernetesNamespace === 'default' ? '' : ` -n ${this.kubernetesNamespace}`; - this.log("\nUse these commands to find your application's IP addresses:"); - for (let i = 0; i < this.appsFolders.length; i++) { - if (this.appConfigs[i].applicationType === 'gateway' || this.appConfigs[i].applicationType === 'monolith') { - this.log(` ${chalk.cyan(`kubectl get svc ${this.appConfigs[i].baseName.toLowerCase()}${namespaceSuffix}`)}`); + + this.log( + `\n${chalk.yellow.bold( + 'WARNING!' + )} You will need to push your image to a registry. If you have not done so, use the following commands to tag and push the images:` + ); + for (let i = 0; i < this.appsFolders.length; i++) { + const originalImageName = this.appConfigs[i].baseName.toLowerCase(); + const targetImageName = this.appConfigs[i].targetImageName; + if (originalImageName !== targetImageName) { + this.log(` ${chalk.cyan(`docker image tag ${originalImageName} ${targetImageName}`)}`); + } + this.log(` ${chalk.cyan(`${this.dockerPushCommand} ${targetImageName}`)}`); } - } - this.log(); - } - // Make the apply script executable - try { - fs.chmodSync('kubectl-apply.sh', '755'); - } catch (err) { - this.log( - `${chalk.yellow.bold('WARNING!')}Failed to make 'kubectl-apply.sh' executable, you may need to run 'chmod +x kubectl-apply.sh'` - ); - } + + if (this.dockerRepositoryName) { + this.log(`\n${chalk.green.bold('INFO!')} Alternatively, you can use Jib to build and push image directly to a remote registry:`); + this.appsFolders.forEach((appsFolder, index) => { + const appConfig = this.appConfigs[index]; + let runCommand = ''; + if (appConfig.buildTool === MAVEN) { + runCommand = `./mvnw -ntp -Pprod verify jib:build -Djib.to.image=${appConfig.targetImageName}`; + } else { + runCommand = `./gradlew bootJar -Pprod jib -Djib.to.image=${appConfig.targetImageName}`; + } + this.log(` ${chalk.cyan(`${runCommand}`)} in ${this.destinationPath(this.directoryPath + appsFolder)}`); + }); + } + this.log('\nYou can deploy all your apps by running the following kubectl command:'); + this.log(` ${chalk.cyan('bash kubectl-apply.sh -f')}`); + this.log('\n[OR]'); + this.log('\nIf you want to use kustomize configuration, then run the following command:'); + this.log(` ${chalk.cyan('bash kubectl-apply.sh -k')}`); + if (this.gatewayNb + this.monolithicNb >= 1) { + const namespaceSuffix = this.kubernetesNamespace === 'default' ? '' : ` -n ${this.kubernetesNamespace}`; + this.log("\nUse these commands to find your application's IP addresses:"); + for (let i = 0; i < this.appsFolders.length; i++) { + if (this.appConfigs[i].applicationType === 'gateway' || this.appConfigs[i].applicationType === 'monolith') { + this.log(` ${chalk.cyan(`kubectl get svc ${this.appConfigs[i].baseName.toLowerCase()}${namespaceSuffix}`)}`); + } + } + this.log(); + } + // Make the apply script executable + try { + fs.chmodSync('kubectl-apply.sh', '755'); + } catch (err) { + this.log( + `${chalk.yellow.bold('WARNING!')}Failed to make 'kubectl-apply.sh' executable, you may need to run 'chmod +x kubectl-apply.sh'` + ); + } + }, + }; + } + + get end() { + if (useBlueprints) return; + return this._end(); } }; diff --git a/generators/kubernetes/kubernetes-constants.js b/generators/kubernetes/kubernetes-constants.js new file mode 100644 index 000000000000..64cad0ff0a8e --- /dev/null +++ b/generators/kubernetes/kubernetes-constants.js @@ -0,0 +1,13 @@ +const kubernetesDefaultConfig = { + kubernetesServiceType: 'LoadBalancer', + monitoring: 'no', + istio: false, +}; + +const defaultKubernetesConfig = { + ...kubernetesDefaultConfig, +}; + +module.exports = { + defaultKubernetesConfig, +}; diff --git a/generators/kubernetes/prompts.js b/generators/kubernetes/prompts.js index a22c5e2d70a1..3159927b234d 100644 --- a/generators/kubernetes/prompts.js +++ b/generators/kubernetes/prompts.js @@ -18,6 +18,10 @@ */ const execSync = require('child_process').execSync; const dockerPrompts = require('../docker-prompts'); +const { MONOLITH } = require('../../jdl/jhipster/application-types'); +const databaseTypes = require('../../jdl/jhipster/database-types'); + +const NO_DATABASE = databaseTypes.NO; module.exports = { askForKubernetesNamespace, @@ -177,7 +181,7 @@ async function askForIngressDomain() { async function askForIstioSupport() { if (this.regenerate) return; - if (this.deploymentApplicationType === 'monolith') { + if (this.deploymentApplicationType === MONOLITH) { this.istio = false; return; } @@ -209,7 +213,7 @@ async function askForPersistentStorage() { if (this.regenerate) return; let usingDataBase = false; this.appConfigs.forEach((appConfig, index) => { - if (appConfig.prodDatabaseType !== 'no') { + if (appConfig.prodDatabaseType !== NO_DATABASE) { usingDataBase = true; } }); diff --git a/generators/kubernetes/templates/db/elasticsearch.yml.ejs b/generators/kubernetes/templates/db/elasticsearch.yml.ejs index 586c9ebcb930..ac73dd03543f 100644 --- a/generators/kubernetes/templates/db/elasticsearch.yml.ejs +++ b/generators/kubernetes/templates/db/elasticsearch.yml.ejs @@ -47,21 +47,21 @@ spec: metadata: labels: app: <%= app.baseName.toLowerCase() %>-elasticsearch - <%_ if (istio) { _%> +<%_ if (istio) { _%> annotations: sidecar.istio.io/inject: "false" - <%_ } _%> +<%_ } _%> spec: securityContext: fsGroup: 1000 volumes: - name: data - <%_ if (kubernetesUseDynamicStorage) { _%> +<%_ if (kubernetesUseDynamicStorage) { _%> persistentVolumeClaim: claimName: <%= app.baseName.toLowerCase() %>-elasticsearch-pvc - <%_ } else { _%> +<%_ } else { _%> emptyDir: {} - <%_ } _%> +<%_ } _%> initContainers: - name: init-sysctl image: busybox diff --git a/generators/kubernetes/templates/db/mariadb.yml.ejs b/generators/kubernetes/templates/db/mariadb.yml.ejs index 54a2f722e02e..3b60e01106a0 100644 --- a/generators/kubernetes/templates/db/mariadb.yml.ejs +++ b/generators/kubernetes/templates/db/mariadb.yml.ejs @@ -58,19 +58,19 @@ spec: metadata: labels: app: <%= app.baseName.toLowerCase() %>-mariadb - <%_ if (istio) { _%> +<%_ if (istio) { _%> annotations: sidecar.istio.io/inject: "false" - <%_ } _%> +<%_ } _%> spec: volumes: - name: data - <%_ if (kubernetesUseDynamicStorage) { _%> +<%_ if (kubernetesUseDynamicStorage) { _%> persistentVolumeClaim: claimName: <%= app.baseName.toLowerCase() %>-mariadb-pvc - <%_ } else { _%> +<%_ } else { _%> emptyDir: {} - <%_ } _%> +<%_ } _%> containers: - name: mariadb image: <%= DOCKER_MARIADB %> diff --git a/generators/kubernetes/templates/db/mongodb.yml.ejs b/generators/kubernetes/templates/db/mongodb.yml.ejs index c4a2f42c5adc..1f5923d031c0 100644 --- a/generators/kubernetes/templates/db/mongodb.yml.ejs +++ b/generators/kubernetes/templates/db/mongodb.yml.ejs @@ -183,10 +183,10 @@ spec: metadata: labels: app: <%= app.baseName.toLowerCase() %>-mongodb - <%_ if (istio) { _%> +<%_ if (istio) { _%> annotations: sidecar.istio.io/inject: "false" - <%_ } _%> +<%_ } _%> spec: initContainers: - name: config diff --git a/generators/kubernetes/templates/db/mssql.yml.ejs b/generators/kubernetes/templates/db/mssql.yml.ejs index 0db62fb53ef1..c6239ebba175 100644 --- a/generators/kubernetes/templates/db/mssql.yml.ejs +++ b/generators/kubernetes/templates/db/mssql.yml.ejs @@ -47,22 +47,22 @@ spec: metadata: labels: app: <%= app.baseName.toLowerCase() %>-mssql - <%_ if (istio) { _%> +<%_ if (istio) { _%> annotations: sidecar.istio.io/inject: "false" - <%_ } _%> +<%_ } _%> spec: volumes: - name: mssqldb persistentVolumeClaim: claimName: mssql-data - name: data - <%_ if (kubernetesUseDynamicStorage) { _%> +<%_ if (kubernetesUseDynamicStorage) { _%> persistentVolumeClaim: claimName: <%= app.baseName.toLowerCase() %>-mssql-pvc - <%_ } else { _%> +<%_ } else { _%> emptyDir: {} - <%_ } _%> +<%_ } _%> containers: - name: mysql image: <%= DOCKER_MSSQL %> diff --git a/generators/kubernetes/templates/db/mysql.yml.ejs b/generators/kubernetes/templates/db/mysql.yml.ejs index a9280a0bf429..d7618f8de3d1 100644 --- a/generators/kubernetes/templates/db/mysql.yml.ejs +++ b/generators/kubernetes/templates/db/mysql.yml.ejs @@ -47,19 +47,19 @@ spec: metadata: labels: app: <%= app.baseName.toLowerCase() %>-mysql - <%_ if (istio) { _%> +<%_ if (istio) { _%> annotations: sidecar.istio.io/inject: "false" - <%_ } _%> +<%_ } _%> spec: volumes: - name: data - <%_ if (kubernetesUseDynamicStorage) { _%> +<%_ if (kubernetesUseDynamicStorage) { _%> persistentVolumeClaim: claimName: <%= app.baseName.toLowerCase() %>-mysql-pvc - <%_ } else { _%> +<%_ } else { _%> emptyDir: {} - <%_ } _%> +<%_ } _%> containers: - name: mysql image: <%= DOCKER_MYSQL %> diff --git a/generators/kubernetes/templates/db/neo4j.yml.ejs b/generators/kubernetes/templates/db/neo4j.yml.ejs index c59debb763f5..cf5526634956 100644 --- a/generators/kubernetes/templates/db/neo4j.yml.ejs +++ b/generators/kubernetes/templates/db/neo4j.yml.ejs @@ -59,19 +59,19 @@ spec: metadata: labels: app: <%= app.baseName.toLowerCase() %>-neo4j - <%_ if (istio) { _%> +<%_ if (istio) { _%> annotations: sidecar.istio.io/inject: "false" - <%_ } _%> +<%_ } _%> spec: volumes: - name: data - <%_ if (kubernetesUseDynamicStorage) { _%> +<%_ if (kubernetesUseDynamicStorage) { _%> persistentVolumeClaim: claimName: <%= app.baseName.toLowerCase() %>-neo4j-pvc - <%_ } else { _%> +<%_ } else { _%> emptyDir: {} - <%_ } _%> +<%_ } _%> containers: - name: neo4j image: <%= DOCKER_NEO4J %> diff --git a/generators/kubernetes/templates/db/postgresql.yml.ejs b/generators/kubernetes/templates/db/postgresql.yml.ejs index 142d5fa9629e..8d5f60348258 100644 --- a/generators/kubernetes/templates/db/postgresql.yml.ejs +++ b/generators/kubernetes/templates/db/postgresql.yml.ejs @@ -58,19 +58,19 @@ spec: metadata: labels: app: <%= app.baseName.toLowerCase() %>-postgresql - <%_ if (istio) { _%> +<%_ if (istio) { _%> annotations: sidecar.istio.io/inject: "false" - <%_ } _%> +<%_ } _%> spec: volumes: - name: data - <%_ if (kubernetesUseDynamicStorage) { _%> +<%_ if (kubernetesUseDynamicStorage) { _%> persistentVolumeClaim: claimName: <%= app.baseName.toLowerCase() %>-postgresql-pvc - <%_ } else { _%> +<%_ } else { _%> emptyDir: {} - <%_ } _%> +<%_ } _%> containers: - name: postgres image: <%= DOCKER_POSTGRESQL %> diff --git a/generators/kubernetes/templates/deployment.yml.ejs b/generators/kubernetes/templates/deployment.yml.ejs index 7319c0c86548..a64f74b65d28 100644 --- a/generators/kubernetes/templates/deployment.yml.ejs +++ b/generators/kubernetes/templates/deployment.yml.ejs @@ -54,24 +54,24 @@ spec: - | while true do - <%_ if (app.prodDatabaseType === 'mysql') { _%> +<%_ if (app.prodDatabaseTypeMysql) { _%> rt=$(nc -z -w 1 <%= app.baseName.toLowerCase() %>-mysql 3306) - <%_ } _%> - <%_ if (app.prodDatabaseType === 'mariadb') { _%> +<%_ } _%> +<%_ if (app.prodDatabaseTypeMariadb) { _%> rt=$(nc -z -w 1 <%= app.baseName.toLowerCase() %>-mariadb 3306) - <%_ } _%> - <%_ if (app.prodDatabaseType === 'postgresql') { _%> +<%_ } _%> +<%_ if (app.prodDatabaseTypePostgres) { _%> rt=$(nc -z -w 1 <%= app.baseName.toLowerCase() %>-postgresql 5432) - <%_ } _%> - <%_ if (app.prodDatabaseType === 'mongodb') { _%> +<%_ } _%> +<%_ if (app.prodDatabaseTypeMongodb) { _%> rt=$(nc -z -w 1 <%= app.baseName.toLowerCase() %>-mongodb 27017) - <%_ } _%> - <%_ if (app.prodDatabaseType === 'couchbase') { _%> +<%_ } _%> +<%_ if (app.prodDatabaseTypeCouchbase) { _%> rt=$(nc -z -w 1 <%= app.baseName.toLowerCase() %>-couchbase 8091) - <%_ } _%> - <%_ if (app.prodDatabaseType === 'neo4j') { _%> +<%_ } _%> +<%_ if (app.prodDatabaseTypeNeo4j) { _%> rt=$(nc -z -w 1 <%= app.baseName.toLowerCase() %>-neo4j 7474) - <%_ } _%> +<%_ } _%> if [ $? -eq 0 ]; then echo "DB is UP" break @@ -85,7 +85,7 @@ spec: env: - name: SPRING_PROFILES_ACTIVE value: prod - <%_ if (app.serviceDiscoveryType === 'eureka') { _%> +<%_ if (app.serviceDiscoveryEureka) { _%> - name: SPRING_CLOUD_CONFIG_URI value: http://admin:${jhipster.registry.password}@jhipster-registry.<%= kubernetesNamespace %>.svc.cluster.local:8761/config - name: JHIPSTER_REGISTRY_PASSWORD @@ -95,97 +95,97 @@ spec: key: registry-admin-password - name: EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE value: http://admin:${jhipster.registry.password}@jhipster-registry.<%= kubernetesNamespace %>.svc.cluster.local:8761/eureka/ - <%_ if (istio) { _%> + <%_ if (istio) { _%> - name: EUREKA_INSTANCE_PREFER_IP_ADDRESS value: "false" - name: EUREKA_INSTANCE_HOSTNAME value: <%= app.baseName.toLowerCase() %> - <%_ } _%> - <%_ } _%> - <%_ if (app.serviceDiscoveryType === 'consul') { _%> + <%_ } _%> +<%_ } _%> +<%_ if (app.serviceDiscoveryConsul) { _%> - name: SPRING_CLOUD_CONSUL_HOST value: consul.<%= kubernetesNamespace %>.svc.cluster.local - name: SPRING_CLOUD_CONSUL_PORT value: "8500" - <%_ if (istio) { _%> + <%_ if (istio) { _%> - name: SPRING_CLOUD_CONSUL_DISCOVERY_PREFER_IP_ADDRESS value: "false" - name: SPRING_CLOUD_CONSUL_DISCOVERY_HOSTNAME value: <%= app.baseName.toLowerCase() %> - name: SPRING_CLOUD_CONSUL_DISCOVERY_SERVICE_NAME value: <%= app.baseName.toLowerCase() %> - <%_ } _%> - <%_ } _%> - <%_ if (!app.serviceDiscoveryType && app.authenticationType === 'jwt') { _%> + <%_ } _%> +<%_ } _%> +<%_ if (!app.serviceDiscoveryType && app.authenticationTypeJwt) { _%> - name: JHIPSTER_SECURITY_AUTHENTICATION_JWT_BASE64_SECRET valueFrom: secretKeyRef: name: jwt-secret key: secret - <%_ } _%> - <%_ if (app.prodDatabaseType === 'mysql' || app.prodDatabaseType === 'mariadb') { _%> +<%_ } _%> +<%_ if (app.prodDatabaseTypeMysql || app.prodDatabaseTypeMariadb) { _%> - name: SPRING_DATASOURCE_URL value: <%- getJDBCUrl(app.prodDatabaseType, { hostname: `${app.baseName.toLowerCase()}-${app.prodDatabaseType}.${kubernetesNamespace}.svc.cluster.local`, databaseName: app.baseName.toLowerCase() }) %> - name: SPRING_LIQUIBASE_URL value: <%- getJDBCUrl(app.prodDatabaseType, { hostname: `${app.baseName.toLowerCase()}-${app.prodDatabaseType}.${kubernetesNamespace}.svc.cluster.local`, databaseName: app.baseName.toLowerCase() }) %> - <%_ if (app.reactive) { _%> + <%_ if (app.reactive) { _%> - name: SPRING_R2DBC_URL value: <%- getR2DBCUrl(app.prodDatabaseType, { hostname: `${app.baseName.toLowerCase()}-${app.prodDatabaseType}.${kubernetesNamespace}.svc.cluster.local`, databaseName: app.baseName.toLowerCase() }) %> - <%_ } _%> - <%_ } _%> - <%_ if (app.prodDatabaseType === 'mariadb') { _%> - <%_ if (app.reactive) { _%> + <%_ } _%> +<%_ } _%> +<%_ if (app.prodDatabaseTypeMariadb) { _%> + <%_ if (app.reactive) { _%> - name: SPRING_R2DBC_PASSWORD - <%_ } else { _%> + <%_ } else { _%> - name: SPRING_DATASOURCE_PASSWORD - <%_ } _%> + <%_ } _%> valueFrom: secretKeyRef: name: <%= app.baseName.toLowerCase() %>-mariadb key: mariadb-root-password - <%_ } _%> - <%_ if (app.prodDatabaseType === 'postgresql') { _%> +<%_ } _%> +<%_ if (app.prodDatabaseTypePostgres) { _%> - name: SPRING_DATASOURCE_URL value: <%- getJDBCUrl(app.prodDatabaseType, { hostname: `${app.baseName.toLowerCase()}-${app.prodDatabaseType}.${kubernetesNamespace}.svc.cluster.local`, databaseName: app.baseName }) %> - name: SPRING_DATASOURCE_USERNAME value: <%= app.baseName %> - <%_ if (app.reactive) { _%> + <%_ if (app.reactive) { _%> - name: SPRING_R2DBC_PASSWORD - <%_ } else { _%> + <%_ } else { _%> - name: SPRING_DATASOURCE_PASSWORD - <%_ } _%> + <%_ } _%> valueFrom: secretKeyRef: name: <%= app.baseName.toLowerCase() %>-postgresql key: postgresql-password - name: SPRING_LIQUIBASE_URL value: <%- getJDBCUrl(app.prodDatabaseType, { hostname: `${app.baseName.toLowerCase()}-${app.prodDatabaseType}.${kubernetesNamespace}.svc.cluster.local`, databaseName: app.baseName.toLowerCase() }) %> - <%_ if (app.reactive) { _%> + <%_ if (app.reactive) { _%> - name: SPRING_R2DBC_URL value: <%- getR2DBCUrl(app.prodDatabaseType, { hostname: `${app.baseName.toLowerCase()}-${app.prodDatabaseType}.${kubernetesNamespace}.svc.cluster.local`, databaseName: app.baseName.toLowerCase() }) %> - <%_ } _%> - <%_ } _%> - <%_ if (app.prodDatabaseType === 'mongodb') { _%> + <%_ } _%> +<%_ } _%> +<%_ if (app.prodDatabaseTypeMongodb) { _%> - name: SPRING_DATA_MONGODB_DATABASE value: <%= app.baseName %> - name: SPRING_DATA_MONGODB_URI value: "mongodb://<% for (let i = 0; i < app.dbPeerCount; i++) { %><%= app.baseName.toLowerCase() %>-mongodb-<%= i %>.<%= app.baseName.toLowerCase() %>-mongodb.<%= kubernetesNamespace %>:27017<% if (app.reactive) { %>/?waitQueueMultiple=1000<% } %><% if (i < (app.dbPeerCount-1)) { %>,<% }} %>" - <%_ } _%> - <%_ if (app.prodDatabaseType === 'neo4j') { _%> +<%_ } _%> +<%_ if (app.prodDatabaseTypeNeo4j) { _%> - name: SPRING_NEO4J_URI value: bolt://<%= app.baseName.toLowerCase() %>-neo4j.<%= kubernetesNamespace %>.svc.cluster.local:7687 - <%_ } _%> - <%_ if (app.prodDatabaseType === 'couchbase') { _%> +<%_ } _%> +<%_ if (app.prodDatabaseTypeCouchbase) { _%> - name: SPRING_COUCHBASE_BOOTSTRAP_HOSTS value: "<% for (let i = 0; i < app.dbPeerCount; i++) { %><%= app.baseName.toLowerCase() %>-couchbase-<%= i %>.<%= app.baseName.toLowerCase() %>-couchbase<% if (i < (app.dbPeerCount-1)) { %>,<% }} %>" - name: SPRING_COUCHBASE_BUCKET_NAME value: <%= app.baseName.toLowerCase() %> - <%_ } _%> - <%_ if (app.searchEngine === 'elasticsearch') { _%> +<%_ } _%> +<%_ if (app.searchEngineElasticsearch) { _%> - name: SPRING_ELASTICSEARCH_REST_URIS value: http://<%= app.baseName.toLowerCase() %>-elasticsearch.<%= kubernetesNamespace %>.svc.cluster.local:9200 - <%_ } _%> - <%_ if (app.messageBroker === 'kafka') { _%> +<%_ } _%> +<%_ if (app.messageBrokerKafka) { _%> - name: KAFKA_CONSUMER_KEY_DESERIALIZER value: 'org.apache.kafka.common.serialization.StringDeserializer' - name: KAFKA_CONSUMER_VALUE_DESERIALIZER @@ -202,15 +202,15 @@ spec: value: 'org.apache.kafka.common.serialization.StringDeserializer' - name: KAFKA_PRODUCER_VALUE_DESERIALIZER value: 'org.apache.kafka.common.serialization.StringDeserializer' - <%_ } _%> - <%_ if (monitoring === 'prometheus') { _%> +<%_ } _%> +<%_ if (monitoringPrometheus) { _%> - name: MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED value: 'true' - <%_ } _%> - <%_ if (deploymentApplicationType === 'microservice') { _%> +<%_ } _%> +<%_ if (deploymentApplicationTypeMicroservice) { _%> - name: SPRING_SLEUTH_PROPAGATION_KEYS value: "x-request-id,x-ot-span-context" - <%_ } _%> +<%_ } _%> - name: JAVA_OPTS value: " -Xmx256m -Xms256m" - name: SERVER_SHUTDOWN diff --git a/generators/kubernetes/templates/ingress.yml.ejs b/generators/kubernetes/templates/ingress.yml.ejs index a0367c0a6e44..85437bb8d509 100644 --- a/generators/kubernetes/templates/ingress.yml.ejs +++ b/generators/kubernetes/templates/ingress.yml.ejs @@ -30,13 +30,13 @@ spec: - http: <%_ } _%> paths: - - path: /<%= ingressType === "nginx" ? "" : "*" %> + - path: /<%= ingressTypeNginx ? "" : "*" %> backend: serviceName: <%= app.baseName.toLowerCase() %> servicePort: <%= app.serverPort %> <%_ if (!app.serviceDiscoveryType) { _%> <%_ appConfigs.filter(config => config.baseName !== app.baseName).forEach(config => { _%> - - path: /services/<%= config.baseName.toLowerCase() %>/<%= ingressType === "nginx" ? "" : "*" %> + - path: /services/<%= config.baseName.toLowerCase() %>/<%= ingressTypeNginx ? "" : "*" %> backend: serviceName: <%= config.baseName.toLowerCase() %> servicePort: <%= config.serverPort %> diff --git a/generators/kubernetes/templates/istio/gateway.yml.ejs b/generators/kubernetes/templates/istio/gateway.yml.ejs index 78bf74a8a6ba..7c47a80edeee 100644 --- a/generators/kubernetes/templates/istio/gateway.yml.ejs +++ b/generators/kubernetes/templates/istio/gateway.yml.ejs @@ -54,16 +54,16 @@ spec: gateways: - <%= app.baseName.toLowerCase() %>-gateway http: - <%_ if (!app.serviceDiscoveryType) { _%> - <%_ appConfigs.filter(config => config.baseName !== app.baseName).forEach(config => { _%> +<%_ if (!app.serviceDiscoveryType) { _%> + <%_ appConfigs.filter(config => config.baseName !== app.baseName).forEach(config => { _%> - match: - uri: prefix: /<%= config.baseName.toLowerCase() %>/ route: - destination: host: <%= config.baseName.toLowerCase() %> - <%_ }); _%> - <%_ } _%> + <%_ }); _%> +<%_ } _%> - match: - uri: prefix: / diff --git a/generators/kubernetes/templates/kubectl-apply.sh.ejs b/generators/kubernetes/templates/kubectl-apply.sh.ejs index 6c269949785c..6b14a3013317 100755 --- a/generators/kubernetes/templates/kubectl-apply.sh.ejs +++ b/generators/kubernetes/templates/kubectl-apply.sh.ejs @@ -38,44 +38,45 @@ exit 0 logSummary() { echo "" - <%_ if (monitoring === 'prometheus' || kubernetesServiceType === 'Ingress' || istio) { _%> +<%_ if (monitoringPrometheus || kubernetesServiceTypeIngress || istio) { _%> echo "#####################################################" echo "Please find the below useful endpoints," - <%_ if (monitoring === 'prometheus') { _%> + <%_ if (monitoringPrometheus) { _%> echo "JHipster Grafana - http://jhipster-grafana.<%= kubernetesNamespace %>.<%= ingressDomain %>" - <%_ } _%> - <%_ if (kubernetesServiceType === 'Ingress') { _%> - <%_ appConfigs.forEach((appConfig) => { _%> - <%_ if (appConfig.applicationType === 'gateway') {_%> + <%_ } _%> + <%_ if (kubernetesServiceTypeIngress) { _%> + <%_ appConfigs.forEach((appConfig) => { _%> + <%_ if (appConfig.applicationTypeGateway) {_%> echo "Gateway - http://<%= appConfig.baseName.toLowerCase() %>.<%= kubernetesNamespace %>.<%= ingressDomain %>" - <%_ } _%><%_ if (appConfig.applicationType === 'monolith') {_%> + <%_ } _%> + <%_ if (appConfig.applicationTypeMonolith) {_%> echo "<%= appConfig.baseName %> - http://<%= appConfig.baseName.toLowerCase() %>.<%= kubernetesNamespace %>.<%= ingressDomain %>" - <%_ } _%> - <%_ }) _%> - <%_ if (istio) { _%> + <%_ } _%> + <%_ }) _%> + <%_ if (istio) { _%> echo "Zipkin - http://zipkin.istio-system.<%= ingressDomain %>" echo "Grafana - http://grafana.istio-system.<%= ingressDomain %>" echo "Kiali - http://kiali.istio-system.<%= ingressDomain %>" - <%_ } _%> - <%_ } _%> - echo "#####################################################" <%_ } _%> + <%_ } _%> + echo "#####################################################" +<%_ } _%> } default() { suffix=k8s - <%_ if (kubernetesNamespace !== 'default') { _%> +<%_ if (!kubernetesNamespaceDefault) { _%> kubectl apply -f namespace.yml - <%_ } _%> <%_ if (serviceDiscoveryType === 'eureka' || serviceDiscoveryType === 'consul') { _%> +<%_ } _%> <%_ if (serviceDiscoveryEureka || serviceDiscoveryConsul) { _%> kubectl apply -f registry-${suffix}/ - <%_ } _%> <%_ if (istio) { _%> +<%_ } _%> <%_ if (istio) { _%> kubectl label namespace <%-kubernetesNamespace%> istio-injection=enabled --overwrite=true - <%_ } _%> <%_ appConfigs.forEach((appConfig, index) => { _%> +<%_ } _%> <%_ appConfigs.forEach((appConfig, index) => { _%> kubectl apply -f <%- appConfig.baseName.toLowerCase() %>-${suffix}/ - <%_ }) _%> - <%_ if (useKafka === true) { _%> +<%_ }) _%> +<%_ if (useKafka) { _%> kubectl apply -f messagebroker-${suffix}/ - <%_ } _%> <%_ if (monitoring === 'prometheus') { _%> +<%_ } _%> <%_ if (monitoringPrometheus) { _%> kubectl apply -f monitoring-${suffix}/jhipster-prometheus-crd.yml until [ $(kubectl get crd prometheuses.monitoring.coreos.com 2>>/dev/null | wc -l) -ge 2 ]; do echo "Waiting for the custom resource prometheus operator to get initialised"; @@ -84,11 +85,11 @@ default() { kubectl apply -f monitoring-${suffix}/jhipster-prometheus-cr.yml kubectl apply -f monitoring-${suffix}/jhipster-grafana.yml kubectl apply -f monitoring-${suffix}/jhipster-grafana-dashboard.yml - <%_ } _%> +<%_ } _%> - <%_ if (istio && kubernetesServiceType === 'Ingress') { _%> +<%_ if (istio && kubernetesServiceTypeIngress) { _%> kubectl apply -f istio-${suffix}/ - <%_ } _%> +<%_ } _%> } kustomize() { diff --git a/generators/kubernetes/templates/kustomize/kustomization.yml.ejs b/generators/kubernetes/templates/kustomize/kustomization.yml.ejs index 5de183176abb..f3011356e3c8 100644 --- a/generators/kubernetes/templates/kustomize/kustomization.yml.ejs +++ b/generators/kubernetes/templates/kustomize/kustomization.yml.ejs @@ -1,13 +1,13 @@ commonLabels: app.kubernetes.io/genereted-by: JHipster -<%_ if (kubernetesNamespace !== 'default') { _%> +<%_ if (!kubernetesNamespaceDefault) { _%> namespace: <%= kubernetesNamespace %> <%_ } _%> resources: <%_ -if (kubernetesNamespace !== 'default') { _%> +if (!kubernetesNamespaceDefault) { _%> - namespace.yml <%_ } _%> # Individual apps @@ -18,58 +18,59 @@ const appName = appConfig.baseName.toLowerCase(); const appOut = appName.concat('-', suffix); _%> - <%= appOut %>/<%= appName %>-deployment.yml - <%= appOut %>/<%= appName %>-service.yml -<%_ - if (appConfig.prodDatabaseType !== 'no') { _%> + <%_ + if (!appConfig.databaseTypeNo) { _%> - <%= appOut %>/<%= appName %>-<%= appConfig.prodDatabaseType %>.yml -<%_ } - if (appConfig.searchEngine === 'elasticsearch') { _%> + <%_ } + if (appConfig.searchEngineElasticsearch) { _%> - <%= appOut %>/<%= appName %>-elasticsearch.yml -<%_ } - if (appConfig.applicationType === 'gateway' || appConfig.applicationType === 'monolith') { + <%_ } + if (appConfig.applicationTypeGateway || appConfig.applicationTypeMonolith) { if (istio) { _%> - <%= appOut %>/<%= appName %>-gateway.yml -<%_ } else if (kubernetesServiceType === 'Ingress') { _%> + <%_ } else if (kubernetesServiceTypeIngress) { _%> - <%= appOut %>/<%= appName %>-ingress.yml -<%_ } + <%_ } } - if (!appConfig.serviceDiscoveryType && appConfig.authenticationType === 'jwt') { _%> + if (!appConfig.serviceDiscoveryType && appConfig.authenticationTypeJwt) { _%> - <%= appOut %>/jwt-secret.yml -<%_ } - if (monitoring === 'prometheus') { _%> + <%_ } + if (monitoringPrometheus) { _%> - <%= appOut %>/<%= appName %>-prometheus-sm.yml -<%_ } + <%_ } if (istio) { _%> - <%= appOut %>/<%= appName %>-destination-rule.yml - <%= appOut %>/<%= appName %>-virtual-service.yml -<%_ } _%> + <%_ } _%> <%_ }) _%> <%_ if (useKafka) { _%> # messagebroker - messagebroker-<%= suffix %>/kafka.yml <%_ } _%> -<%_ if (monitoring === 'prometheus') { - const monitOut = 'monitoring'.concat('-', suffix); _%> +<%_ if (monitoringPrometheus) { + const monitOut = 'monitoring'.concat('-', suffix); _%> # monitoring prometheus - <%= monitOut %>/jhipster-prometheus-cr.yml - <%= monitOut %>/jhipster-prometheus-crd.yml - <%= monitOut %>/jhipster-grafana.yml - <%= monitOut %>/jhipster-grafana-dashboard.yml -<%_ if (istio) { _%> + <%_ if (istio) { _%> - <%= monitOut %>/jhipster-grafana-gateway.yml -<%_ } } _%> + <%_ } _%> +<%_ } _%> # service discovery eureka/consul -<%_ if (serviceDiscoveryType === 'eureka') { - const registryOut = 'registry'.concat('-', suffix); _%> +<%_ if (serviceDiscoveryEureka) { + const registryOut = 'registry'.concat('-', suffix); _%> - <%= registryOut %>/jhipster-registry.yml - <%= registryOut %>/application-configmap.yml -<%_ } else if (serviceDiscoveryType === 'consul') { +<%_ } else if (serviceDiscoveryConsul) { const registryOut = 'registry'.concat('-', suffix);_%> - <%= registryOut %>/consul.yml - <%= registryOut %>/consul-config-loader.yml - <%= registryOut %>/application-configmap.yml <%_ } _%> <%_ if (istio) { - const istioOut = 'istio'.concat('-', suffix); _%> + const istioOut = 'istio'.concat('-', suffix); _%> # istio - <%= istioOut %>/grafana-gateway.yml - <%= istioOut %>/zipkin-gateway.yml @@ -78,7 +79,7 @@ const appOut = appName.concat('-', suffix); _%> patchesJson6902: <%_ if (istio) { - const patchOut = 'patch'.concat('-', suffix); _%> + const patchOut = 'patch'.concat('-', suffix); _%> - target: version: v1 kind: Namespace diff --git a/generators/kubernetes/templates/monitoring/jhipster-grafana.yml.ejs b/generators/kubernetes/templates/monitoring/jhipster-grafana.yml.ejs index 15f691befe52..e8f6c4fc3645 100644 --- a/generators/kubernetes/templates/monitoring/jhipster-grafana.yml.ejs +++ b/generators/kubernetes/templates/monitoring/jhipster-grafana.yml.ejs @@ -91,15 +91,15 @@ spec: - name: http port: 3000 targetPort: 3000 - <%_ if (kubernetesServiceType !== 'Ingress') { _%> +<%_ if (!kubernetesServiceTypeIngress) { _%> type: <%= kubernetesServiceType %> - <%_ } else { _%> +<%_ } else { _%> type: ClusterIP - <%_ } _%> +<%_ } _%> selector: app: jhipster-grafana --- -<%_ if (kubernetesServiceType === 'Ingress' && !istio ) { _%> +<%_ if (kubernetesServiceTypeIngress && !istio ) { _%> apiVersion: <%= KUBERNETES_INGRESS_API_VERSION %> kind: Ingress metadata: diff --git a/generators/kubernetes/templates/monitoring/jhipster-prometheus-crd.yml.ejs b/generators/kubernetes/templates/monitoring/jhipster-prometheus-crd.yml.ejs index 208c44b55988..a670fd44faee 100644 --- a/generators/kubernetes/templates/monitoring/jhipster-prometheus-crd.yml.ejs +++ b/generators/kubernetes/templates/monitoring/jhipster-prometheus-crd.yml.ejs @@ -106,10 +106,10 @@ spec: metadata: labels: k8s-app: prometheus-operator - <%_ if (istio) { _%> +<%_ if (istio) { _%> annotations: sidecar.istio.io/inject: "false" - <%_ } _%> +<%_ } _%> spec: containers: - args: diff --git a/generators/kubernetes/templates/registry/application-configmap.yml.ejs b/generators/kubernetes/templates/registry/application-configmap.yml.ejs index c9f819aa244b..7ae46ab9cd54 100644 --- a/generators/kubernetes/templates/registry/application-configmap.yml.ejs +++ b/generators/kubernetes/templates/registry/application-configmap.yml.ejs @@ -25,9 +25,9 @@ metadata: data: application.yml: |- configserver: - name: <% if (serviceDiscoveryType === 'eureka') { %> JHipster Registry<% } %><% if (serviceDiscoveryType === 'consul') { %>Consul<% } %> - status: Connected to <% if (serviceDiscoveryType === 'eureka') { %>the JHipster Registry<% } %><% if (serviceDiscoveryType === 'consul') { %>Consul<% } %> running in Kubernetes - <%_ if (serviceDiscoveryType === 'eureka') { _%> + name: <% if (serviceDiscoveryEureka) { %> JHipster Registry<% } %><% if (serviceDiscoveryConsul) { %>Consul<% } %> + status: Connected to <% if (serviceDiscoveryEureka) { %>the JHipster Registry<% } %><% if (serviceDiscoveryConsul) { %>Consul<% } %> running in Kubernetes +<%_ if (serviceDiscoveryEureka) { _%> eureka: client: initial-instance-info-replication-interval-seconds: 15 @@ -39,17 +39,17 @@ data: instance: lease-renewal-interval-in-seconds: 10 registry-default-open-for-traffic-count: 0 - <%_ } _%> +<%_ } _%> jhipster: security: authentication: jwt: base64-secret: <%= jwtSecretKey %> # app specific configuration - <%_ if (serviceDiscoveryType === 'eureka') { _%> +<%_ if (serviceDiscoveryEureka) { _%> jhipster-registry.yml: |- eureka: client: service-url: defaultZone: http://admin:${spring.security.user.password}@jhipster-registry-0.jhipster-registry.<%= kubernetesNamespace %>.svc.cluster.local:8761/eureka/,http://admin:${spring.security.user.password}@jhipster-registry-1.jhipster-registry.<%= kubernetesNamespace %>.svc.cluster.local:8761/eureka/ - <%_ } _%> +<%_ } _%> diff --git a/generators/kubernetes/templates/registry/consul.yml.ejs b/generators/kubernetes/templates/registry/consul.yml.ejs index 52be9173ef78..966ebac6b24c 100644 --- a/generators/kubernetes/templates/registry/consul.yml.ejs +++ b/generators/kubernetes/templates/registry/consul.yml.ejs @@ -93,10 +93,10 @@ spec: name: consul labels: app: consul - <%_ if (istio) { _%> +<%_ if (istio) { _%> annotations: sidecar.istio.io/inject: "false" - <%_ } _%> +<%_ } _%> spec: securityContext: fsGroup: 1000 diff --git a/generators/kubernetes/templates/registry/jhipster-registry.yml.ejs b/generators/kubernetes/templates/registry/jhipster-registry.yml.ejs index bf3c5230a290..546c44a55e45 100644 --- a/generators/kubernetes/templates/registry/jhipster-registry.yml.ejs +++ b/generators/kubernetes/templates/registry/jhipster-registry.yml.ejs @@ -75,10 +75,10 @@ spec: labels: app: jhipster-registry version: "1.0" - <%_ if (istio) { _%> +<%_ if (istio) { _%> annotations: sidecar.istio.io/inject: "false" - <%_ } _%> +<%_ } _%> spec: terminationGracePeriodSeconds: 10 containers: @@ -96,10 +96,10 @@ spec: secretKeyRef: name: registry-secret key: registry-admin-password - <%_ if (istio) { _%> +<%_ if (istio) { _%> - name: EUREKA_INSTANCE_PREFER_IP_ADDRESS value: "false" - <%_ } _%> +<%_ } _%> - name: JHIPSTER_SECURITY_AUTHENTICATION_JWT_BASE64_SECRET value: YlhrdGMyVmpjbVYwTFhSdmEyVnVMWFJ2TFdOb1lXNW5aUzFwYmkxd2NtOWtkV04wYVc5dUxXRnVaQzEwYnkxclpXVndMV2x1TFdFdGMyVmpkWEpsTFhCc1lXTmwK - name: SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE diff --git a/generators/kubernetes/templates/service.yml.ejs b/generators/kubernetes/templates/service.yml.ejs index 4a69d2039894..44d0940f94d9 100644 --- a/generators/kubernetes/templates/service.yml.ejs +++ b/generators/kubernetes/templates/service.yml.ejs @@ -26,18 +26,18 @@ metadata: spec: selector: app: <%= app.baseName.toLowerCase() %> - <%_ if (app.applicationType === 'monolith' || app.applicationType === 'gateway') { _%> - <%_ if (kubernetesServiceType !== 'Ingress') { _%> +<%_ if (app.applicationTypeMonolith || app.applicationTypeGateway) { _%> + <%_ if (!kubernetesServiceTypeIngress) { _%> type: <%= kubernetesServiceType %> - <%_ } else { _%> - type: <%= ingressType === 'gke' ? 'NodePort' : 'ClusterIP' %> - <%_ } _%> + <%_ } else { _%> + type: <%= ingressTypeGke ? 'NodePort' : 'ClusterIP' %> <%_ } _%> +<%_ } _%> ports: - name: http - <%_ if (!app.serviceDiscoveryType) { _%> +<%_ if (!app.serviceDiscoveryType) { _%> port: 80 targetPort: <%= app.serverPort %> - <%_ } else { _%> +<%_ } else { _%> port: <%= app.serverPort %> - <%_ } _%> +<%_ } _%> diff --git a/generators/languages/index.js b/generators/languages/index.js index 72ac5d45c6c7..17c873d5790c 100644 --- a/generators/languages/index.js +++ b/generators/languages/index.js @@ -178,6 +178,7 @@ module.exports = class extends BaseBlueprintGenerator { getSharedConfigOptions() { this.loadAppConfig(); this.loadClientConfig(); + this.loadPlatformConfig(); this.loadServerConfig(); this.loadTranslationConfig(); }, diff --git a/generators/server/index.js b/generators/server/index.js index 250cc4e94776..127efd5d89ea 100644 --- a/generators/server/index.js +++ b/generators/server/index.js @@ -258,6 +258,7 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator { this.loadDerivedClientConfig(); this.loadServerConfig(); this.loadDerivedServerConfig(); + this.loadPlatformConfig(); this.loadTranslationConfig(); }, }; diff --git a/test/__snapshots__/docker-compose.spec.js.snap b/test/__snapshots__/docker-compose.spec.js.snap index ccffa0217503..7ebb63e9159a 100644 --- a/test/__snapshots__/docker-compose.spec.js.snap +++ b/test/__snapshots__/docker-compose.spec.js.snap @@ -1088,6 +1088,11 @@ jhipster: authentication: jwt: base64-secret: SECRET--50 +management: + metrics: + export: + prometheus: + enabled: true eureka: client: service-url: @@ -1145,8 +1150,42 @@ eureka: # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=git # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI=https://github.com/jhipster/jhipster-registry/ # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_PATHS=central-config + - MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true ports: - 8761:8761 + + prometheus: + image: prom/prometheus:v2.27.1 + volumes: + - ./prometheus-conf/:/etc/prometheus/ + - prometheus_data:/prometheus + command: + - \\"--config.file=/etc/prometheus/prometheus.yml\\" + ports: + - 9090:9090 + alertmanager: + image: prom/alertmanager:v0.22.2 + ports: + - 9093:9093 + volumes: + - ./alertmanager-conf/:/etc/alertmanager/ + command: + - \\"--config.file=/etc/alertmanager/config.yml\\" + - \\"--storage.path=/alertmanager\\" + + grafana: + image: grafana/grafana:8.0.1 + ports: + - 3000:3000 + volumes: + - grafana_data:/var/lib/grafana + environment: + - GF_SECURITY_ADMIN_PASSWORD=admin + - GF_USERS_ALLOW_SIGN_UP=false + +volumes: + prometheus_data: {} + grafana_data: {} ", "stateCleared": "modified", }, @@ -1263,27 +1302,6 @@ Launch all your infrastructure by running: \`docker-compose up -d\`. command: mysqld --lower_case_table_names=1 --skip-ssl --character_set_server=utf8mb4 --explicit_defaults_for_timestamp samplemysql-elasticsearch: image: elasticsearch:2.4.6 - - jhipster-registry: - image: jhipster/jhipster-registry:v6.8.0 - volumes: - - ./central-server-config:/central-config - # By default the JHipster Registry runs with the \\"dev\\" and \\"native\\" - # Spring profiles. - # \\"native\\" profile means the filesystem is used to store data, see - # http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html - environment: - - _JAVA_OPTIONS=-Xmx512m -Xms256m - - SPRING_PROFILES_ACTIVE=dev - - SPRING_SECURITY_USER_PASSWORD= - - JHIPSTER_REGISTRY_PASSWORD= - - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=native - - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_LOCATIONS=file:./central-config - # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=git - # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI=https://github.com/jhipster/jhipster-registry/ - # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_PATHS=central-config - ports: - - 8761:8761 ", "stateCleared": "modified", }, @@ -1641,27 +1659,6 @@ Launch all your infrastructure by running: \`docker-compose up -d\`. - SERVER_PORT=80 ports: - \\"8080:8080\\" - - jhipster-registry: - image: jhipster/jhipster-registry:v6.8.0 - volumes: - - ./central-server-config:/central-config - # By default the JHipster Registry runs with the \\"dev\\" and \\"native\\" - # Spring profiles. - # \\"native\\" profile means the filesystem is used to store data, see - # http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html - environment: - - _JAVA_OPTIONS=-Xmx512m -Xms256m - - SPRING_PROFILES_ACTIVE=dev - - SPRING_SECURITY_USER_PASSWORD= - - JHIPSTER_REGISTRY_PASSWORD= - - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=native - - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_LOCATIONS=file:./central-config - # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE=git - # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_URI=https://github.com/jhipster/jhipster-registry/ - # - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_PATHS=central-config - ports: - - 8761:8761 ", "stateCleared": "modified", }, diff --git a/test/__snapshots__/heroku.spec.js.snap b/test/__snapshots__/heroku.spec.js.snap index 9336cff8b49d..838db11b2f2f 100644 --- a/test/__snapshots__/heroku.spec.js.snap +++ b/test/__snapshots__/heroku.spec.js.snap @@ -25,7 +25,7 @@ Object { \\"serviceDiscoveryType\\": \\"eureka\\", \\"buildTool\\": \\"maven\\", \\"enableSwaggerCodegen\\": false, - \\"jwtSecretKey\\": \\"fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8\\", + \\"jwtSecretKey\\": \\"SECRET--50\\", \\"enableTranslation\\": false, \\"applicationType\\": \\"microservice\\", \\"testFrameworks\\": [], @@ -42,7 +42,7 @@ Object { "stateCleared": "modified", }, "Procfile": Object { - "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku + "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku ", "stateCleared": "modified", }, @@ -132,7 +132,7 @@ Object { "stateCleared": "modified", }, "Procfile": Object { - "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku + "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku ", "stateCleared": "modified", }, @@ -214,7 +214,7 @@ Object { "stateCleared": "modified", }, "Procfile": Object { - "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku + "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku ", "stateCleared": "modified", }, @@ -296,7 +296,7 @@ Object { "stateCleared": "modified", }, "Procfile": Object { - "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku + "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku ", "stateCleared": "modified", }, @@ -378,7 +378,7 @@ Object { "stateCleared": "modified", }, "Procfile": Object { - "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku + "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku ", "stateCleared": "modified", }, @@ -460,7 +460,7 @@ Object { "stateCleared": "modified", }, "Procfile": Object { - "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku + "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku ", "stateCleared": "modified", }, @@ -542,7 +542,7 @@ Object { "stateCleared": "modified", }, "Procfile": Object { - "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku + "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku ", "stateCleared": "modified", }, @@ -627,7 +627,7 @@ Object { "stateCleared": "modified", }, "Procfile": Object { - "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku + "contents": "web: java $JAVA_OPTS -Xmx256m -jar target/*.jar --spring.profiles.active=prod,heroku ", "stateCleared": "modified", }, diff --git a/test/__snapshots__/knative.spec.js.snap b/test/__snapshots__/knative.spec.js.snap index 34e9b9c497ab..41c3dcf8ded2 100644 --- a/test/__snapshots__/knative.spec.js.snap +++ b/test/__snapshots__/knative.spec.js.snap @@ -13,6 +13,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"helm\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"no\\", @@ -935,6 +936,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"helm\\", \\"ingressDomain\\": \\"example.com\\", \\"monitoring\\": \\"no\\", @@ -1615,6 +1617,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"helm\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"no\\", @@ -2506,6 +2509,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"helm\\", \\"ingressDomain\\": \\"example.com\\", \\"monitoring\\": \\"no\\", @@ -3192,6 +3196,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"helm\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"no\\", @@ -4815,6 +4820,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"mynamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"helm\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"prometheus\\", @@ -7837,6 +7843,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"mynamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"helm\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"no\\", @@ -8473,6 +8480,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipsterrepository\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"jhipsternamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"helm\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"no\\", @@ -9162,6 +9170,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"k8s\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"no\\", @@ -10017,6 +10026,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"k8s\\", \\"ingressDomain\\": \\"example.com\\", \\"monitoring\\": \\"no\\", @@ -10632,6 +10642,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"k8s\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"no\\", @@ -11448,6 +11459,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"k8s\\", \\"ingressDomain\\": \\"example.com\\", \\"monitoring\\": \\"no\\", @@ -12070,6 +12082,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"k8s\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"no\\", @@ -14097,6 +14110,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"mynamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"k8s\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"prometheus\\", @@ -17356,6 +17370,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"mynamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"k8s\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"no\\", @@ -17926,6 +17941,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipsterrepository\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"jhipsternamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"generatorType\\": \\"k8s\\", \\"ingressDomain\\": \\"\\", \\"monitoring\\": \\"no\\", diff --git a/test/__snapshots__/kubernetes.helm.spec.js.snap b/test/__snapshots__/kubernetes.helm.spec.js.snap index 7839bca6cae7..1a8899049613 100644 --- a/test/__snapshots__/kubernetes.helm.spec.js.snap +++ b/test/__snapshots__/kubernetes.helm.spec.js.snap @@ -390,8 +390,10 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", @@ -1647,8 +1649,10 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", @@ -2319,6 +2323,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"ingressDomain\\": \\"example.com\\", \\"monitoring\\": \\"no\\", \\"istio\\": true @@ -3053,8 +3058,10 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", @@ -3566,7 +3573,7 @@ metadata: spec: selector: app: jhgate - type: + type: LoadBalancer ports: - name: http port: 8080 @@ -4744,8 +4751,10 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"mynamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"prometheus\\" + \\"monitoring\\": \\"prometheus\\", + \\"istio\\": false } } ", @@ -7578,8 +7587,10 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"mynamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", @@ -8073,8 +8084,10 @@ Object { \\"dockerRepositoryName\\": \\"jhipsterrepository\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"jhipsternamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", diff --git a/test/__snapshots__/kubernetes.spec.js.snap b/test/__snapshots__/kubernetes.spec.js.snap index 9101dc8fcfe1..ccf2a4016ccd 100644 --- a/test/__snapshots__/kubernetes.spec.js.snap +++ b/test/__snapshots__/kubernetes.spec.js.snap @@ -494,10 +494,12 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"kubernetesUseDynamicStorage\\": true, \\"kubernetesStorageClassName\\": \\"\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", @@ -1348,10 +1350,12 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"kubernetesUseDynamicStorage\\": true, \\"kubernetesStorageClassName\\": \\"\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", @@ -1894,10 +1898,12 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"kubernetesUseDynamicStorage\\": true, \\"kubernetesStorageClassName\\": \\"\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", @@ -2634,6 +2640,7 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"kubernetesUseDynamicStorage\\": true, \\"kubernetesStorageClassName\\": \\"\\", \\"ingressDomain\\": \\"example.com\\", @@ -3499,10 +3506,12 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"kubernetesUseDynamicStorage\\": true, \\"kubernetesStorageClassName\\": \\"\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", @@ -5873,10 +5882,12 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"mynamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"kubernetesUseDynamicStorage\\": true, \\"kubernetesStorageClassName\\": \\"\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"prometheus\\" + \\"monitoring\\": \\"prometheus\\", + \\"istio\\": false } } ", @@ -9116,10 +9127,12 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"mynamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"kubernetesUseDynamicStorage\\": true, \\"kubernetesStorageClassName\\": \\"\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", @@ -9690,10 +9703,12 @@ Object { \\"dockerRepositoryName\\": \\"jhipster\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"default\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"kubernetesUseDynamicStorage\\": true, \\"kubernetesStorageClassName\\": \\"\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", @@ -11611,10 +11626,12 @@ Object { \\"dockerRepositoryName\\": \\"jhipsterrepository\\", \\"dockerPushCommand\\": \\"docker push\\", \\"kubernetesNamespace\\": \\"jhipsternamespace\\", + \\"kubernetesServiceType\\": \\"LoadBalancer\\", \\"kubernetesUseDynamicStorage\\": true, \\"kubernetesStorageClassName\\": \\"\\", \\"ingressDomain\\": \\"\\", - \\"monitoring\\": \\"no\\" + \\"monitoring\\": \\"no\\", + \\"istio\\": false } } ", diff --git a/test/kubernetes.helm.spec.js b/test/kubernetes.helm.spec.js index bce8c89ca5d8..9125192934f9 100644 --- a/test/kubernetes.helm.spec.js +++ b/test/kubernetes.helm.spec.js @@ -305,6 +305,7 @@ describe('JHipster Kubernetes Helm Sub Generator', () => { jhipsterConsole: false, kubernetesServiceType: 'LoadBalancer', clusteredDbApps: [], + istio: false, }) .run(); }); diff --git a/test/templates/all-languages/.yo-rc.json b/test/templates/all-languages/.yo-rc.json index 8b0568fb2b85..2cfcf8429001 100644 --- a/test/templates/all-languages/.yo-rc.json +++ b/test/templates/all-languages/.yo-rc.json @@ -15,7 +15,7 @@ "messageBroker": false, "serviceDiscoveryType": false, "buildTool": "maven", - "jwtSecretKey": "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8", + "jwtSecretKey": "SECRET--50", "clientFramework": "angularX", "clientPackageManager": "npm", "applicationType": "monolith", diff --git a/test/templates/compose/01-gateway/.yo-rc.json b/test/templates/compose/01-gateway/.yo-rc.json index df39a39c62b7..da47014814d6 100644 --- a/test/templates/compose/01-gateway/.yo-rc.json +++ b/test/templates/compose/01-gateway/.yo-rc.json @@ -15,7 +15,7 @@ "searchEngine": "no", "serviceDiscoveryType": "eureka", "buildTool": "maven", - "jwtSecretKey": "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8", + "jwtSecretKey": "SECRET--50", "applicationType": "gateway", "testFrameworks": [ "gatling" diff --git a/test/templates/compose/02-mysql/.yo-rc.json b/test/templates/compose/02-mysql/.yo-rc.json index 69df58f44a01..ef9fe301e813 100644 --- a/test/templates/compose/02-mysql/.yo-rc.json +++ b/test/templates/compose/02-mysql/.yo-rc.json @@ -13,7 +13,7 @@ "prodDatabaseType": "mysql", "searchEngine": "no", "buildTool": "maven", - "jwtSecretKey": "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8", + "jwtSecretKey": "SECRET--50", "enableTranslation": true, "applicationType": "microservice", "serviceDiscoveryType": "eureka", diff --git a/test/templates/compose/03-psql/.yo-rc.json b/test/templates/compose/03-psql/.yo-rc.json index eb8b504968c2..9ff62e650a89 100644 --- a/test/templates/compose/03-psql/.yo-rc.json +++ b/test/templates/compose/03-psql/.yo-rc.json @@ -13,7 +13,7 @@ "prodDatabaseType": "postgresql", "searchEngine": "elasticsearch", "buildTool": "maven", - "jwtSecretKey": "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8", + "jwtSecretKey": "SECRET--50", "enableTranslation": true, "applicationType": "microservice", "serviceDiscoveryType": "eureka", diff --git a/test/templates/compose/04-mongo/.yo-rc.json b/test/templates/compose/04-mongo/.yo-rc.json index 90e078e3057d..e29ec8f0b2b8 100644 --- a/test/templates/compose/04-mongo/.yo-rc.json +++ b/test/templates/compose/04-mongo/.yo-rc.json @@ -12,7 +12,7 @@ "devDatabaseType": "mongodb", "prodDatabaseType": "mongodb", "buildTool": "maven", - "jwtSecretKey": "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8", + "jwtSecretKey": "SECRET--50", "enableTranslation": true, "applicationType": "microservice", "testFrameworks": [ diff --git a/test/templates/compose/05-cassandra/.yo-rc.json b/test/templates/compose/05-cassandra/.yo-rc.json index fc00c0f75462..b520ea775b82 100644 --- a/test/templates/compose/05-cassandra/.yo-rc.json +++ b/test/templates/compose/05-cassandra/.yo-rc.json @@ -13,7 +13,7 @@ "prodDatabaseType": "cassandra", "searchEngine": "no", "buildTool": "maven", - "jwtSecretKey": "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8", + "jwtSecretKey": "SECRET--50", "enableTranslation": true, "applicationType": "microservice", "testFrameworks": [ diff --git a/test/templates/compose/07-mariadb/.yo-rc.json b/test/templates/compose/07-mariadb/.yo-rc.json index 65e60fe6386c..5e61c297df76 100644 --- a/test/templates/compose/07-mariadb/.yo-rc.json +++ b/test/templates/compose/07-mariadb/.yo-rc.json @@ -13,7 +13,7 @@ "prodDatabaseType": "mariadb", "searchEngine": "no", "buildTool": "maven", - "jwtSecretKey": "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8", + "jwtSecretKey": "SECRET--50", "enableTranslation": true, "applicationType": "microservice", "testFrameworks": [ diff --git a/test/templates/compose/08-monolith/.yo-rc.json b/test/templates/compose/08-monolith/.yo-rc.json index 019e5b439910..5d86cee7e4e3 100644 --- a/test/templates/compose/08-monolith/.yo-rc.json +++ b/test/templates/compose/08-monolith/.yo-rc.json @@ -12,7 +12,7 @@ "devDatabaseType": "h2Disk", "prodDatabaseType": "mysql", "searchEngine": "elasticsearch", - "buildTool": "maven", + "buildTool": "maven", "enableTranslation": true, "rememberMeKey": "2bb60a80889aa6e6767e9ccd8714982681152aa5", "testFrameworks": [ diff --git a/test/templates/compose/10-couchbase/.yo-rc.json b/test/templates/compose/10-couchbase/.yo-rc.json index 84e8ab9ad167..b330a7746d48 100644 --- a/test/templates/compose/10-couchbase/.yo-rc.json +++ b/test/templates/compose/10-couchbase/.yo-rc.json @@ -12,7 +12,7 @@ "devDatabaseType": "couchbase", "prodDatabaseType": "couchbase", "buildTool": "maven", - "jwtSecretKey": "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8", + "jwtSecretKey": "SECRET--50", "enableTranslation": true, "applicationType": "microservice", "testFrameworks": [ diff --git a/test/templates/compose/11-mssql/.yo-rc.json b/test/templates/compose/11-mssql/.yo-rc.json index 2b1e6a6680f2..45ab22a77d9b 100644 --- a/test/templates/compose/11-mssql/.yo-rc.json +++ b/test/templates/compose/11-mssql/.yo-rc.json @@ -13,7 +13,7 @@ "prodDatabaseType": "mssql", "searchEngine": "no", "buildTool": "maven", - "jwtSecretKey": "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8", + "jwtSecretKey": "SECRET--50", "enableTranslation": true, "applicationType": "microservice", "testFrameworks": [ diff --git a/test/templates/compose/12-oracle/.yo-rc.json b/test/templates/compose/12-oracle/.yo-rc.json index 74f6fd9c1a23..fa2bbccf51cc 100644 --- a/test/templates/compose/12-oracle/.yo-rc.json +++ b/test/templates/compose/12-oracle/.yo-rc.json @@ -13,7 +13,7 @@ "prodDatabaseType": "oracle", "searchEngine": "no", "buildTool": "maven", - "jwtSecretKey": "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8", + "jwtSecretKey": "SECRET--50", "enableTranslation": true, "applicationType": "monolith", "testFrameworks": [ diff --git a/test/templates/default-microservice/.yo-rc.json b/test/templates/default-microservice/.yo-rc.json index 991246e13830..8d28477a11cd 100644 --- a/test/templates/default-microservice/.yo-rc.json +++ b/test/templates/default-microservice/.yo-rc.json @@ -20,7 +20,7 @@ "serviceDiscoveryType": "eureka", "buildTool": "maven", "enableSwaggerCodegen": false, - "jwtSecretKey": "fd54a45s65fds737b9aafcb3412e07ed99b267f33413274720ddbb7f6c5e64e9f14075f2d7ed041592f0b7657baf8", + "jwtSecretKey": "SECRET--50", "enableTranslation": false, "applicationType": "microservice", "testFrameworks": [],