New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update go-getter client options #111
Changes from all commits
da23d8b
ee2fe87
ffa44ec
faee09d
900cdcf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
"path/filepath" | ||
"runtime" | ||
"strings" | ||
"time" | ||
|
||
gcs "github.com/hashicorp/go-getter/gcs/v2" | ||
s3 "github.com/hashicorp/go-getter/s3/v2" | ||
|
@@ -55,13 +56,44 @@ type StepDownload struct { | |
Extension string | ||
} | ||
|
||
var defaultGetterClient = getter.Client{ | ||
Getters: getter.Getters, | ||
} | ||
// defaultGetterReadTimeout is the read timeout for downloading operations via go-getter. | ||
// The timeout must be long enough to accommodate large/slow downloads. | ||
const defaultGetterReadTimeout time.Duration = 30 * time.Minute | ||
|
||
func init() { | ||
defaultGetterClient.Getters = append(defaultGetterClient.Getters, new(gcs.Getter)) | ||
defaultGetterClient.Getters = append(defaultGetterClient.Getters, new(s3.Getter)) | ||
var defaultGetterClient = getter.Client{ | ||
// Disable writing and reading through symlinks. | ||
DisableSymlinks: true, | ||
// The order of the Getters in the list may affect the result | ||
// depending if the Request.Src is detected as valid by multiple getters | ||
Getters: []getter.Getter{ | ||
&getter.GitGetter{ | ||
Timeout: defaultGetterReadTimeout, | ||
Detectors: []getter.Detector{ | ||
new(getter.GitHubDetector), | ||
new(getter.GitDetector), | ||
new(getter.BitBucketDetector), | ||
new(getter.GitLabDetector), | ||
}, | ||
}, | ||
&getter.HgGetter{ | ||
Timeout: defaultGetterReadTimeout, | ||
}, | ||
new(getter.SmbClientGetter), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 Should this getter have a timeout? I see this getter only exists in v2, and doesn't have that option currently. Just curious to your thoughts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - I think it should. It was not caught in the go-getter updates. I will follow up with a separate PR for that change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR opened for the SmbClientGetter hashicorp/go-getter#369 |
||
new(getter.SmbMountGetter), | ||
&getter.HttpGetter{ | ||
Netrc: true, | ||
XTerraformGetDisabled: true, | ||
HeadFirstTimeout: defaultGetterReadTimeout, | ||
ReadTimeout: defaultGetterReadTimeout, | ||
}, | ||
new(getter.FileGetter), | ||
&gcs.Getter{ | ||
Timeout: defaultGetterReadTimeout, | ||
}, | ||
&s3.Getter{ | ||
Timeout: defaultGetterReadTimeout, | ||
}, | ||
}, | ||
} | ||
|
||
func (s *StepDownload) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!