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
Prev Previous commit
fix: apply PR changes
  • Loading branch information
AhmedGrati committed Nov 30, 2022
commit 29c842cf48fe8bb4faecc09fee3544d5184a46ee
14 changes: 2 additions & 12 deletions pkg/transformer/kubernetes/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,6 @@ func getDirName(opt kobject.ConvertOptions) string {
return dirName
}

// func objectToRaw(object runtime.Object) runtime.RawExtension {
// r := runtime.RawExtension{
// Object: object,
// }

// bytes, _ := json.Marshal(object)
// r.Raw = bytes

// return r
// }

// PrintList will take the data converted and decide on the commandline attributes given
func PrintList(objects []runtime.Object, opt kobject.ConvertOptions) error {
var f *os.File
Expand Down Expand Up @@ -209,10 +198,11 @@ func PrintList(objects []runtime.Object, opt kobject.ConvertOptions) error {
if err != nil {
return fmt.Errorf("error in marshalling the List: %v", err)
}
// this part add --- which unifies the file
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.

if err != nil {
return errors.Wrap(err, "transformer.Print failed")
return errors.Wrap(err, "transformer to print to one single file failed")
}
files = append(files, printVal)
}
Expand Down