isSameServer compares the calling ProtocolIncus object with the provided server object to check if they are the same server. It verifies the equality based on their connection information (Protocol, Certificate, Project, and Target).
(server Server)
| 109 | // isSameServer compares the calling ProtocolIncus object with the provided server object to check if they are the same server. |
| 110 | // It verifies the equality based on their connection information (Protocol, Certificate, Project, and Target). |
| 111 | func (r *ProtocolIncus) isSameServer(server Server) bool { |
| 112 | // Short path checking if the two structs are identical. |
| 113 | if r == server { |
| 114 | return true |
| 115 | } |
| 116 | |
| 117 | // Short path if either of the structs are nil. |
| 118 | if r == nil || server == nil { |
| 119 | return false |
| 120 | } |
| 121 | |
| 122 | // When dealing with uninitialized servers, we can't safely compare. |
| 123 | if r.server == nil { |
| 124 | return false |
| 125 | } |
| 126 | |
| 127 | // Get the connection info from both servers. |
| 128 | srcInfo, err := r.GetConnectionInfo() |
| 129 | if err != nil { |
| 130 | return false |
| 131 | } |
| 132 | |
| 133 | dstInfo, err := server.GetConnectionInfo() |
| 134 | if err != nil { |
| 135 | return false |
| 136 | } |
| 137 | |
| 138 | // Check whether we're dealing with the same server. |
| 139 | return srcInfo.Protocol == dstInfo.Protocol && srcInfo.Certificate == dstInfo.Certificate && |
| 140 | srcInfo.Project == dstInfo.Project && srcInfo.Target == dstInfo.Target |
| 141 | } |
| 142 | |
| 143 | // GetHTTPClient returns the http client used for the connection. This can be used to set custom http options. |
| 144 | func (r *ProtocolIncus) GetHTTPClient() (*http.Client, error) { |
no test coverage detected