Documentation ¶
Index ¶
- func FormatPath(format string, args ...interface{}) (string, error)
- func JoinPathSegments(segments ...string) (string, error)
- func RequireFormatPath(format string, args ...interface{}) string
- func RequireJoinPathSegments(segments ...string) string
- func ValidatePath(path string) error
- func ValidatePathSegment(segment string) error
- type ID
- func FromPath(td TrustDomain, path string) (ID, error)
- func FromPathf(td TrustDomain, format string, args ...interface{}) (ID, error)
- func FromSegments(td TrustDomain, segments ...string) (ID, error)
- func FromString(id string) (ID, error)
- func FromStringf(format string, args ...interface{}) (ID, error)
- func FromURI(uri *url.URL) (ID, error)
- func RequireFromPath(td TrustDomain, path string) ID
- func RequireFromPathf(td TrustDomain, format string, args ...interface{}) ID
- func RequireFromSegments(td TrustDomain, segments ...string) ID
- func RequireFromString(s string) ID
- func RequireFromStringf(format string, args ...interface{}) ID
- func RequireFromURI(uri *url.URL) ID
- func (id ID) AppendPath(path string) (ID, error)
- func (id ID) AppendPathf(format string, args ...interface{}) (ID, error)
- func (id ID) AppendSegments(segments ...string) (ID, error)
- func (id ID) IsZero() bool
- func (id ID) MarshalText() ([]byte, error)
- func (id ID) MemberOf(td TrustDomain) bool
- func (id ID) Path() string
- func (id ID) ReplacePath(path string) (ID, error)
- func (id ID) ReplacePathf(format string, args ...interface{}) (ID, error)
- func (id ID) ReplaceSegments(segments ...string) (ID, error)
- func (id ID) String() string
- func (id ID) TrustDomain() TrustDomain
- func (id ID) URL() *url.URL
- func (id *ID) UnmarshalText(text []byte) error
- type Matcher
- type TrustDomain
- func (td TrustDomain) Compare(other TrustDomain) int
- func (td TrustDomain) ID() ID
- func (td TrustDomain) IDString() string
- func (td TrustDomain) IsZero() bool
- func (td TrustDomain) MarshalText() ([]byte, error)
- func (td TrustDomain) Name() string
- func (td TrustDomain) String() string
- func (td *TrustDomain) UnmarshalText(text []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatPath ¶
FormatPath builds a path by formatting the given formatting string with the given args (i.e. fmt.Sprintf). The resulting path must be valid or an error is returned.
func JoinPathSegments ¶
JoinPathSegments joins one or more path segments into a slash separated path. Segments cannot contain slashes. The resulting path must be valid or an error is returned. If no segments are provided, an empty string is returned.
func RequireFormatPath ¶
RequireFormatPath builds a path by formatting the given formatting string with the given args (i.e. fmt.Sprintf). The resulting path must be valid or the function panics. It should only be used when the input is statically verifiable.
func RequireJoinPathSegments ¶
RequireJoinPathSegments joins one or more path segments into a slash separated path. Segments cannot contain slashes. The resulting path must be valid or the function panics. It should only be used when the input is statically verifiable.
func ValidatePath ¶
ValidatePath validates that a path string is a conformant path for a SPIFFE ID. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
func ValidatePathSegment ¶ added in v2.1.3
ValidatePathSegment validates that a string is a conformant segment for inclusion in the path for a SPIFFE ID. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
Types ¶
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID is a SPIFFE ID
func FromPath ¶
func FromPath(td TrustDomain, path string) (ID, error)
FromPath returns a new SPIFFE ID in the given trust domain and with the given path. The supplied path must be a valid absolute path according to the SPIFFE specification. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
func FromPathf ¶
func FromPathf(td TrustDomain, format string, args ...interface{}) (ID, error)
FromPathf returns a new SPIFFE ID from the formatted path in the given trust domain. The formatted path must be a valid absolute path according to the SPIFFE specification. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
func FromSegments ¶
func FromSegments(td TrustDomain, segments ...string) (ID, error)
FromSegments returns a new SPIFFE ID in the given trust domain with joined path segments. The path segments must be valid according to the SPIFFE specification and must not contain path separators. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
func FromString ¶
FromString parses a SPIFFE ID from a string.
func FromStringf ¶
FromStringf parses a SPIFFE ID from a formatted string.
func RequireFromPath ¶
func RequireFromPath(td TrustDomain, path string) ID
RequireFromPath is similar to FromPath except that instead of returning an error on malformed input, it panics. It should only be used when the input is statically verifiable.
func RequireFromPathf ¶
func RequireFromPathf(td TrustDomain, format string, args ...interface{}) ID
RequireFromPathf is similar to FromPathf except that instead of returning an error on malformed input, it panics. It should only be used when the input is statically verifiable.
func RequireFromSegments ¶
func RequireFromSegments(td TrustDomain, segments ...string) ID
RequireFromSegments is similar to FromSegments except that instead of returning an error on malformed input, it panics. It should only be used when the input is statically verifiable.
func RequireFromString ¶
RequireFromString is similar to FromString except that instead of returning an error on malformed input, it panics. It should only be used when the input is statically verifiable.
func RequireFromStringf ¶
RequireFromStringf is similar to FromStringf except that instead of returning an error on malformed input, it panics. It should only be used when the input is statically verifiable.
func RequireFromURI ¶
RequireFromURI is similar to FromURI except that instead of returning an error on malformed input, it panics. It should only be used when the input is statically verifiable.
func (ID) AppendPath ¶
AppendPath returns an ID with the appended path. It will fail if called on a zero value. The path to append must be a valid absolute path according to the SPIFFE specification. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
func (ID) AppendPathf ¶
AppendPathf returns an ID with the appended formatted path. It will fail if called on a zero value. The formatted path must be a valid absolute path according to the SPIFFE specification. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
func (ID) AppendSegments ¶
AppendSegments returns an ID with the appended joined path segments. It will fail if called on a zero value. The path segments must be valid according to the SPIFFE specification and must not contain path separators. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
func (ID) MarshalText ¶
MarshalText returns a text representation of the ID. If the ID is the zero value, nil is returned.
func (ID) MemberOf ¶
func (id ID) MemberOf(td TrustDomain) bool
MemberOf returns true if the SPIFFE ID is a member of the given trust domain.
func (ID) ReplacePath ¶
Replace path returns an ID with the given path in the same trust domain. It will fail if called on a zero value. The given path must be a valid absolute path according to the SPIFFE specification. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
func (ID) ReplacePathf ¶
ReplacePathf returns an ID with the formatted path in the same trust domain. It will fail if called on a zero value. The formatted path must be a valid absolute path according to the SPIFFE specification. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
func (ID) ReplaceSegments ¶
ReplaceSegments returns an ID with the joined path segments in the same trust domain. It will fail if called on a zero value. The path segments must be valid according to the SPIFFE specification and must not contain path separators. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
func (ID) String ¶
String returns the string representation of the SPIFFE ID, e.g., "spiffe://example.org/foo/bar".
func (ID) TrustDomain ¶
func (id ID) TrustDomain() TrustDomain
TrustDomain returns the trust domain of the SPIFFE ID.
func (*ID) UnmarshalText ¶
UnmarshalText decodes a text representation of the ID. If the text is empty, the ID is set to the zero value.
type Matcher ¶
Matcher is used to match a SPIFFE ID.
func MatchMemberOf ¶
func MatchMemberOf(expected TrustDomain) Matcher
MatchMemberOf matches any SPIFFE ID in the given trust domain.
func MatchOneOf ¶
MatchOneOf matches any SPIFFE ID in the given list of IDs.
type TrustDomain ¶
type TrustDomain struct {
// contains filtered or unexported fields
}
TrustDomain represents the trust domain portion of a SPIFFE ID (e.g. example.org).
func RequireTrustDomainFromString ¶
func RequireTrustDomainFromString(s string) TrustDomain
RequireTrustDomainFromString is similar to TrustDomainFromString except that instead of returning an error on malformed input, it panics. It should only be used when the input is statically verifiable.
func RequireTrustDomainFromURI ¶
func RequireTrustDomainFromURI(uri *url.URL) TrustDomain
RequireTrustDomainFromURI is similar to TrustDomainFromURI except that instead of returning an error on malformed input, it panics. It should only be used when the input is statically verifiable.
func TrustDomainFromString ¶
func TrustDomainFromString(idOrName string) (TrustDomain, error)
TrustDomainFromString returns a new TrustDomain from a string. The string can either be a trust domain name (e.g. example.org), or a valid SPIFFE ID URI (e.g. spiffe://example.org), otherwise an error is returned. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#21-trust-domain.
func TrustDomainFromURI ¶
func TrustDomainFromURI(uri *url.URL) (TrustDomain, error)
TrustDomainFromURI returns a new TrustDomain from a URI. The URI must be a valid SPIFFE ID (see FromURI) or an error is returned. The trust domain is extracted from the host field.
func (TrustDomain) Compare ¶
func (td TrustDomain) Compare(other TrustDomain) int
Compare returns an integer comparing the trust domain to another lexicographically. The result will be 0 if td==other, -1 if td < other, and +1 if td > other.
func (TrustDomain) IDString ¶
func (td TrustDomain) IDString() string
IDString returns a string representation of the the SPIFFE ID of the trust domain, e.g. "spiffe://example.org".
func (TrustDomain) IsZero ¶
func (td TrustDomain) IsZero() bool
IsZero returns true if the trust domain is the zero value.
func (TrustDomain) MarshalText ¶
func (td TrustDomain) MarshalText() ([]byte, error)
MarshalText returns a text representation of the trust domain. If the trust domain is the zero value, nil is returned.
func (TrustDomain) Name ¶ added in v2.1.6
func (td TrustDomain) Name() string
Name returns the trust domain name as a string, e.g. example.org.
func (TrustDomain) String ¶
func (td TrustDomain) String() string
String returns the trust domain name as a string, e.g. example.org.
func (*TrustDomain) UnmarshalText ¶
func (td *TrustDomain) UnmarshalText(text []byte) error
UnmarshalText decodes a text representation of the trust domain. If the text is empty, the trust domain is set to the zero value.