Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ type Config struct {
Override map[string]string `hcl:"override,optional"`

// Translate is a map that translates one import source into another.
// For example, "gopkg.in/(.*)" => "github.com/\1" would translate
// If the name begins and ends with `/` (forward slash) then it will
// be treated like a regular expression. The destination can use
// \1, \2, ... to reference capture groups. Note that these may need
// to be escaped.
// For example, "/gopkg.in/(.*)/" = "github.com/\\1" would translate
// gopkg into github (incorrectly, but the example would work).
Translate map[string]string `hcl:"translate,optional"`
}
Expand Down
16 changes: 16 additions & 0 deletions config/testdata/complex.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
allow = ["one",
"two", "three/four"
]

deny = [
"five",
]

override = {
"six" = "seven"
}

translate = {
"eight" = "nine"
"/gopkg.in/(.*)/" = "github.com/\\1"
}
17 changes: 17 additions & 0 deletions config/testdata/complex.hcl.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(*config.Config)({
Allow: ([]string) (len=3 cap=3) {
(string) (len=3) "one",
(string) (len=3) "two",
(string) (len=10) "three/four"
},
Deny: ([]string) (len=1 cap=1) {
(string) (len=4) "five"
},
Override: (map[string]string) (len=1) {
(string) (len=3) "six": (string) (len=5) "seven"
},
Translate: (map[string]string) (len=2) {
(string) (len=15) "/gopkg.in/(.*)/": (string) (len=13) "github.com/\\1",
(string) (len=5) "eight": (string) (len=4) "nine"
}
})