types/key: use tlpub: in error message (#13707)

Fixes tailscale/corp#19442

Signed-off-by: Erisa A <erisa@tailscale.com>
This commit is contained in:
Erisa A 2024-10-07 17:28:45 +01:00 committed by GitHub
parent cb10eddc26
commit c588c36233
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -1448,7 +1448,7 @@ func TestParseNLArgs(t *testing.T) {
name: "disablements not allowed", name: "disablements not allowed",
input: []string{"disablement:" + strings.Repeat("02", 32)}, input: []string{"disablement:" + strings.Repeat("02", 32)},
parseKeys: true, parseKeys: true,
wantErr: fmt.Errorf("parsing key 1: key hex string doesn't have expected type prefix nlpub:"), wantErr: fmt.Errorf("parsing key 1: key hex string doesn't have expected type prefix tlpub:"),
}, },
{ {
name: "keys not allowed", name: "keys not allowed",

View File

@ -131,10 +131,10 @@ func NLPublicFromEd25519Unsafe(public ed25519.PublicKey) NLPublic {
// is able to decode both the CLI form (tlpub:<hex>) & the // is able to decode both the CLI form (tlpub:<hex>) & the
// regular form (nlpub:<hex>). // regular form (nlpub:<hex>).
func (k *NLPublic) UnmarshalText(b []byte) error { func (k *NLPublic) UnmarshalText(b []byte) error {
if mem.HasPrefix(mem.B(b), mem.S(nlPublicHexPrefixCLI)) { if mem.HasPrefix(mem.B(b), mem.S(nlPublicHexPrefix)) {
return parseHex(k.k[:], mem.B(b), mem.S(nlPublicHexPrefixCLI))
}
return parseHex(k.k[:], mem.B(b), mem.S(nlPublicHexPrefix)) return parseHex(k.k[:], mem.B(b), mem.S(nlPublicHexPrefix))
}
return parseHex(k.k[:], mem.B(b), mem.S(nlPublicHexPrefixCLI))
} }
// AppendText implements encoding.TextAppender. // AppendText implements encoding.TextAppender.