This commit is contained in:
sianao 2025-03-25 18:28:06 +08:00
parent 80e147ef1e
commit d1c5fb1162
10 changed files with 334 additions and 1 deletions

2
.gitignore vendored
View File

@ -13,7 +13,7 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
floares
# Dependency directories (remove the comment below to include it)
# vendor/

1
lib/http/images/list.go Normal file
View File

@ -0,0 +1 @@
package images

20
lib/http/network/list.go Normal file
View File

@ -0,0 +1,20 @@
package network
import (
"encoding/json"
"floares/lib/model"
"log"
"net/http"
)
func ListJsons() []model.NetWorkJson {
req, _ := http.NewRequest("GET", "http://127.0.0.1:8888/networks", nil)
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Println("request for network list error:", err)
return []model.NetWorkJson{}
}
var result []model.NetWorkJson
err = json.NewDecoder(res.Body).Decode(&result)
return result
}

20
lib/http/system/basic.go Normal file
View File

@ -0,0 +1,20 @@
package system
import (
"encoding/json"
"floares/lib/model"
"log"
"net/http"
)
func Version() model.Version {
req, _ := http.NewRequest("GET", "http://127.0.0.1:8888/version", nil)
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Println("request for version list error:", err)
return model.Version{}
}
var result model.Version
err = json.NewDecoder(res.Body).Decode(&result)
return result
}

20
lib/http/system/info.go Normal file
View File

@ -0,0 +1,20 @@
package system
import (
"encoding/json"
"floares/lib/model"
"log"
"net/http"
)
func Info() model.Info {
req, _ := http.NewRequest("GET", "http://127.0.0.1:8888/info", nil)
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Println("request for info list error:", err)
return model.Info{}
}
var result model.Info
err = json.NewDecoder(res.Body).Decode(&result)
return result
}

20
lib/http/volume/list.go Normal file
View File

@ -0,0 +1,20 @@
package volume
import (
"encoding/json"
"floares/lib/model"
"log"
"net/http"
)
func ListJsons() model.VolumesJson {
req, _ := http.NewRequest("GET", "http://127.0.0.1:8888/volumes", nil)
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Println("request for volume list error:", err)
return model.VolumesJson{}
}
var result model.VolumesJson
err = json.NewDecoder(res.Body).Decode(&result)
return result
}

175
lib/model/basic.go Normal file
View File

@ -0,0 +1,175 @@
package model
import "time"
type Version struct {
Platform struct {
Name string `json:"Name"`
} `json:"Platform"`
Components []struct {
Name string `json:"Name"`
Version string `json:"Version"`
Details struct {
APIVersion string `json:"APIVersion,omitempty"`
Arch string `json:"Arch,omitempty"`
BuildTime time.Time `json:"BuildTime,omitempty"`
Experimental string `json:"Experimental,omitempty"`
GitCommit string `json:"GitCommit,omitempty"`
GoVersion string `json:"GoVersion,omitempty"`
KernelVersion string `json:"KernelVersion,omitempty"`
MinAPIVersion string `json:"MinAPIVersion,omitempty"`
Os string `json:"Os,omitempty"`
Package string `json:"Package,omitempty"`
} `json:"Details"`
} `json:"Components"`
Version string `json:"Version"`
ApiVersion string `json:"ApiVersion"`
MinAPIVersion string `json:"MinAPIVersion"`
GitCommit string `json:"GitCommit"`
GoVersion string `json:"GoVersion"`
Os string `json:"Os"`
Arch string `json:"Arch"`
KernelVersion string `json:"KernelVersion"`
BuildTime time.Time `json:"BuildTime"`
}
type Info struct {
ID string `json:"ID"`
Containers int `json:"Containers"`
ContainersRunning int `json:"ContainersRunning"`
ContainersPaused int `json:"ContainersPaused"`
ContainersStopped int `json:"ContainersStopped"`
Images int `json:"Images"`
Driver string `json:"Driver"`
DriverStatus [][]string `json:"DriverStatus"`
Plugins struct {
Volume []string `json:"Volume"`
Network []string `json:"Network"`
Authorization interface{} `json:"Authorization"`
Log []string `json:"Log"`
} `json:"Plugins"`
MemoryLimit bool `json:"MemoryLimit"`
SwapLimit bool `json:"SwapLimit"`
CpuCfsPeriod bool `json:"CpuCfsPeriod"`
CpuCfsQuota bool `json:"CpuCfsQuota"`
CPUShares bool `json:"CPUShares"`
CPUSet bool `json:"CPUSet"`
PidsLimit bool `json:"PidsLimit"`
IPv4Forwarding bool `json:"IPv4Forwarding"`
BridgeNfIptables bool `json:"BridgeNfIptables"`
BridgeNfIp6Tables bool `json:"BridgeNfIp6tables"`
Debug bool `json:"Debug"`
NFd int `json:"NFd"`
OomKillDisable bool `json:"OomKillDisable"`
NGoroutines int `json:"NGoroutines"`
SystemTime time.Time `json:"SystemTime"`
LoggingDriver string `json:"LoggingDriver"`
CgroupDriver string `json:"CgroupDriver"`
NEventsListener int `json:"NEventsListener"`
KernelVersion string `json:"KernelVersion"`
OperatingSystem string `json:"OperatingSystem"`
OSVersion string `json:"OSVersion"`
OSType string `json:"OSType"`
Architecture string `json:"Architecture"`
IndexServerAddress string `json:"IndexServerAddress"`
RegistryConfig struct {
AllowNondistributableArtifactsCIDRs []interface{} `json:"AllowNondistributableArtifactsCIDRs"`
AllowNondistributableArtifactsHostnames []interface{} `json:"AllowNondistributableArtifactsHostnames"`
InsecureRegistryCIDRs []interface{} `json:"InsecureRegistryCIDRs"`
IndexConfigs struct {
} `json:"IndexConfigs"`
Mirrors []interface{} `json:"Mirrors"`
} `json:"RegistryConfig"`
NCPU int `json:"NCPU"`
MemTotal int64 `json:"MemTotal"`
GenericResources interface{} `json:"GenericResources"`
DockerRootDir string `json:"DockerRootDir"`
HttpProxy string `json:"HttpProxy"`
HttpsProxy string `json:"HttpsProxy"`
NoProxy string `json:"NoProxy"`
Name string `json:"Name"`
Labels interface{} `json:"Labels"`
ExperimentalBuild bool `json:"ExperimentalBuild"`
ServerVersion string `json:"ServerVersion"`
Runtimes struct {
Crun struct {
Path string `json:"path"`
} `json:"crun"`
CrunVm struct {
Path string `json:"path"`
} `json:"crun-vm"`
CrunWasm struct {
Path string `json:"path"`
} `json:"crun-wasm"`
Kata struct {
Path string `json:"path"`
} `json:"kata"`
Krun struct {
Path string `json:"path"`
} `json:"krun"`
Ocijail struct {
Path string `json:"path"`
} `json:"ocijail"`
Runc struct {
Path string `json:"path"`
} `json:"runc"`
Runj struct {
Path string `json:"path"`
} `json:"runj"`
Runsc struct {
Path string `json:"path"`
} `json:"runsc"`
Youki struct {
Path string `json:"path"`
} `json:"youki"`
} `json:"Runtimes"`
DefaultRuntime string `json:"DefaultRuntime"`
Swarm struct {
NodeID string `json:"NodeID"`
NodeAddr string `json:"NodeAddr"`
LocalNodeState string `json:"LocalNodeState"`
ControlAvailable bool `json:"ControlAvailable"`
Error string `json:"Error"`
RemoteManagers interface{} `json:"RemoteManagers"`
} `json:"Swarm"`
LiveRestoreEnabled bool `json:"LiveRestoreEnabled"`
Isolation string `json:"Isolation"`
InitBinary string `json:"InitBinary"`
ContainerdCommit struct {
ID string `json:"ID"`
Expected string `json:"Expected"`
} `json:"ContainerdCommit"`
RuncCommit struct {
ID string `json:"ID"`
Expected string `json:"Expected"`
} `json:"RuncCommit"`
InitCommit struct {
ID string `json:"ID"`
Expected string `json:"Expected"`
} `json:"InitCommit"`
SecurityOptions []string `json:"SecurityOptions"`
ProductLicense string `json:"ProductLicense"`
CDISpecDirs interface{} `json:"CDISpecDirs"`
Warnings []interface{} `json:"Warnings"`
BuildahVersion string `json:"BuildahVersion"`
CPURealtimePeriod bool `json:"CPURealtimePeriod"`
CPURealtimeRuntime bool `json:"CPURealtimeRuntime"`
CgroupVersion string `json:"CgroupVersion"`
Rootless bool `json:"Rootless"`
SwapFree int64 `json:"SwapFree"`
SwapTotal int64 `json:"SwapTotal"`
Uptime string `json:"Uptime"`
}
type BasicInfo struct {
Platform struct {
Name string `json:"Name"`
} `json:"Platform"`
Uptime string `json:"Uptime"`
DefaultRuntime string `json:"DefaultRuntime"`
NCPU int `json:"NCPU"`
MemTotal int64 `json:"MemTotal"`
OperatingSystem string `json:"OperatingSystem"`
Images int `json:"Images"`
Containers int `json:"Containers"`
Networks int `json:"Networks"`
Volumes int `json:"Volumes"`
}

35
lib/model/network.go Normal file
View File

@ -0,0 +1,35 @@
package model
import "time"
type NetWorkJson struct {
Name string `json:"Name"`
Id string `json:"Id"`
Created time.Time `json:"Created"`
Scope string `json:"Scope"`
Driver string `json:"Driver"`
EnableIPv6 bool `json:"EnableIPv6"`
IPAM struct {
Driver string `json:"Driver"`
Options struct {
Driver string `json:"driver"`
} `json:"Options"`
Config []struct {
Subnet string `json:"Subnet"`
Gateway string `json:"Gateway"`
} `json:"Config"`
} `json:"IPAM"`
Internal bool `json:"Internal"`
Attachable bool `json:"Attachable"`
Ingress bool `json:"Ingress"`
ConfigFrom struct {
Network string `json:"Network"`
} `json:"ConfigFrom"`
ConfigOnly bool `json:"ConfigOnly"`
Containers struct {
} `json:"Containers"`
Options struct {
} `json:"Options"`
Labels struct {
} `json:"Labels"`
}

18
lib/model/volume.go Normal file
View File

@ -0,0 +1,18 @@
package model
import "time"
type VolumesJson struct {
Volumes []struct {
CreatedAt time.Time `json:"CreatedAt"`
Driver string `json:"Driver"`
Labels struct {
} `json:"Labels"`
Mountpoint string `json:"Mountpoint"`
Name string `json:"Name"`
Options struct {
} `json:"Options"`
Scope string `json:"Scope"`
} `json:"Volumes"`
Warnings []interface{} `json:"Warnings"`
}

24
service/auth/sigin.go Normal file
View File

@ -0,0 +1,24 @@
package auth
import (
"github.com/gin-gonic/gin"
"log"
"net/http"
)
type SignReq struct {
Email string `json:"email"`
Password string `json:"password"`
}
func Sign(c *gin.Context) {
var req SignReq
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
}
jwt.
c.JSON(http.StatusOK, gin.H{
"data": "hello world",
})
log.Println(req)
}