Add generated file
This PR adds generated files under pkg/client and vendor folder.
This commit is contained in:
42
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/BUILD
generated
vendored
Normal file
42
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/BUILD
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"discard.go",
|
||||
"interface.go",
|
||||
"json.go",
|
||||
"name.go",
|
||||
"sourcechecker.go",
|
||||
"typesetter.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/ghodss/yaml:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["sourcechecker_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
30
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/discard.go
generated
vendored
Normal file
30
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/discard.go
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package printers
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// NewDiscardingPrinter is a printer that discards all objects
|
||||
func NewDiscardingPrinter() ResourcePrinterFunc {
|
||||
return ResourcePrinterFunc(func(runtime.Object, io.Writer) error {
|
||||
return nil
|
||||
})
|
||||
}
|
37
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/interface.go
generated
vendored
Normal file
37
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/interface.go
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package printers
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// ResourcePrinterFunc is a function that can print objects
|
||||
type ResourcePrinterFunc func(runtime.Object, io.Writer) error
|
||||
|
||||
// PrintObj implements ResourcePrinter
|
||||
func (fn ResourcePrinterFunc) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
return fn(obj, w)
|
||||
}
|
||||
|
||||
// ResourcePrinter is an interface that knows how to print runtime objects.
|
||||
type ResourcePrinter interface {
|
||||
// Print receives a runtime object, formats it and prints it to a writer.
|
||||
PrintObj(runtime.Object, io.Writer) error
|
||||
}
|
105
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/json.go
generated
vendored
Normal file
105
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/json.go
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package printers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
)
|
||||
|
||||
// JSONPrinter is an implementation of ResourcePrinter which outputs an object as JSON.
|
||||
type JSONPrinter struct{}
|
||||
|
||||
// PrintObj is an implementation of ResourcePrinter.PrintObj which simply writes the object to the Writer.
|
||||
func (p *JSONPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
// we use reflect.Indirect here in order to obtain the actual value from a pointer.
|
||||
// we need an actual value in order to retrieve the package path for an object.
|
||||
// using reflect.Indirect indiscriminately is valid here, as all runtime.Objects are supposed to be pointers.
|
||||
if InternalObjectPreventer.IsForbidden(reflect.Indirect(reflect.ValueOf(obj)).Type().PkgPath()) {
|
||||
return fmt.Errorf(InternalObjectPrinterErr)
|
||||
}
|
||||
|
||||
switch obj := obj.(type) {
|
||||
case *runtime.Unknown:
|
||||
var buf bytes.Buffer
|
||||
err := json.Indent(&buf, obj.Raw, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
buf.WriteRune('\n')
|
||||
_, err = buf.WriteTo(w)
|
||||
return err
|
||||
}
|
||||
|
||||
if obj.GetObjectKind().GroupVersionKind().Empty() {
|
||||
return fmt.Errorf("missing apiVersion or kind; try GetObjectKind().SetGroupVersionKind() if you know the type")
|
||||
}
|
||||
|
||||
data, err := json.MarshalIndent(obj, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data = append(data, '\n')
|
||||
_, err = w.Write(data)
|
||||
return err
|
||||
}
|
||||
|
||||
// YAMLPrinter is an implementation of ResourcePrinter which outputs an object as YAML.
|
||||
// The input object is assumed to be in the internal version of an API and is converted
|
||||
// to the given version first.
|
||||
type YAMLPrinter struct {
|
||||
version string
|
||||
converter runtime.ObjectConvertor
|
||||
}
|
||||
|
||||
// PrintObj prints the data as YAML.
|
||||
func (p *YAMLPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
// we use reflect.Indirect here in order to obtain the actual value from a pointer.
|
||||
// we need an actual value in order to retrieve the package path for an object.
|
||||
// using reflect.Indirect indiscriminately is valid here, as all runtime.Objects are supposed to be pointers.
|
||||
if InternalObjectPreventer.IsForbidden(reflect.Indirect(reflect.ValueOf(obj)).Type().PkgPath()) {
|
||||
return fmt.Errorf(InternalObjectPrinterErr)
|
||||
}
|
||||
|
||||
switch obj := obj.(type) {
|
||||
case *runtime.Unknown:
|
||||
data, err := yaml.JSONToYAML(obj.Raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = w.Write(data)
|
||||
return err
|
||||
}
|
||||
|
||||
if obj.GetObjectKind().GroupVersionKind().Empty() {
|
||||
return fmt.Errorf("missing apiVersion or kind; try GetObjectKind().SetGroupVersionKind() if you know the type")
|
||||
}
|
||||
|
||||
output, err := yaml.Marshal(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = fmt.Fprint(w, string(output))
|
||||
return err
|
||||
}
|
124
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/name.go
generated
vendored
Normal file
124
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/name.go
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package printers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// NamePrinter is an implementation of ResourcePrinter which outputs "resource/name" pair of an object.
|
||||
type NamePrinter struct {
|
||||
// ShortOutput indicates whether an operation should be
|
||||
// printed along side the "resource/name" pair for an object.
|
||||
ShortOutput bool
|
||||
// Operation describes the name of the action that
|
||||
// took place on an object, to be included in the
|
||||
// finalized "successful" message.
|
||||
Operation string
|
||||
}
|
||||
|
||||
// PrintObj is an implementation of ResourcePrinter.PrintObj which decodes the object
|
||||
// and print "resource/name" pair. If the object is a List, print all items in it.
|
||||
func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
// we use reflect.Indirect here in order to obtain the actual value from a pointer.
|
||||
// using reflect.Indirect indiscriminately is valid here, as all runtime.Objects are supposed to be pointers.
|
||||
// we need an actual value in order to retrieve the package path for an object.
|
||||
if InternalObjectPreventer.IsForbidden(reflect.Indirect(reflect.ValueOf(obj)).Type().PkgPath()) {
|
||||
return fmt.Errorf(InternalObjectPrinterErr)
|
||||
}
|
||||
|
||||
if meta.IsListType(obj) {
|
||||
// we allow unstructured lists for now because they always contain the GVK information. We should chase down
|
||||
// callers and stop them from passing unflattened lists
|
||||
// TODO chase the caller that is setting this and remove it.
|
||||
if _, ok := obj.(*unstructured.UnstructuredList); !ok {
|
||||
return fmt.Errorf("list types are not supported by name printing: %T", obj)
|
||||
}
|
||||
|
||||
items, err := meta.ExtractList(obj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, obj := range items {
|
||||
if err := p.PrintObj(obj, w); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if obj.GetObjectKind().GroupVersionKind().Empty() {
|
||||
return fmt.Errorf("missing apiVersion or kind; try GetObjectKind().SetGroupVersionKind() if you know the type")
|
||||
}
|
||||
|
||||
name := "<unknown>"
|
||||
if acc, err := meta.Accessor(obj); err == nil {
|
||||
if n := acc.GetName(); len(n) > 0 {
|
||||
name = n
|
||||
}
|
||||
}
|
||||
|
||||
return printObj(w, name, p.Operation, p.ShortOutput, GetObjectGroupKind(obj))
|
||||
}
|
||||
|
||||
func GetObjectGroupKind(obj runtime.Object) schema.GroupKind {
|
||||
if obj == nil {
|
||||
return schema.GroupKind{Kind: "<unknown>"}
|
||||
}
|
||||
groupVersionKind := obj.GetObjectKind().GroupVersionKind()
|
||||
if len(groupVersionKind.Kind) > 0 {
|
||||
return groupVersionKind.GroupKind()
|
||||
}
|
||||
|
||||
if uns, ok := obj.(*unstructured.Unstructured); ok {
|
||||
if len(uns.GroupVersionKind().Kind) > 0 {
|
||||
return uns.GroupVersionKind().GroupKind()
|
||||
}
|
||||
}
|
||||
|
||||
return schema.GroupKind{Kind: "<unknown>"}
|
||||
}
|
||||
|
||||
func printObj(w io.Writer, name string, operation string, shortOutput bool, groupKind schema.GroupKind) error {
|
||||
if len(groupKind.Kind) == 0 {
|
||||
return fmt.Errorf("missing kind for resource with name %v", name)
|
||||
}
|
||||
|
||||
if len(operation) > 0 {
|
||||
operation = " " + operation
|
||||
}
|
||||
|
||||
if shortOutput {
|
||||
operation = ""
|
||||
}
|
||||
|
||||
if len(groupKind.Group) == 0 {
|
||||
fmt.Fprintf(w, "%s/%s%s\n", strings.ToLower(groupKind.Kind), name, operation)
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "%s.%s/%s%s\n", strings.ToLower(groupKind.Kind), groupKind.Group, name, operation)
|
||||
return nil
|
||||
}
|
60
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/sourcechecker.go
generated
vendored
Normal file
60
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/sourcechecker.go
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package printers
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
InternalObjectPrinterErr = "a versioned object must be passed to a printer"
|
||||
|
||||
// disallowedPackagePrefixes contains regular expression templates
|
||||
// for object package paths that are not allowed by printers.
|
||||
disallowedPackagePrefixes = []string{
|
||||
"k8s.io/kubernetes/pkg/apis/",
|
||||
}
|
||||
)
|
||||
|
||||
var InternalObjectPreventer = &illegalPackageSourceChecker{disallowedPackagePrefixes}
|
||||
|
||||
func IsInternalObjectError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return err.Error() == InternalObjectPrinterErr
|
||||
}
|
||||
|
||||
// illegalPackageSourceChecker compares a given
|
||||
// object's package path, and determines if the
|
||||
// object originates from a disallowed source.
|
||||
type illegalPackageSourceChecker struct {
|
||||
// disallowedPrefixes is a slice of disallowed package path
|
||||
// prefixes for a given runtime.Object that we are printing.
|
||||
disallowedPrefixes []string
|
||||
}
|
||||
|
||||
func (c *illegalPackageSourceChecker) IsForbidden(pkgPath string) bool {
|
||||
for _, forbiddenPrefix := range c.disallowedPrefixes {
|
||||
if strings.HasPrefix(pkgPath, forbiddenPrefix) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
66
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/sourcechecker_test.go
generated
vendored
Normal file
66
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/sourcechecker_test.go
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package printers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIllegalPackageSourceChecker(t *testing.T) {
|
||||
disallowedPrefixes := []string{
|
||||
"foo/bar",
|
||||
"k8s.io/foo/bar/vendor/k8s.io/baz/buz",
|
||||
"bar/foo/baz",
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
pkgPath string
|
||||
shouldBeAllowed bool
|
||||
}{
|
||||
{
|
||||
name: "package path beginning with forbidden prefix is rejected",
|
||||
pkgPath: "foo/bar/baz/buz",
|
||||
shouldBeAllowed: false,
|
||||
},
|
||||
{
|
||||
name: "package path not fully matching forbidden prefix is allowed",
|
||||
pkgPath: "bar/foo",
|
||||
shouldBeAllowed: true,
|
||||
},
|
||||
{
|
||||
name: "package path containing forbidden prefix (not as prefix) is allowed",
|
||||
pkgPath: "k8s.io/bar/foo/baz/etc",
|
||||
shouldBeAllowed: true,
|
||||
},
|
||||
}
|
||||
|
||||
checker := &illegalPackageSourceChecker{disallowedPrefixes}
|
||||
|
||||
for _, tc := range testCases {
|
||||
if checker.IsForbidden(tc.pkgPath) {
|
||||
if tc.shouldBeAllowed {
|
||||
t.Fatalf("expected package path %q to have been allowed", tc.pkgPath)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if !tc.shouldBeAllowed {
|
||||
t.Fatalf("expected package path %q to have been rejected", tc.pkgPath)
|
||||
}
|
||||
}
|
||||
}
|
95
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/typesetter.go
generated
vendored
Normal file
95
vendor/k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers/typesetter.go
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package printers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// TypeSetterPrinter is an implementation of ResourcePrinter wraps another printer with types set on the objects
|
||||
type TypeSetterPrinter struct {
|
||||
Delegate ResourcePrinter
|
||||
|
||||
Typer runtime.ObjectTyper
|
||||
}
|
||||
|
||||
// NewTypeSetter constructs a wrapping printer with required params
|
||||
func NewTypeSetter(typer runtime.ObjectTyper) *TypeSetterPrinter {
|
||||
return &TypeSetterPrinter{Typer: typer}
|
||||
}
|
||||
|
||||
// PrintObj is an implementation of ResourcePrinter.PrintObj which sets type information on the obj for the duration
|
||||
// of printing. It is NOT threadsafe.
|
||||
func (p *TypeSetterPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
|
||||
if obj == nil {
|
||||
return p.Delegate.PrintObj(obj, w)
|
||||
}
|
||||
if !obj.GetObjectKind().GroupVersionKind().Empty() {
|
||||
return p.Delegate.PrintObj(obj, w)
|
||||
}
|
||||
|
||||
// we were empty coming in, make sure we're empty going out. This makes the call thread-unsafe
|
||||
defer func() {
|
||||
obj.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
|
||||
}()
|
||||
|
||||
gvks, _, err := p.Typer.ObjectKinds(obj)
|
||||
if err != nil {
|
||||
// printers wrapped by us expect to find the type information present
|
||||
return fmt.Errorf("missing apiVersion or kind and cannot assign it; %v", err)
|
||||
}
|
||||
|
||||
for _, gvk := range gvks {
|
||||
if len(gvk.Kind) == 0 {
|
||||
continue
|
||||
}
|
||||
if len(gvk.Version) == 0 || gvk.Version == runtime.APIVersionInternal {
|
||||
continue
|
||||
}
|
||||
obj.GetObjectKind().SetGroupVersionKind(gvk)
|
||||
break
|
||||
}
|
||||
|
||||
return p.Delegate.PrintObj(obj, w)
|
||||
}
|
||||
|
||||
// ToPrinter returns a printer (not threadsafe!) that has been wrapped
|
||||
func (p *TypeSetterPrinter) ToPrinter(delegate ResourcePrinter) ResourcePrinter {
|
||||
if p == nil {
|
||||
return delegate
|
||||
}
|
||||
|
||||
p.Delegate = delegate
|
||||
return p
|
||||
}
|
||||
|
||||
// WrapToPrinter wraps the common ToPrinter method
|
||||
func (p *TypeSetterPrinter) WrapToPrinter(delegate ResourcePrinter, err error) (ResourcePrinter, error) {
|
||||
if err != nil {
|
||||
return delegate, err
|
||||
}
|
||||
if p == nil {
|
||||
return delegate, nil
|
||||
}
|
||||
|
||||
p.Delegate = delegate
|
||||
return p, nil
|
||||
}
|
Reference in New Issue
Block a user