github.com/hashicorp/go-getter/v2@v2.2.2/request.go (about) 1 package getter 2 3 import ( 4 "io" 5 "net/url" 6 "os" 7 ) 8 9 type Request struct { 10 // Src is the source URL to get. 11 // 12 // Dst is the path to save the downloaded thing as. If Dir is set to 13 // true, then this should be a directory. If the directory doesn't exist, 14 // it will be created for you. 15 // 16 // Pwd is the working directory for detection. If this isn't set, some 17 // detection may fail. Client will not default pwd to the current 18 // working directory for security reasons. 19 Src string 20 Dst string 21 Pwd string 22 23 // Forced is the forced getter detected in the Src string during the 24 // Getter detection. Forcing a getter means that go-getter will try 25 // to download the artifact only with the Getter that is being forced. 26 // 27 // For example: 28 // 29 // Request.Src Forced 30 // git::ssh://git@git.example.com:2222/foo/bar.git git 31 // 32 // This field is used by the Getters to validate when they are forced to download 33 // the artifact. 34 // If both Request.Src and Forced contains a forced getter, the one in the Request.Src will 35 // be considered and will override the value of this field. 36 Forced string 37 38 // Umask is used to mask file permissions when storing local files or 39 // decompressing an archive 40 Umask os.FileMode 41 42 // GetMode is the method of download the client will use. See Mode for 43 // documentation. 44 GetMode Mode 45 46 // Copy, in local file mode if set to true, will copy data instead of using 47 // a symlink. If false, attempts to symlink to speed up the operation and 48 // to lower the disk space usage. If the symlink fails, may attempt to copy 49 // on windows. 50 Copy bool 51 52 // Inplace, in local file mode if set to true, do nothing and the returned 53 // operation will simply contain the source file path. Inplace has precedence 54 // over Copy. 55 Inplace bool 56 57 // ProgressListener allows to track file downloads. 58 // By default a no op progress listener is used. 59 ProgressListener ProgressTracker 60 61 // Disable symlinks is used to prevent copying or writing files through symlinks. 62 // When set to true any copying or writing through symlinks will result in a ErrSymlinkCopy error. 63 DisableSymlinks bool 64 65 u *url.URL 66 subDir, realDst string 67 } 68 69 func (req *Request) URL() *url.URL { 70 return req.u 71 } 72 73 // umask returns the effective umask for the Request, defaulting to the process 74 // umask 75 func (req *Request) umask() os.FileMode { 76 if req == nil { 77 return 0 78 } 79 return req.Umask 80 } 81 82 func (req *Request) CopyReader(dst string, src io.Reader, fmode os.FileMode, fileSizeLimit int64) error { 83 return copyReader(dst, src, fmode, req.Umask, fileSizeLimit) 84 } 85 86 // Mode returns file Mode umasked by the Request umask 87 func (req *Request) Mode(m os.FileMode) os.FileMode { 88 return mode(m, req.umask()) 89 } 90 91 // mode returns the file mode masked by the umask 92 func mode(mode, umask os.FileMode) os.FileMode { 93 return mode & ^umask 94 }