github.com/azure-devops-engineer/helm@v3.0.0-alpha.2+incompatible/pkg/kube/fake/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 fake 18 19 import ( 20 "io" 21 "time" 22 23 v1 "k8s.io/api/core/v1" 24 "k8s.io/cli-runtime/pkg/resource" 25 26 "helm.sh/helm/pkg/kube" 27 ) 28 29 // PrintingKubeClient implements KubeClient, but simply prints the reader to 30 // the given output. 31 type PrintingKubeClient struct { 32 Out io.Writer 33 } 34 35 // Create prints the values of what would be created with a real KubeClient. 36 func (p *PrintingKubeClient) Create(r io.Reader) error { 37 _, err := io.Copy(p.Out, r) 38 return err 39 } 40 41 func (p *PrintingKubeClient) Wait(r io.Reader, _ time.Duration) error { 42 _, err := io.Copy(p.Out, r) 43 return err 44 } 45 46 // Get prints the values of what would be created with a real KubeClient. 47 func (p *PrintingKubeClient) Get(r io.Reader) (string, error) { 48 _, err := io.Copy(p.Out, r) 49 return "", err 50 } 51 52 // Delete implements KubeClient delete. 53 // 54 // It only prints out the content to be deleted. 55 func (p *PrintingKubeClient) Delete(r io.Reader) error { 56 _, err := io.Copy(p.Out, r) 57 return err 58 } 59 60 // WatchUntilReady implements KubeClient WatchUntilReady. 61 func (p *PrintingKubeClient) WatchUntilReady(r io.Reader, _ time.Duration) error { 62 _, err := io.Copy(p.Out, r) 63 return err 64 } 65 66 // Update implements KubeClient Update. 67 func (p *PrintingKubeClient) Update(_, modifiedReader io.Reader, _, _ bool) error { 68 _, err := io.Copy(p.Out, modifiedReader) 69 return err 70 } 71 72 // Build implements KubeClient Build. 73 func (p *PrintingKubeClient) Build(_ io.Reader) (kube.Result, error) { 74 return []*resource.Info{}, nil 75 } 76 77 func (p *PrintingKubeClient) BuildUnstructured(_ io.Reader) (kube.Result, error) { 78 return p.Build(nil) 79 } 80 81 // WaitAndGetCompletedPodPhase implements KubeClient WaitAndGetCompletedPodPhase. 82 func (p *PrintingKubeClient) WaitAndGetCompletedPodPhase(_ string, _ time.Duration) (v1.PodPhase, error) { 83 return v1.PodSucceeded, nil 84 }