diff --git a/pkg/util.go b/pkg/util.go index 7e8dd85..0a2165a 100644 --- a/pkg/util.go +++ b/pkg/util.go @@ -194,6 +194,8 @@ func Output(w io.Writer, obj runtime.Object, format string) error { s = json.NewSerializer(json.DefaultMetaFactory, Scheme, Scheme, true) case "yaml": s = json.NewYAMLSerializer(json.DefaultMetaFactory, Scheme, Scheme) + // TODO: clean up "creationTimestamp: null" upstream + w = &stripCreationTimestamp{w} default: return fmt.Errorf("unknown format: %s", format) } @@ -202,3 +204,16 @@ func Output(w io.Writer, obj runtime.Object, format string) error { return codec.Encode(obj, w) } + +type stripCreationTimestamp struct { + w io.Writer +} + +func (s *stripCreationTimestamp) Write(p []byte) (n int, err error) { + p2 := strings.Replace(string(p), "\n creationTimestamp: null\n", "\n", -1) + n, err = s.w.Write([]byte(p2)) + if n == len(p2) { + n = len(p) + } + return n, err +}