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

Merge the same TOML file writing logic #1822

Merged
merged 2 commits into from
Jul 10, 2023

Conversation

ESWZY
Copy link
Contributor

@ESWZY ESWZY commented Jul 3, 2023

Summary

Seeing that there is the same TOML file writing logic here, for maintainability considerations, they can be merged together.

Output

No change.

Documentation

  • Should this change be documented?
    • No

@ESWZY ESWZY requested review from a team as code owners July 3, 2023 01:30
@github-actions github-actions bot added this to the 0.30.0 milestone Jul 3, 2023
@github-actions github-actions bot added the type/enhancement Issue that requests a new feature or improvement. label Jul 3, 2023
@ESWZY ESWZY force-pushed the merge-toml-writing branch 2 times, most recently from 1b236e8 to 36c234e Compare July 3, 2023 02:36
@ESWZY ESWZY marked this pull request as draft July 3, 2023 03:52
@ESWZY ESWZY marked this pull request as ready for review July 3, 2023 04:35
@ESWZY ESWZY force-pushed the merge-toml-writing branch from 36c234e to d78e829 Compare July 3, 2023 04:36
Copy link
Contributor

@joe-kimmel-vmw joe-kimmel-vmw left a comment

Choose a reason for hiding this comment

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

Thanks for contributing @ESWZY !

It looks like your intention is to "DRY" up this part of the code by merging redundant codepaths? I think that's a fine idea overall though I'll defer to the actual pack maintainers' judgement.

I've made a couple of suggestions. I think as a project we really do want our error messages to be as helpful and informative as possible, so maintaining the existing specificity of the error messages is probably desired.

buf := &bytes.Buffer{}
err := toml.NewEncoder(buf).Encode(stack)
if err != nil {
return errors.Wrap(err, "marshaling stack metadata")
Copy link
Contributor

Choose a reason for hiding this comment

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

imo the loss of specific error messages here and above is undesirable, but we could fix this by passing in one additional parameter to writeToml something like dataDescriptor string and it could then be given the value stack metadata on line 253 below, and appropriate values elsewhere. What do you think?


return ctrClient.CopyToContainer(ctx, containerID, "/", reader, types.CopyToContainerOptions{})
// WriteToml writes a `data.toml` for test only.
func WriteToml(dstPath string, data interface{}, os string) ContainerOperation {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think rather than introduce a new public API function only for the tests, it would be better to test one of the existing public functions

@ESWZY
Copy link
Contributor Author

ESWZY commented Jul 4, 2023

Thanks for your generous suggestions, I will consider it!

@jjbustamante jjbustamante modified the milestones: 0.30.0, 0.31.0 Jul 4, 2023
Signed-off-by: Woa <me@wuzy.cn>
@ESWZY ESWZY force-pushed the merge-toml-writing branch from d78e829 to 8b81013 Compare July 5, 2023 01:38
@github-actions github-actions bot modified the milestones: 0.31.0, 0.30.0 Jul 5, 2023
@natalieparellano natalieparellano modified the milestones: 0.30.0, 0.31.0 Jul 5, 2023
Copy link
Contributor

@joe-kimmel-vmw joe-kimmel-vmw left a comment

Choose a reason for hiding this comment

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

LGTM but it'll have to wait for a pack maintainer review :)

@jkutner jkutner enabled auto-merge July 10, 2023 14:28
@github-actions github-actions bot modified the milestones: 0.31.0, 0.30.0 Jul 10, 2023
@jkutner jkutner merged commit 88a998d into buildpacks:main Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants