github.com/vmware/govmomi@v0.51.0/ovf/importer/importable.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 importer 6 7 import ( 8 "fmt" 9 "path" 10 ) 11 12 type importable struct { 13 localPath string 14 remotePath string 15 } 16 17 func (i importable) Ext() string { 18 return path.Ext(i.localPath) 19 } 20 21 func (i importable) Base() string { 22 return path.Base(i.localPath) 23 } 24 25 func (i importable) BaseClean() string { 26 b := i.Base() 27 e := i.Ext() 28 return b[:len(b)-len(e)] 29 } 30 31 func (i importable) RemoteSrcVMDK() string { 32 file := fmt.Sprintf("%s-src.vmdk", i.BaseClean()) 33 return i.toRemotePath(file) 34 } 35 36 func (i importable) RemoteDstVMDK() string { 37 file := fmt.Sprintf("%s.vmdk", i.BaseClean()) 38 return i.toRemotePath(file) 39 } 40 41 func (i importable) toRemotePath(p string) string { 42 if i.remotePath == "" { 43 return p 44 } 45 46 return path.Join(i.remotePath, p) 47 }