github.com/vmware/govmomi@v0.51.0/vim25/mo/helpers.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package mo 6 7 import ( 8 "fmt" 9 "io" 10 "text/tabwriter" 11 "time" 12 ) 13 14 // Write implements the cli package's Write(io.Writer) error interface for 15 // emitting objects to the command line. 16 func (l HttpNfcLease) Write(w io.Writer) error { 17 18 tw := tabwriter.NewWriter(w, 2, 0, 2, ' ', 0) 19 20 fmt.Fprintf(tw, "Lease:\t%s\n", l.Reference().String()) 21 fmt.Fprintf(tw, "InitializeProgress:\t%d\n", l.InitializeProgress) 22 fmt.Fprintf(tw, "TransferProgress:\t%d\n", l.TransferProgress) 23 fmt.Fprintf(tw, "Mode:\t%s\n", l.Mode) 24 fmt.Fprintf(tw, "State:\t%s\n", l.State) 25 fmt.Fprintf(tw, "Capabilities:\n") 26 fmt.Fprintf(tw, " CorsSupported:\t%v\n", l.Capabilities.CorsSupported) 27 fmt.Fprintf(tw, " PullModeSupported:\t%v\n", l.Capabilities.PullModeSupported) 28 29 if info := l.Info; info != nil { 30 fmt.Fprintf(tw, "Info:\n") 31 fmt.Fprintf(tw, " Entity:\t%s\n", info.Entity.String()) 32 33 timeout := time.Second * time.Duration(info.LeaseTimeout) 34 fmt.Fprintf(tw, " Timeout:\t%s\n", timeout) 35 36 fmt.Fprintf(tw, " TotalDiskCapacityInKB:\t%d\n", info.TotalDiskCapacityInKB) 37 38 fmt.Fprintf(tw, " URLs:\n") 39 for i := range info.DeviceUrl { 40 du := info.DeviceUrl[i] 41 fmt.Fprintf(tw, " Datastore:\t%s\n", du.DatastoreKey) 42 fmt.Fprintf(tw, " DeviceKey:\t%s\n", du.Key) 43 isDisk := false 44 if du.Disk != nil { 45 isDisk = *du.Disk 46 } 47 fmt.Fprintf(tw, " IsDisk:\t%v\n", isDisk) 48 fmt.Fprintf(tw, " SSLThumbprint:\t%s\n", du.SslThumbprint) 49 fmt.Fprintf(tw, " Target:\t%s\n", du.TargetId) 50 fmt.Fprintf(tw, " URL:\t%s\n", du.Url) 51 } 52 } 53 54 if err := l.Error; err != nil { 55 fmt.Fprintf(tw, "Error:\t%s\n", err.LocalizedMessage) 56 } 57 58 return tw.Flush() 59 }