mirror of https://github.com/hashicorp/packer
Add http_content func to serve variables from HTTP @ preseed (#10801)
This imports hashicorp/packer-plugin-sdk#43 * code generate things * update docs * update guides * update examples We want to add a new guide.pull/10814/head
parent
ff01e6715a
commit
7732f7998c
@ -0,0 +1,24 @@
|
||||
package didyoumean
|
||||
|
||||
import (
|
||||
"github.com/agext/levenshtein"
|
||||
)
|
||||
|
||||
// NameSuggestion tries to find a name from the given slice of suggested names
|
||||
// that is close to the given name and returns it if found. If no suggestion is
|
||||
// close enough, returns the empty string.
|
||||
//
|
||||
// The suggestions are tried in order, so earlier suggestions take precedence if
|
||||
// the given string is similar to two or more suggestions.
|
||||
//
|
||||
// This function is intended to be used with a relatively-small number of
|
||||
// suggestions. It's not optimized for hundreds or thousands of them.
|
||||
func NameSuggestion(given string, suggestions []string) string {
|
||||
for _, suggestion := range suggestions {
|
||||
dist := levenshtein.Distance(given, suggestion, nil)
|
||||
if dist < 3 { // threshold determined experimentally
|
||||
return suggestion
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
14
vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/http_config.go
generated
vendored
14
vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/http_config.go
generated
vendored
81
vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/step_http_server.go
generated
vendored
81
vendor/github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps/step_http_server.go
generated
vendored
Loading…
Reference in new issue