interface.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package printers
  14. import (
  15. "io"
  16. "k8s.io/apimachinery/pkg/runtime"
  17. "k8s.io/apimachinery/pkg/runtime/schema"
  18. )
  19. // ResourcePrinter is an interface that knows how to print runtime objects.
  20. type ResourcePrinter interface {
  21. // Print receives a runtime object, formats it and prints it to a writer.
  22. PrintObj(runtime.Object, io.Writer) error
  23. }
  24. // ResourcePrinterFunc is a function that can print objects
  25. type ResourcePrinterFunc func(runtime.Object, io.Writer) error
  26. // PrintObj implements ResourcePrinter
  27. func (fn ResourcePrinterFunc) PrintObj(obj runtime.Object, w io.Writer) error {
  28. return fn(obj, w)
  29. }
  30. // PrintOptions struct defines a struct for various print options
  31. type PrintOptions struct {
  32. // supported Format types can be found in pkg/printers/printers.go
  33. OutputFormatType string
  34. OutputFormatArgument string
  35. NoHeaders bool
  36. WithNamespace bool
  37. WithKind bool
  38. Wide bool
  39. ShowLabels bool
  40. AbsoluteTimestamps bool
  41. Kind schema.GroupKind
  42. ColumnLabels []string
  43. SortBy string
  44. // indicates if it is OK to ignore missing keys for rendering an output template.
  45. AllowMissingKeys bool
  46. }