github.com/umeshredd/helm@v3.0.0-alpha.1+incompatible/pkg/kube/printer.go (about) 1 /* 2 Copyright The Helm Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package kube 18 19 import ( 20 "io" 21 "time" 22 23 v1 "k8s.io/api/core/v1" 24 "k8s.io/cli-runtime/pkg/resource" 25 ) 26 27 // PrintingKubeClient implements KubeClient, but simply prints the reader to 28 // the given output. 29 type PrintingKubeClient struct { 30 Out io.Writer 31 } 32 33 // Create prints the values of what would be created with a real KubeClient. 34 func (p *PrintingKubeClient) Create(r io.Reader) error { 35 _, err := io.Copy(p.Out, r) 36 return err 37 } 38 39 func (p *PrintingKubeClient) Wait(r io.Reader, _ time.Duration) error { 40 _, err := io.Copy(p.Out, r) 41 return err 42 } 43 44 // Get prints the values of what would be created with a real KubeClient. 45 func (p *PrintingKubeClient) Get(r io.Reader) (string, error) { 46 _, err := io.Copy(p.Out, r) 47 return "", err 48 } 49 50 // Delete implements KubeClient delete. 51 // 52 // It only prints out the content to be deleted. 53 func (p *PrintingKubeClient) Delete(r io.Reader) error { 54 _, err := io.Copy(p.Out, r) 55 return err 56 } 57 58 // WatchUntilReady implements KubeClient WatchUntilReady. 59 func (p *PrintingKubeClient) WatchUntilReady(r io.Reader, _ time.Duration) error { 60 _, err := io.Copy(p.Out, r) 61 return err 62 } 63 64 // Update implements KubeClient Update. 65 func (p *PrintingKubeClient) Update(_, modifiedReader io.Reader, _, _ bool) error { 66 _, err := io.Copy(p.Out, modifiedReader) 67 return err 68 } 69 70 // Build implements KubeClient Build. 71 func (p *PrintingKubeClient) Build(_ io.Reader) (Result, error) { 72 return []*resource.Info{}, nil 73 } 74 75 func (p *PrintingKubeClient) BuildUnstructured(_ io.Reader) (Result, error) { 76 return p.Build(nil) 77 } 78 79 // WaitAndGetCompletedPodPhase implements KubeClient WaitAndGetCompletedPodPhase. 80 func (p *PrintingKubeClient) WaitAndGetCompletedPodPhase(_ string, _ time.Duration) (v1.PodPhase, error) { 81 return v1.PodSucceeded, nil 82 }