Skip to content

Add cli option to output all strings in plain text#688

Open
Phuong-Le-NN wants to merge 1 commit intocoreos:mainfrom
Phuong-Le-NN:humanReadableInline
Open

Add cli option to output all strings in plain text#688
Phuong-Le-NN wants to merge 1 commit intocoreos:mainfrom
Phuong-Le-NN:humanReadableInline

Conversation

@Phuong-Le-NN
Copy link

Adding --plain-text CLI flag to generate an Ignition config in plain text This generated config should be used for debugging only

Fixes: #670

Adding --plain-text CLI flag to generate an Ignition config in plain text
This generated config should be used for debugging only

Fixes: coreos#670
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a --plain-text CLI flag for debugging, which generates an Ignition config with plain text strings instead of data URLs. The implementation correctly adds a new parameter to baseutil.MakeDataURL, a new option to TranslateOptions, and propagates the changes through various spec versions. The logic to skip JSON validation for plain text output is also correctly handled. I have two suggestions for improvement: one addresses an inconsistent use of the new flag in an experimental spec, and the other is a minor style fix to maintain code consistency.

Comment on lines +18 to +21
FilesDir string // allow embedding local files relative to this directory
NoResourceAutoCompression bool // skip automatic compression of inline/local resources
PlainTextEncoding bool // plain text, only for debugging
DebugPrintTranslations bool // report translations to stderr

Choose a reason for hiding this comment

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

medium

This change introduces tabs for alignment within the TranslateOptions struct. The project's coding style appears to use spaces for alignment. To maintain consistency, please use spaces instead of tabs.

Suggested change
FilesDir string // allow embedding local files relative to this directory
NoResourceAutoCompression bool // skip automatic compression of inline/local resources
PlainTextEncoding bool // plain text, only for debugging
DebugPrintTranslations bool // report translations to stderr
FilesDir string // allow embedding local files relative to this directory
NoResourceAutoCompression bool // skip automatic compression of inline/local resources
PlainTextEncoding bool // plain text, only for debugging
DebugPrintTranslations bool // report translations to stderr

Copy link
Member

Choose a reason for hiding this comment

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

@Phuong-Le-NN this seems valid, just need to replace the tab by spaces.


userCfgContent := []byte(buildGrubConfig(c.Grub))
src, compression, err := baseutil.MakeDataURL(userCfgContent, nil, !options.NoResourceAutoCompression)
src, compression, err := baseutil.MakeDataURL(userCfgContent, nil, !options.NoResourceAutoCompression, false)

Choose a reason for hiding this comment

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

medium

In this experimental spec, the plain-text option is not propagated to MakeDataURL for the user grub config. This is inconsistent with other experimental specs and the overall goal of the feature. To ensure consistent behavior for the --plain-text flag, options.PlainTextEncoding should be used here instead of hardcoding false.

Suggested change
src, compression, err := baseutil.MakeDataURL(userCfgContent, nil, !options.NoResourceAutoCompression, false)
src, compression, err := baseutil.MakeDataURL(userCfgContent, nil, !options.NoResourceAutoCompression, options.PlainTextEncoding)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cli option to output all strings in plain text in the Ignition config

2 participants