fixed bugs
This commit is contained in:
@@ -8,8 +8,9 @@ import (
|
||||
|
||||
instancemanager "git.acooldomain.co/server-manager/backend/instancemanager"
|
||||
"git.acooldomain.co/server-manager/backend/models"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/go-connections/nat"
|
||||
)
|
||||
|
||||
@@ -54,15 +55,15 @@ func stringifyMap(m map[string]any) map[string]string {
|
||||
return stringifiedMap
|
||||
}
|
||||
|
||||
func convertContainerPortsToPorts(ports []types.Port) []models.Port {
|
||||
func convertContainerPortsToPorts(ports []container.Port) []models.Port {
|
||||
containerPorts := make([]models.Port, len(ports))
|
||||
logger := log.Default()
|
||||
for i, port := range ports {
|
||||
var portProtocol models.PortProtocol
|
||||
switch port.Type {
|
||||
case "TCP":
|
||||
case "tcp":
|
||||
portProtocol = models.TCP
|
||||
case "UDP":
|
||||
case "udp":
|
||||
portProtocol = models.UDP
|
||||
default:
|
||||
logger.Println(fmt.Sprintf("Unkown Port Protocol %s assuming TCP", port.Type))
|
||||
@@ -90,10 +91,11 @@ func convertImageStringToModelsImage(image string) models.Image {
|
||||
}
|
||||
}
|
||||
|
||||
func convertImageInspectToInstanceImage(image types.ImageInspect) instancemanager.Image {
|
||||
func convertImageInspectToInstanceImage(image image.InspectResponse) instancemanager.Image {
|
||||
modelsImage := convertImageStringToModelsImage(image.RepoTags[0])
|
||||
|
||||
ports := convertImagePortsToPorts(image.Config.ExposedPorts)
|
||||
fmt.Printf("image: %#v\nconfig: %#v\nports: %#v\n", image, image.Config, ports)
|
||||
|
||||
return instancemanager.Image{
|
||||
Registry: modelsImage.Registry,
|
||||
@@ -112,7 +114,7 @@ func convertContainerLabelsToStruct(labels map[string]string) (*ContainerLabels,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(rawLabels, &labels)
|
||||
err = json.Unmarshal(rawLabels, &containerLabels)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -129,7 +131,7 @@ func convertVolumeLabelsToStruct(labels map[string]string) (*VolumeLabels, error
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(rawLabels, &labels)
|
||||
err = json.Unmarshal(rawLabels, &volumeLabels)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -146,7 +148,7 @@ func convertImageLabelsToStruct(labels map[string]string) (*ImageLabels, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(rawLabels, &labels)
|
||||
err = json.Unmarshal(rawLabels, &imageLabels)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -161,9 +163,9 @@ func convertImagePortsToPorts(rawPorts nat.PortSet) []instancemanager.Port {
|
||||
portNumber := imagePort.Int()
|
||||
var protocol models.PortProtocol
|
||||
switch imagePort.Proto() {
|
||||
case "TCP":
|
||||
case "tcp":
|
||||
protocol = models.TCP
|
||||
case "UDP":
|
||||
case "udp":
|
||||
protocol = models.UDP
|
||||
default:
|
||||
log.Default().Println(fmt.Sprintf("Unknown port protocol %s using TCP", imagePort.Proto()))
|
||||
|
||||
Reference in New Issue
Block a user