This commit is contained in:
Colin 2024-08-29 11:42:52 -04:00
parent 628a734a37
commit 305f38a0ad
8 changed files with 7 additions and 4 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

11
main.go
View File

@ -199,9 +199,11 @@ func parseJSONVolumeMounts(jsonStr string) []string {
var volumeMounts []string var volumeMounts []string
volumeData := strings.Split(jsonStr, "},{") volumeData := strings.Split(jsonStr, "},{")
for _, data := range volumeData { for _, data := range volumeData {
if strings.Contains(data, "\"Destination\"") { if strings.Contains(data, "\"Source\"") && strings.Contains(data, "\"Destination\"") {
parts := strings.Split(data, "\"") parts := strings.Split(data, "\"")
volumeMounts = append(volumeMounts, parts[3]+":"+parts[7]) source := parts[3]
destination := parts[7]
volumeMounts = append(volumeMounts, source+":"+destination)
} }
} }
return volumeMounts return volumeMounts
@ -212,8 +214,9 @@ func parseJSONPorts(jsonStr string) []string {
portData := strings.Split(jsonStr, "},{") portData := strings.Split(jsonStr, "},{")
for _, data := range portData { for _, data := range portData {
if strings.Contains(data, "\"HostPort\"") { if strings.Contains(data, "\"HostPort\"") {
hostPort := strings.Split(data, "\"")[3] parts := strings.Split(data, "\"")
containerPort := strings.Split(data, "\"")[7] hostPort := parts[3]
containerPort := strings.Split(parts[1], "/")[0]
ports = append(ports, hostPort+":"+containerPort) ports = append(ports, hostPort+":"+containerPort)
} }
} }