/* * Copyright 2026 Oleg Borodin * * This work is published and licensed under a Creative Commons * Attribution-NonCommercial-NoDerivatives 4.0 International License. * * Distribution of this work is permitted, but commercial use and * modifications are strictly prohibited. */ package accountcmd import ( "fmt" "sigs.k8s.io/yaml" ) func printResponse(res any, err error) { type Response struct { Error bool `json:"error" yaml:"error"` Message string `json:"message,omitempty" yaml:"message,omitempty"` Result any `json:"result,omitempty" yaml:"result,omitempty"` } resp := Response{} if err != nil { resp.Error = true resp.Message = err.Error() } else { resp.Result = res } respBytes, _ := yaml.Marshal(resp) fmt.Printf("---\n%s\n", string(respBytes)) }