Skip to content

Commit

Permalink
Added missing jdl deployment options
Browse files Browse the repository at this point in the history
fixes #14817
  • Loading branch information
MathieuAA committed May 11, 2021
1 parent 2370799 commit e7e089f
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 11 deletions.
39 changes: 28 additions & 11 deletions jdl/jhipster/deployment-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@ const DeploymentTypes = {
exists: deploymentType => !!deploymentType && !!DeploymentTypes[deploymentType.toUpperCase().replace('-', '')],
};

const kubernetesRelatedOptions = {
kubernetesNamespace: 'default',
kubernetesServiceType: {
loadBalancer: 'LoadBalancer',
nodePort: 'NodePort',
ingress: 'Ingress',
},
kubernetesStorageClassName: '',
kubernetesUseDynamicStorage: {
false: false,
true: true,
},
ingressDomain: '',
ingressType: {
nginx: 'nginx',
gke: 'gke',
},
istio: {
false: false,
true: true,
},
};

const Options = {
deploymentType: {
dockerCompose: DeploymentTypes.DOCKERCOMPOSE,
Expand All @@ -50,17 +73,7 @@ const Options = {
dockerRepositoryName: '',
dockerPushCommand: 'docker push',
// Kubernetes specific
kubernetesNamespace: 'default',
kubernetesServiceType: {
loadBalancer: 'LoadBalancer',
nodePort: 'NodePort',
ingress: 'Ingress',
},
ingressDomain: '',
istio: {
false: false,
true: true,
},
...kubernetesRelatedOptions,
// openshift specific
openshiftNamespace: 'default',
storageType: {
Expand All @@ -84,7 +97,11 @@ Options.defaults = (deploymentType = Options.deploymentType.dockerCompose) =>
dockerPushCommand: Options.dockerPushCommand,
kubernetesNamespace: deploymentType === Options.deploymentType.kubernetes ? Options.kubernetesNamespace : undefined,
kubernetesServiceType: deploymentType === Options.deploymentType.kubernetes ? Options.kubernetesServiceType.loadBalancer : undefined,
kubernetesStorageClassName: deploymentType === Options.deploymentType.kubernetes ? Options.kubernetesStorageClassName : '',
kubernetesUseDynamicStorage:
deploymentType === Options.deploymentType.kubernetes ? deploymentType === Options.deploymentType.kubernetes : false,
ingressDomain: deploymentType === Options.deploymentType.kubernetes ? Options.ingressDomain : undefined,
ingressType: deploymentType === Options.deploymentType.kubernetes ? Options.ingressType.nginx : undefined,
istio: deploymentType === Options.deploymentType.kubernetes ? Options.istio.false : undefined,
openshiftNamespace: deploymentType === Options.deploymentType.openshift ? Options.openshiftNamespace : undefined,
storageType: deploymentType === Options.deploymentType.openshift ? Options.storageType.ephemeral : undefined,
Expand Down
47 changes: 47 additions & 0 deletions test/jdl/jdl-importer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,53 @@ relationship OneToOne {
});
});
});
context('when parsing two JDL applications with and without entities ', () => {
let returned;
const APPLICATION_NAMES = ['app1', 'app2'];

before(() => {
const importer = createImporterFromFiles([path.join(__dirname, 'test-files', 'applications_with_and_without_entities.jdl')]);
returned = importer.import();
});

after(() => {
APPLICATION_NAMES.forEach(applicationName => {
fse.removeSync(applicationName);
});
});

it('should return the import state', () => {
expect(returned.exportedEntities).to.have.lengthOf(1);
expect(returned.exportedApplications).to.have.lengthOf(2);
expect(Object.keys(returned.exportedApplicationsWithEntities).length).to.equal(2);
expect(returned.exportedDeployments).to.have.lengthOf(0);
});
it('should create the folders and the .yo-rc.json files', () => {
APPLICATION_NAMES.forEach(applicationName => {
expect(fse.statSync(path.join(applicationName, '.yo-rc.json')).isFile()).to.be.true;
expect(fse.statSync(applicationName).isDirectory()).to.be.true;
});
});
it('should create the entity folder in only one app folder', () => {
expect(fse.existsSync(path.join(APPLICATION_NAMES[0], '.jhipster'))).to.be.false;
expect(fse.statSync(path.join(APPLICATION_NAMES[1], '.jhipster')).isDirectory()).to.be.true;
expect(fse.statSync(path.join(APPLICATION_NAMES[1], '.jhipster', 'BankAccount.json')).isFile()).to.be.true;
});
it('should export the application contents', () => {
expect(returned.exportedApplicationsWithEntities[APPLICATION_NAMES[0]].entities).to.have.lengthOf(0);
expect(returned.exportedApplicationsWithEntities[APPLICATION_NAMES[1]].entities).to.have.lengthOf(1);
});
it('should return the corresponding exportedApplicationsWithEntities', () => {
returned.exportedApplications.forEach(application => {
const applicationConfig = application['generator-jhipster'];
const entityNames = application.entities || [];
const applicationWithEntities = returned.exportedApplicationsWithEntities[applicationConfig.baseName];
expect(applicationConfig).to.be.eql(applicationWithEntities.config);
expect(applicationWithEntities.entities.map(entity => entity.name)).to.be.eql(entityNames);
expect(returned.exportedEntities.filter(entity => entityNames.includes(entity.name))).to.be.eql(applicationWithEntities.entities);
});
});
});
context('when parsing one JDL application and entities passed as string', () => {
let returned;

Expand Down

0 comments on commit e7e089f

Please sign in to comment.