mirror of https://github.com/status-im/consul.git
agent/structs: String format for Intention, used for logging
This commit is contained in:
parent
fb7bccc690
commit
6dc2db94ea
|
@ -921,7 +921,7 @@ func (s *HTTPServer) AgentConnectAuthorize(resp http.ResponseWriter, req *http.R
|
||||||
if !ok {
|
if !ok {
|
||||||
return &connectAuthorizeResp{
|
return &connectAuthorizeResp{
|
||||||
Authorized: false,
|
Authorized: false,
|
||||||
Reason: fmt.Sprintf("Client ID must be a valid SPIFFE service URI"),
|
Reason: "Client ID must be a valid SPIFFE service URI",
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,7 +951,7 @@ func (s *HTTPServer) AgentConnectAuthorize(resp http.ResponseWriter, req *http.R
|
||||||
if auth, ok := uriService.Authorize(ixn); ok {
|
if auth, ok := uriService.Authorize(ixn); ok {
|
||||||
return &connectAuthorizeResp{
|
return &connectAuthorizeResp{
|
||||||
Authorized: auth,
|
Authorized: auth,
|
||||||
Reason: fmt.Sprintf("Matched intention %s", ixn.ID),
|
Reason: fmt.Sprintf("Matched intention: %s", ixn.String()),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,15 @@ func (x *Intention) GetACLPrefix() (string, bool) {
|
||||||
return x.DestinationName, x.DestinationName != ""
|
return x.DestinationName, x.DestinationName != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns a human-friendly string for this intention.
|
||||||
|
func (x *Intention) String() string {
|
||||||
|
return fmt.Sprintf("%s %s/%s => %s/%s (ID: %s",
|
||||||
|
strings.ToUpper(string(x.Action)),
|
||||||
|
x.SourceNS, x.SourceName,
|
||||||
|
x.DestinationNS, x.DestinationName,
|
||||||
|
x.ID)
|
||||||
|
}
|
||||||
|
|
||||||
// IntentionAction is the action that the intention represents. This
|
// IntentionAction is the action that the intention represents. This
|
||||||
// can be "allow" or "deny" to whitelist or blacklist intentions.
|
// can be "allow" or "deny" to whitelist or blacklist intentions.
|
||||||
type IntentionAction string
|
type IntentionAction string
|
||||||
|
|
Loading…
Reference in New Issue