mirror of https://github.com/hashicorp/consul
29 lines
611 B
Go
29 lines
611 B
Go
package connect
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
)
|
|
|
|
// SpiffeIDService is the structure to represent the SPIFFE ID for a service.
|
|
type SpiffeIDService struct {
|
|
Host string
|
|
Namespace string
|
|
Datacenter string
|
|
Service string
|
|
}
|
|
|
|
// URI returns the *url.URL for this SPIFFE ID.
|
|
func (id *SpiffeIDService) URI() *url.URL {
|
|
var result url.URL
|
|
result.Scheme = "spiffe"
|
|
result.Host = id.Host
|
|
result.Path = fmt.Sprintf("/ns/%s/dc/%s/svc/%s",
|
|
id.Namespace, id.Datacenter, id.Service)
|
|
return &result
|
|
}
|
|
|
|
func (id *SpiffeIDService) CommonName() string {
|
|
return ServiceCN(id.Service, id.Namespace, id.Host)
|
|
}
|