Struct KeyringReference

Namespace
Kuestenlogik.Bowire.Keyring
Assembly
Kuestenlogik.Bowire.Keyring.dll

A parsed {{keyring.service/account}} reference: a mandatory Service and an optional Account. A bare {{keyring.service}} leaves Account null, which each backend maps to "any account under this service".

public readonly struct KeyringReference : IEquatable<KeyringReference>
Implements
Inherited Members

Remarks

A plain reference is split on the first slash, so the account may contain slashes: github.com/deploy-bot is service github.com, account deploy-bot; vault/team/bot is service vault, account team/bot.

A reference that starts with a URL scheme (<scheme>://) names a URL service and is split on the last slash after the host, so the service keeps its path (#870): https://api.example.com/v1/deploy-bot is service https://api.example.com/v1, account deploy-bot; https://api.example.com/deploy-bot is service https://api.example.com, account deploy-bot; a host-only URL (with or without a trailing slash) is a service without an account.

%2F (any case) is an escaped slash in either part and is decoded after the split, so any edge case can be written — e.g. an account with a slash under a URL service: https://api.example.com/v1/team%2Fbot. %25 decodes to % so a literal %2F is written %252F. No other escape is decoded: the reference is not a URL to percent-decode, only these two are needed to write every split.

Constructors

KeyringReference(string, string?)

A parsed {{keyring.service/account}} reference: a mandatory Service and an optional Account. A bare {{keyring.service}} leaves Account null, which each backend maps to "any account under this service".

public KeyringReference(string Service, string? Account)

Parameters

Service string
Account string

Remarks

A plain reference is split on the first slash, so the account may contain slashes: github.com/deploy-bot is service github.com, account deploy-bot; vault/team/bot is service vault, account team/bot.

A reference that starts with a URL scheme (<scheme>://) names a URL service and is split on the last slash after the host, so the service keeps its path (#870): https://api.example.com/v1/deploy-bot is service https://api.example.com/v1, account deploy-bot; https://api.example.com/deploy-bot is service https://api.example.com, account deploy-bot; a host-only URL (with or without a trailing slash) is a service without an account.

%2F (any case) is an escaped slash in either part and is decoded after the split, so any edge case can be written — e.g. an account with a slash under a URL service: https://api.example.com/v1/team%2Fbot. %25 decodes to % so a literal %2F is written %252F. No other escape is decoded: the reference is not a URL to percent-decode, only these two are needed to write every split.

Properties

Account

public string? Account { get; init; }

Property Value

string

Service

public string Service { get; init; }

Property Value

string

Methods

Deconstruct(out string, out string?)

public void Deconstruct(out string Service, out string? Account)

Parameters

Service string
Account string

Equals(KeyringReference)

public bool Equals(KeyringReference other)

Parameters

other KeyringReference

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

TryParse(string, out KeyringReference)

Parse the portion of a placeholder key that follows the keyring. prefix. Returns false for an empty or whitespace-only reference, a missing service, or a URL without a host, so the caller leaves the placeholder intact instead of issuing a meaningless lookup.

public static bool TryParse(string reference, out KeyringReference parsed)

Parameters

reference string
parsed KeyringReference

Returns

bool

Operators

operator ==(KeyringReference, KeyringReference)

public static bool operator ==(KeyringReference left, KeyringReference right)

Parameters

left KeyringReference
right KeyringReference

Returns

bool

operator !=(KeyringReference, KeyringReference)

public static bool operator !=(KeyringReference left, KeyringReference right)

Parameters

left KeyringReference
right KeyringReference

Returns

bool