Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25817 from mshima/gateway-imperative
Add manual routes support to imperative gateway
- Loading branch information
Showing
24 changed files
with
232 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
generators/spring-cloud/generators/gateway/jdl/jdl-routes-option.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { before, it, describe, expect } from 'esmocha'; | ||
import { createImporterFromContent, ImportState } from '../../../../../jdl/jdl-importer.js'; | ||
import { convertSingleContentToJDL } from '../../../../../jdl/converters/json-to-jdl-converter.js'; | ||
|
||
const optionName = 'routes'; | ||
|
||
describe('generators - spring-cloud:gateway - jdl', () => { | ||
it('should not accept route and port', () => { | ||
expect(() => createImporterFromContent(`application { config { ${optionName} ["blog:123"] } }`)).toThrow( | ||
/The routes property name must match:/, | ||
); | ||
}); | ||
it('should not accept values starting with numbers', () => { | ||
expect(() => createImporterFromContent(`application { config { ${optionName} ["1foo"] } }`)).toThrow( | ||
/The routes property name must match:/, | ||
); | ||
}); | ||
it('should not accept empty value', () => { | ||
expect(() => createImporterFromContent(`application { config { ${optionName} [""] } }`)).toThrow( | ||
/The routes property name must match:/, | ||
); | ||
}); | ||
it('should not accept empty host', () => { | ||
expect(() => createImporterFromContent(`application { config { ${optionName} ["foo:"] } }`)).toThrow( | ||
/The routes property name must match:/, | ||
); | ||
}); | ||
it('should not accept empty port', () => { | ||
expect(() => createImporterFromContent(`application { config { ${optionName} ["foo:foo_host:"] } }`)).toThrow( | ||
/The routes property name must match:/, | ||
); | ||
}); | ||
it('should not accept non numeric port', () => { | ||
expect(() => createImporterFromContent(`application { config { ${optionName} ["foo:foo_host:1a"] } }`)).toThrow( | ||
/The routes property name must match:/, | ||
); | ||
}); | ||
describe(`parsing ${optionName}`, () => { | ||
let state: ImportState; | ||
|
||
before(() => { | ||
const importer = createImporterFromContent( | ||
`application { config { ${optionName} ["blog:blog_host:123", "store:store_host", "notification"] } }`, | ||
); | ||
state = importer.import(); | ||
}); | ||
|
||
it('should set expected value', () => { | ||
expect(state.exportedApplicationsWithEntities.jhipster.config[optionName]).toEqual([ | ||
'blog:blog_host:123', | ||
'store:store_host', | ||
'notification', | ||
]); | ||
}); | ||
}); | ||
describe(`export ${optionName}`, () => { | ||
let jdl: string; | ||
|
||
before(() => { | ||
jdl = convertSingleContentToJDL({ | ||
'generator-jhipster': { baseName: 'bar', [optionName]: ['blog:blog_host:123', 'store:store_host', 'notification'] }, | ||
}); | ||
}); | ||
|
||
it('should set expected value', () => { | ||
expect(jdl).toEqual(`application { | ||
config { | ||
baseName bar | ||
routes ["blog:blog_host:123", "store:store_host", "notification"] | ||
} | ||
} | ||
`); | ||
}); | ||
}); | ||
}); |
8 changes: 8 additions & 0 deletions
8
generators/spring-cloud/generators/gateway/jdl/jdl-routes-option.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { JHipsterOptionDefinition } from '../../../../../jdl/types/types.js'; | ||
|
||
export const jdlRoutesOptions: JHipsterOptionDefinition = { | ||
name: 'routes', | ||
tokenType: 'quotedList', | ||
type: 'quotedList', | ||
tokenValuePattern: /^"[A-Za-z][A-Za-z0-9_]*(?::[A-Za-z][A-Za-z0-9_]+(?::[0-9]+)?)?"$/, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type GatewayApplication = { | ||
gatewayRoutes?: Array<{ route: string; host: string; serverPort: string }>; | ||
routes?: string[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.