diff --git a/dist/go-compose-exporter_darwin_amd64 b/dist/go-compose-exporter_darwin_amd64 index 94eb3df..10e6d02 100755 Binary files a/dist/go-compose-exporter_darwin_amd64 and b/dist/go-compose-exporter_darwin_amd64 differ diff --git a/dist/go-compose-exporter_darwin_arm64 b/dist/go-compose-exporter_darwin_arm64 index fead102..1eb66ac 100755 Binary files a/dist/go-compose-exporter_darwin_arm64 and b/dist/go-compose-exporter_darwin_arm64 differ diff --git a/dist/go-compose-exporter_linux_amd64 b/dist/go-compose-exporter_linux_amd64 index 8bfc627..a0c5745 100755 Binary files a/dist/go-compose-exporter_linux_amd64 and b/dist/go-compose-exporter_linux_amd64 differ diff --git a/dist/go-compose-exporter_linux_amd64_static b/dist/go-compose-exporter_linux_amd64_static index 2e9a199..b995423 100755 Binary files a/dist/go-compose-exporter_linux_amd64_static and b/dist/go-compose-exporter_linux_amd64_static differ diff --git a/dist/go-compose-exporter_linux_arm64 b/dist/go-compose-exporter_linux_arm64 index 22ec793..b78b9c6 100755 Binary files a/dist/go-compose-exporter_linux_arm64 and b/dist/go-compose-exporter_linux_arm64 differ diff --git a/dist/go-compose-exporter_linux_arm64_static b/dist/go-compose-exporter_linux_arm64_static index 49f0c18..61c99d4 100755 Binary files a/dist/go-compose-exporter_linux_arm64_static and b/dist/go-compose-exporter_linux_arm64_static differ diff --git a/dist/go-compose-exporter_windows_amd64 b/dist/go-compose-exporter_windows_amd64 index be04028..fdb33fe 100755 Binary files a/dist/go-compose-exporter_windows_amd64 and b/dist/go-compose-exporter_windows_amd64 differ diff --git a/main.go b/main.go index d4611e4..99a28cf 100644 --- a/main.go +++ b/main.go @@ -152,7 +152,7 @@ func inspectContainer(containerID string) ([]string, []string, []string, []strin } output := out.String() - parts := strings.Split(output, " ") + parts := strings.SplitN(output, " ", 5) envVars, networks, volumes, ports := []string{}, []string{}, []string{}, []string{} restartPolicy := "" @@ -176,11 +176,11 @@ func inspectContainer(containerID string) ([]string, []string, []string, []strin } func parseJSONStringArray(jsonStr string) []string { - jsonStr = strings.Trim(jsonStr, "[]") + jsonStr = strings.Trim(jsonStr, "[]\"") if jsonStr == "" { return []string{} } - return strings.Split(jsonStr, ",") + return strings.Split(jsonStr, "\",\"") } func parseJSONNetworkNames(jsonStr string) []string { @@ -201,7 +201,7 @@ func parseJSONVolumeMounts(jsonStr string) []string { for _, data := range volumeData { if strings.Contains(data, "\"Destination\"") { parts := strings.Split(data, "\"") - volumeMounts = append(volumeMounts, parts[3]) + volumeMounts = append(volumeMounts, parts[3]+":"+parts[7]) } } return volumeMounts @@ -212,8 +212,9 @@ func parseJSONPorts(jsonStr string) []string { portData := strings.Split(jsonStr, "},{") for _, data := range portData { if strings.Contains(data, "\"HostPort\"") { - parts := strings.Split(data, "\"") - ports = append(ports, parts[3]+":"+parts[7]) + hostPort := strings.Split(data, "\"")[3] + containerPort := strings.Split(data, "\"")[7] + ports = append(ports, hostPort+":"+containerPort) } } return ports