feat: Save diagram YAML content as PNG metadata and add extract CLI command - #294
Open
herley-shaori wants to merge 1 commit into
Open
feat: Save diagram YAML content as PNG metadata and add extract CLI command#294herley-shaori wants to merge 1 commit into
herley-shaori wants to merge 1 commit into
Conversation
…ommand - Implement PNG chunk parser and writer in internal/ctl/metadata.go to embed base64-encoded YAML in standard tEXt chunks. - Store rendered/processed YAML content in CreateOptions during diagram generation. - Encode and write PNG files with embedded metadata chunks in createDiagram. - Add 'extract' subcommand to awsdac CLI to decode and print embedded YAML metadata from generated PNG images. - Add unit tests for embedding, extraction, and validation of PNG metadata.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for embedding the diagram-as-code YAML configuration inside the generated PNG image as metadata, and adds an
extractsubcommand to the CLI to retrieve it. This resolves #258.Rationale
Currently, when diagram images are uploaded to wikis, blogs, or other platforms, it is difficult to find the original YAML code used to generate them if it is not explicitly attached or tracked. Storing the configuration directly inside the image metadata (similar to how PlantUML works) allows seamless retrieval of the source design.
Changes
tEXtchunk right after theIHDRchunk. The chunk uses the keywordawsdacand stores a base64-encoded representation of the source YAML.extractsubcommand toawsdacto scan PNG chunks, locate theawsdacmetadata chunk, base64-decode the content, and output the original YAML to stdout.Verification
All unit tests and integration tests compile and pass successfully:
go test ./...Manual testing verified:
The extraction successfully prints the exact YAML contents of the original diagram design file.