mirror of
https://github.com/docker/compose.git
synced 2025-07-23 13:45:00 +02:00
Support windows npipe, set content type & corrrect URL /usage. Also fixed socket name for desktop mac
Signed-off-by: guillaume.tardif <guillaume.tardif@gmail.com>
This commit is contained in:
parent
369eb3220a
commit
c380604a9e
@ -7,6 +7,9 @@ from docker.transport import UnixHTTPAdapter
|
|||||||
|
|
||||||
from compose.const import IS_WINDOWS_PLATFORM
|
from compose.const import IS_WINDOWS_PLATFORM
|
||||||
|
|
||||||
|
if IS_WINDOWS_PLATFORM:
|
||||||
|
from docker.transport import NpipeHTTPAdapter
|
||||||
|
|
||||||
|
|
||||||
class Status(Enum):
|
class Status(Enum):
|
||||||
SUCCESS = "success"
|
SUCCESS = "success"
|
||||||
@ -19,9 +22,9 @@ class MetricsSource:
|
|||||||
|
|
||||||
|
|
||||||
if IS_WINDOWS_PLATFORM:
|
if IS_WINDOWS_PLATFORM:
|
||||||
METRICS_SOCKET_FILE = 'http+unix://\\\\.\\pipe\\docker_cli'
|
METRICS_SOCKET_FILE = 'npipe://\\\\.\\pipe\\docker_cli'
|
||||||
else:
|
else:
|
||||||
METRICS_SOCKET_FILE = 'http+unix:///var/run/metrics-docker-cli.sock'
|
METRICS_SOCKET_FILE = 'http+unix:///var/run/docker-cli.sock'
|
||||||
|
|
||||||
|
|
||||||
class MetricsCommand(requests.Session):
|
class MetricsCommand(requests.Session):
|
||||||
@ -38,11 +41,17 @@ class MetricsCommand(requests.Session):
|
|||||||
self.source = source
|
self.source = source
|
||||||
self.status = status.value
|
self.status = status.value
|
||||||
self.uri = uri or os.environ.get("METRICS_SOCKET_FILE", METRICS_SOCKET_FILE)
|
self.uri = uri or os.environ.get("METRICS_SOCKET_FILE", METRICS_SOCKET_FILE)
|
||||||
self.mount("http+unix://", UnixHTTPAdapter(self.uri))
|
if IS_WINDOWS_PLATFORM:
|
||||||
|
self.mount("http+unix://", NpipeHTTPAdapter(self.uri))
|
||||||
|
else:
|
||||||
|
self.mount("http+unix://", UnixHTTPAdapter(self.uri))
|
||||||
|
|
||||||
def send_metrics(self):
|
def send_metrics(self):
|
||||||
try:
|
try:
|
||||||
return self.post("http+unix://localhost/", json=self.to_map(), timeout=.05)
|
return self.post("http+unix://localhost/usage",
|
||||||
|
json=self.to_map(),
|
||||||
|
timeout=.05,
|
||||||
|
headers={'Content-Type': 'application/json'})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return e
|
return e
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user