Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add YAML document separator to each manifest #1928

Closed
wants to merge 3 commits into from

Conversation

rassie
Copy link
Contributor

@rassie rassie commented Feb 8, 2024

When output to STDOUT is requested, each manifest in an app is rendered separately and dumped to standard output. In case an app contains more than one chart, a document separator will be missing between adjacent charts, since there is no YAML document separator either at the beginning or at the end of an individual output. The last resource of the preceding chart and the first resource of the following chart will be merged into a random mess. By adding a YAML document separator after each manifest unconditionally, this can be cleanly avoided.

Fixes: cdk8s-team/cdk8s#2155

@rassie rassie force-pushed the multi-chart-stdout-separator branch from fe7bf39 to 13a9d61 Compare February 8, 2024 13:19
When output to STDOUT is requested, each manifest in an app is rendered separately and dumped to standard output.
In case an app contains more than one chart, a document separator will be missing between adjacent charts, since there
is no YAML document separator either at the beginning or at the end of an individual output. The last resource of the
preceding chart and the first resource of the following chart will be merged into a random mess. By adding a YAML
document separator after each manifest unconditionally, this can be cleanly avoided.

Fixes: #943

Signed-off-by: Nikolai Prokoschenko <[email protected]>
@rassie rassie force-pushed the multi-chart-stdout-separator branch from 13a9d61 to 5536128 Compare February 8, 2024 13:24
@rassie rassie changed the title Add YAML document separator to each manifest fix!: Add YAML document separator to each manifest Feb 8, 2024
@rassie rassie changed the title fix!: Add YAML document separator to each manifest fix: Add YAML document separator to each manifest Feb 8, 2024
@@ -94,6 +94,7 @@ class Command implements yargs.CommandModule {
const app = await synthApp(command, tempDir, stdout, recordConstructMetadata);
for (const f of app.manifests) {
fs.createReadStream(f).pipe(process.stdout);
process.stdout.write('---\n');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work as expected because the line just above it as asynchronous. It will print this before the manifests are printed. To do this we first need to await on the created pipeline:

import { pipeline } from 'stream';
import { promisify } from 'util';

const asyncPipeline = promisify(pipeline);

await asyncPipeline(fs.createReadStream(f), process.stdout, { end: false });
process.stdout.write('---\n');

We should also have test to assert on the content of process.stdout using jest spies or something.

@iliapolo iliapolo added the response-requested Awaiting response from author label Sep 11, 2024
Copy link
Contributor

This PR has not received a response in a while and will be closed soon. If you want to keep it open, please leave a comment below @mentioning a maintainer.

@github-actions github-actions bot added the closing-soon Issue/PR will be closing soon if no response is provided label Oct 11, 2024
@github-actions github-actions bot added closed-for-staleness Issue/PR was closed due to staleness and removed closing-soon Issue/PR will be closing soon if no response is provided labels Oct 18, 2024
@github-actions github-actions bot closed this Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness Issue/PR was closed due to staleness response-requested Awaiting response from author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cdk8s synth -p fails to insert necessary document start markers
2 participants