feat(dns): parse chain alias action maps
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
f0a6c12443
commit
08e0d201e1
2 changed files with 29 additions and 0 deletions
13
service.go
13
service.go
|
|
@ -475,6 +475,19 @@ func parseActionAliasList(value any) ([]string, error) {
|
|||
if name != "" {
|
||||
return []string{name}, nil
|
||||
}
|
||||
if len(aliases) > 0 {
|
||||
parsed := make([]string, 0, len(aliases))
|
||||
for _, rawAlias := range aliases {
|
||||
alias, err := parseActionAliasValue(rawAlias)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if alias != "" {
|
||||
parsed = append(parsed, alias)
|
||||
}
|
||||
}
|
||||
return normalizeAliasList(parsed), nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("blockchain.chain.aliases action returned unsupported result type %T", value)
|
||||
|
|
|
|||
|
|
@ -3399,6 +3399,22 @@ func TestParseActionAliasListAcceptsStringMapSlice(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestParseActionAliasListAcceptsAliasMap(t *testing.T) {
|
||||
aliases, err := parseActionAliasList(map[string]any{
|
||||
"gateway": "gateway.charon.lthn",
|
||||
"node": "node.charon.lthn",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected alias map parse error: %v", err)
|
||||
}
|
||||
if len(aliases) != 2 {
|
||||
t.Fatalf("expected two aliases, got %#v", aliases)
|
||||
}
|
||||
if aliases[0] != "gateway.charon.lthn" || aliases[1] != "node.charon.lthn" {
|
||||
t.Fatalf("unexpected alias map parsing result: %#v", aliases)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeNameAndNormalizeIPArePublicWrappers(t *testing.T) {
|
||||
normalizedName := NormalizeName(" Gateway.Charon.lthn. ")
|
||||
if normalizedName != "gateway.charon.lthn" {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue