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: Make the out flag print to one file using seperator #1541

Merged

Conversation

AhmedGrati
Copy link
Contributor

Description

This pull request solves #1539.

Implementation

Basically, it has the exact implementation of the helm template command. It will output all the k8s resources in one YAML file using the --- separator. If the user specifies a JSON output, it will return an error since we cannot have multiple JSON resources in one file.

@AhmedGrati AhmedGrati added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 28, 2022
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Nov 28, 2022
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 28, 2022
@AhmedGrati AhmedGrati changed the title Fix: Make the out flag print to one file using seperator Fix: Make the out flag print to one file using seperator [WIP] Nov 28, 2022
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 30, 2022
@AhmedGrati AhmedGrati changed the title Fix: Make the out flag print to one file using seperator [WIP] Fix: Make the out flag print to one file using seperator Nov 30, 2022
Copy link
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

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

boom-mind-blown

SO HAPPY THIS MAKES TESTS PASS.

Thank you! Small minor changes, but otherwise code LGTM.

Update the PR with the changes and then feel free to merge.

return r
}
// return r
// }
Copy link
Member

Choose a reason for hiding this comment

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

remove commented out section

return fmt.Errorf("error in marshalling the List: %v", err)
}
data = []byte(fmt.Sprintf("---\n%s", data))
printVal, err := transformer.Print("", dirName, "", data, opt.ToStdout, opt.GenerateJSON, f, opt.Provider)
Copy link
Member

Choose a reason for hiding this comment

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

good, but you need to add comments "this part add --- which unifies the file", etc.

data = []byte(fmt.Sprintf("---\n%s", data))
printVal, err := transformer.Print("", dirName, "", data, opt.ToStdout, opt.GenerateJSON, f, opt.Provider)
if err != nil {
return errors.Wrap(err, "transformer.Print failed")
Copy link
Member

Choose a reason for hiding this comment

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

I know this is outside the scope of the PR, but perhaps change this error output while you're at it :) "transformer to print to one single file failed" or something like that.

@hangyan
Copy link
Contributor

hangyan commented Dec 1, 2022

LGTM

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AhmedGrati, cdrage, hangyan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [AhmedGrati,cdrage,hangyan]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants