-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- `bin/renderlocal` now imports `test/lib/LocalRenderer` - this allows other node projects that include MTPs to be able to use the `LocalRenderer` in their own tests - also addresses PR feedback: - items previously added to `src` are now in `test/lib` - `razeedeploy-core` PR was updated to remove logic defaulting namespaces. that logic has been moved here in `test/lib/IOUtils.js`'s `kubeDataFromYamlFiles` method and a warning is emitted when it defaults
- Loading branch information
1 parent
9c47c9e
commit 6ad352a
Showing
6 changed files
with
51 additions
and
28 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
2 changes: 1 addition & 1 deletion
2
src/LocalMustacheTemplateController.js → test/lib/LocalMustacheTemplateController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const IOUtils = require('./IOUtils'); | ||
const LocalMustacheTemplateController = require('./LocalMustacheTemplateController'); | ||
|
||
const { FetchEnvs, MockController } = require('@razee/razeedeploy-core'); | ||
|
||
module.exports = class LocalRenderer { | ||
constructor(mtpPath, ...envPaths) { | ||
this.mtpPath = mtpPath; | ||
this.envPaths = envPaths; | ||
} | ||
|
||
async render() { | ||
const mtp = await IOUtils.readYamlFile(this.mtpPath); | ||
const kubeData = await IOUtils.kubeDataFromYamlFiles(...this.envPaths); | ||
|
||
const eventData = { | ||
type: 'ADDED', | ||
object: mtp[0] | ||
} | ||
|
||
const fetchEnvs = new FetchEnvs(new MockController(eventData, kubeData)); | ||
const view = await fetchEnvs.get('spec'); | ||
|
||
const mtpController = new LocalMustacheTemplateController({eventData: eventData, kubeData: kubeData}); | ||
let templates = mtpController.concatTemplates(); | ||
templates = await mtpController.processTemplate(templates, view); | ||
|
||
if (templates.length > 1) { | ||
throw Error("can only handle one template!"); | ||
} | ||
|
||
return templates[0]; | ||
} | ||
} |
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