chore: delete go folder

This commit is contained in:
Nicolas Meienberger
2025-09-03 22:19:26 +02:00
parent 7fe75c64e8
commit aa82f95c56
21 changed files with 0 additions and 1319 deletions

View File

@@ -1,52 +0,0 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "out"
[build]
args_bin = []
bin = "./out/main"
cmd = "go build -o ./out/main ."
delay = 1000
exclude_dir = ["assets", "out", "vendor", "testdata", "web", "tmp"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go"]
include_file = ["main.go"]
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false
[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
[log]
main_only = false
silent = false
time = false
[misc]
clean_on_exit = false
[proxy]
app_port = 0
enabled = false
proxy_port = 0
[screen]
clear_on_rebuild = false
keep_scroll = true

View File

@@ -1,20 +0,0 @@
FROM golang:1.24-alpine3.21 AS builder
WORKDIR /ironmount
COPY go.mod ./
RUN go mod download
COPY . .
ARG TARGETOS=linux
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -o /out/ironmount .
FROM alpine:3.22 AS runner
WORKDIR /
COPY --from=builder /out/ironmount /ironmount
ENTRYPOINT ["/ironmount"]

View File

@@ -1,16 +0,0 @@
FROM golang:1.24-alpine3.21 AS builder
WORKDIR /app
RUN go install github.com/air-verse/air@latest
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY ./internal ./internal
COPY ./main.go ./
COPY ./.air.toml ./
CMD ["air", "-c", ".air.toml"]

View File

@@ -1,25 +0,0 @@
services:
ironmount:
build:
context: .
dockerfile: Dockerfile.dev
container_name: ironmount
restart: unless-stopped
cap_add:
- SYS_ADMIN
- SYS_MODULE
ports:
- "8080:8080"
privileged: true
# security_opt:
# - apparmor:unconfined
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /run/docker/plugins:/run/docker/plugins
- ./:/app/
# - /home/nicolas/ironmount/tmp:/mounts:rshared
environment:
- GO_ENV=development
- VOLUME_ROOT=/home/nicolas/ironmount/tmp

View File

@@ -1,69 +0,0 @@
module ironmount
go 1.24.5
require (
github.com/gin-gonic/gin v1.10.1
github.com/glebarez/sqlite v1.11.0
github.com/go-playground/validator/v10 v10.27.0
github.com/rs/zerolog v1.34.0
github.com/spf13/viper v1.20.1
gorm.io/gorm v1.30.1
)
require (
github.com/bytedance/sonic v1.14.0 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/gin-contrib/cors v1.7.6 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect
github.com/go-jet/jet/v2 v2.13.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/moby/sys/mountinfo v0.7.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/sagikazarmark/locafero v0.7.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.3.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/arch v0.20.0 // indirect
golang.org/x/crypto v0.41.0 // indirect
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.28.0 // indirect
google.golang.org/protobuf v1.36.7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/mount-utils v0.33.4 // indirect
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
modernc.org/libc v1.66.3 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
modernc.org/sqlite v1.38.2 // indirect
)

190
go/go.sum
View File

@@ -1,190 +0,0 @@
github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=
github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA=
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
github.com/gin-contrib/cors v1.7.6 h1:3gQ8GMzs1Ylpf70y8bMw4fVpycXIeX1ZemuSQIsnQQY=
github.com/gin-contrib/cors v1.7.6/go.mod h1:Ulcl+xN4jel9t1Ry8vqph23a60FwH9xVLd+3ykmTjOk=
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo=
github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k=
github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw=
github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ=
github.com/go-jet/jet/v2 v2.13.0 h1:DcD2IJRGos+4X40IQRV6S6q9onoOfZY/GPdvU6ImZcQ=
github.com/go-jet/jet/v2 v2.13.0/go.mod h1:YhT75U1FoYAxFOObbQliHmXVYQeffkBKWT7ZilZ3zPc=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg=
github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4=
github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
golang.org/x/arch v0.20.0 h1:dx1zTU0MAE98U+TQ8BLl7XsJbgze2WnNKF/8tGp/Q6c=
golang.org/x/arch v0.20.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg=
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A=
google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/gorm v1.30.1 h1:lSHg33jJTBxs2mgJRfRZeLDG+WZaHYCk3Wtfl6Ngzo4=
gorm.io/gorm v1.30.1/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/mount-utils v0.33.4 h1:o83Qx0AgY5JDYhFV6gAYfSy+GAPIuPqSKdEqac5lxqo=
k8s.io/mount-utils v0.33.4/go.mod h1:1JR4rKymg8B8bCPo618hpSAdrpO6XLh0Acqok/xVwPE=
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro=
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
modernc.org/cc/v4 v4.26.2 h1:991HMkLjJzYBIfha6ECZdjrIYz2/1ayr+FL8GN+CNzM=
modernc.org/cc/v4 v4.26.2/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
modernc.org/ccgo/v4 v4.28.0 h1:rjznn6WWehKq7dG4JtLRKxb52Ecv8OUGah8+Z/SfpNU=
modernc.org/ccgo/v4 v4.28.0/go.mod h1:JygV3+9AV6SmPhDasu4JgquwU81XAKLd3OKTUDNOiKE=
modernc.org/fileutil v1.3.8 h1:qtzNm7ED75pd1C7WgAGcK4edm4fvhtBsEiI/0NQ54YM=
modernc.org/fileutil v1.3.8/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
modernc.org/libc v1.66.3 h1:cfCbjTUcdsKyyZZfEUKfoHcP3S0Wkvz3jgSzByEWVCQ=
modernc.org/libc v1.66.3/go.mod h1:XD9zO8kt59cANKvHPXpx7yS2ELPheAey0vjIuZOhOU8=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/sqlite v1.38.2 h1:Aclu7+tgjgcQVShZqim41Bbw9Cho0y/7WzYptXqkEek=
modernc.org/sqlite v1.38.2/go.mod h1:cPTJYSlgg3Sfg046yBShXENNtPrWrDX8bsbAQBzgQ5E=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=

View File

@@ -1,4 +0,0 @@
// Package constants defines constants used throughout the application.
package constants
const VolumeRootLocal = "/mounts"

View File

@@ -1,34 +0,0 @@
// Package core provides the configuration loading functionality for the application.
package core
import (
"github.com/go-playground/validator/v10"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
)
type Config struct {
VolumeRootHost string `mapstructure:"volume_root" validate:"required"`
}
func LoadConfig() Config {
var config Config
viper.AutomaticEnv()
viper.BindEnv("volume_root", "VOLUME_ROOT")
if err := viper.Unmarshal(&config); err != nil {
log.Error().Err(err).Msg("Failed to load configuration")
panic("Failed to load configuration: " + err.Error())
}
validator := validator.New()
if err := validator.Struct(config); err != nil {
log.Error().Err(err).Msg("Configuration validation failed")
panic("Configuration validation failed: " + err.Error())
}
log.Info().Msgf("Loaded configuration: %+v", config)
return config
}

View File

@@ -1,68 +0,0 @@
package core
import (
stdlog "log"
"os"
"strconv"
"time"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func init() {
console := zerolog.ConsoleWriter{
Out: os.Stderr,
TimeFormat: time.ANSIC,
}
logger := zerolog.New(console).With().Timestamp().Caller().Logger()
zerolog.SetGlobalLevel(zerolog.InfoLevel)
log.Logger = logger
stdlog.SetFlags(0)
stdlog.SetOutput(console)
}
func colorStatus(code int) string {
switch {
case code >= 200 && code < 300:
// Green background
return "\033[42m" + strconv.Itoa(code) + "\033[0m"
case code >= 300 && code < 400:
// Cyan background
return "\033[46m" + strconv.Itoa(code) + "\033[0m"
case code >= 400 && code < 500:
// Yellow background
return "\033[43m" + strconv.Itoa(code) + "\033[0m"
default:
// Red background
return "\033[41m" + strconv.Itoa(code) + "\033[0m"
}
}
// GinLogger is a middleware for Gin that logs HTTP requests
// using zerolog.
func GinLogger() gin.HandlerFunc {
return func(c *gin.Context) {
c.Next()
code := c.Writer.Status()
method := c.Request.Method
path := c.Request.URL.Path
// logPath check if the path should be logged normally or with debug
switch {
case code >= 200 && code < 300:
log.Info().Str("method", method).Str("path", path).Msgf("Request status=%s", colorStatus(code))
case code >= 300 && code < 400:
log.Warn().Str("method", method).Str("path", path).Msgf("Request status=%s", colorStatus(code))
case code >= 400:
log.Error().Str("method", method).Str("path", path).Msgf("Request status=%s", colorStatus(code))
}
}
}

View File

@@ -1,18 +0,0 @@
package core
import (
"regexp"
"strings"
)
var nonAlnum = regexp.MustCompile(`[^a-z0-9_-]+`)
var hyphenRuns = regexp.MustCompile(`[-_]{2,}`)
func Slugify(input string) string {
s := strings.ToLower(strings.TrimSpace(input))
s = nonAlnum.ReplaceAllString(s, "-")
s = hyphenRuns.ReplaceAllString(s, "-")
s = strings.Trim(s, "-")
return s
}

View File

@@ -1,129 +0,0 @@
package core
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"reflect"
"strings"
"github.com/gin-gonic/gin/binding"
"github.com/go-playground/validator/v10"
)
type FieldError struct {
Field string `json:"field"`
Tag string `json:"tag"`
Param string `json:"param,omitempty"`
Message string `json:"message"`
}
type ValidationError struct {
Errors []FieldError `json:"errors"`
}
func (e *ValidationError) Error() string {
return fmt.Sprintf("validation failed (%d errors)", len(e.Errors))
}
// DecodeStrict decodes a JSON object from raw, rejects unknown fields, and
// validates struct tags (binding:"..."). Returns a ValidationError for
// semantic issues so callers can map it to HTTP 422.
func DecodeStrict[T any](raw json.RawMessage) (T, error) {
var out T
trimmed := bytes.TrimSpace(raw)
if len(trimmed) == 0 || bytes.Equal(trimmed, []byte("null")) {
return out, &ValidationError{
Errors: []FieldError{{
Field: "",
Tag: "required",
Message: "config is required",
}},
}
}
if trimmed[0] != '{' {
return out, fmt.Errorf("config must be a JSON object")
}
dec := json.NewDecoder(bytes.NewReader(raw))
dec.DisallowUnknownFields()
if err := dec.Decode(&out); err != nil {
return out, fmt.Errorf("invalid JSON: %w", err)
}
// Ensure no trailing junk after the object
if err := dec.Decode(&struct{}{}); err != io.EOF {
if err == nil {
return out, errors.New("unexpected trailing data after JSON object")
}
return out, fmt.Errorf("invalid JSON: %w", err)
}
if binding.Validator == nil {
return out, errors.New("validator not initialized")
}
if err := binding.Validator.ValidateStruct(out); err != nil {
if verrs, ok := err.(validator.ValidationErrors); ok {
return out, toValidationError[T](verrs)
}
return out, err
}
return out, nil
}
func toValidationError[T any](verrs validator.ValidationErrors) *ValidationError {
errs := make([]FieldError, 0, len(verrs))
t := reflect.TypeOf((*T)(nil)).Elem()
if t.Kind() == reflect.Pointer {
t = t.Elem()
}
for _, fe := range verrs {
name := fe.Field()
if t.Kind() == reflect.Struct {
if sf, ok := t.FieldByName(fe.StructField()); ok {
if tag := sf.Tag.Get("json"); tag != "" && tag != "-" {
name = strings.Split(tag, ",")[0]
} else {
// fallback to lower-camel for nicer output
name = lowerCamel(name)
}
}
}
errs = append(errs, FieldError{
Field: name,
Tag: fe.Tag(),
Param: fe.Param(),
Message: defaultMsg(fe),
})
}
return &ValidationError{Errors: errs}
}
func defaultMsg(fe validator.FieldError) string {
switch fe.Tag() {
case "required":
return ""
case "min":
return fmt.Sprintf("must be at least %s", fe.Param())
case "max":
return fmt.Sprintf("must be at most %s", fe.Param())
case "oneof":
return "must be one of: " + fe.Param()
case "hostname", "ip":
return "must be a valid " + fe.Tag()
}
return fe.Error()
}
func lowerCamel(s string) string {
if s == "" {
return s
}
r := []rune(s)
r[0] = []rune(strings.ToLower(string(r[0])))[0]
return string(r)
}

View File

@@ -1,22 +0,0 @@
// Package db provides database access for the Ironmount application
package db
import (
"github.com/glebarez/sqlite"
"gorm.io/gorm"
)
var DB, err = gorm.Open(sqlite.Open("file:ironmount.db"), &gorm.Config{})
// InitDB initializes the database and creates the volumes table if it doesn't exist
func InitDB() {
if err != nil {
panic(err)
}
err = DB.AutoMigrate(&Volume{})
if err != nil {
panic(err)
}
}

View File

@@ -1,13 +0,0 @@
package db
import (
"gorm.io/gorm"
)
type Volume struct {
gorm.Model
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"`
Config string `json:"config"`
}

View File

@@ -1,180 +0,0 @@
// Package driver provides the HTTP handlers for the volume driver API.
package driver
import (
"ironmount/internal/modules/volumes"
"net/http"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
)
func SetupHandlers(router *gin.Engine) {
volumeService := volumes.VolumeService{}
router.POST("/VolumeDriver.Capabilities", func(c *gin.Context) {
c.JSON(200, gin.H{
"Capabilities": map[string]bool{
"Scope": true, // Indicates that the driver supports scope (local/global)
},
})
})
router.POST("/Plugin.Activate", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"Implements": []string{
"VolumeDriver",
},
})
})
router.POST("/VolumeDriver.Create", func(c *gin.Context) {
var req CreateRequest
if err := c.BindJSON(&req); err != nil {
log.Error().Err(err).Msg("Invalid request body for Create")
c.JSON(http.StatusBadRequest, gin.H{"Err": "Invalid request body"})
return
}
volume, status, err := volumeService.CreateVolume(volumes.VolumeCreateRequest{
Name: req.Name,
Type: volumes.VolumeBackendTypeLocal,
})
if err != nil {
log.Error().Err(err).Msg("Failed to create volume")
c.JSON(status, gin.H{"Err": err.Error()})
return
}
c.JSON(status, gin.H{
"Name": volume.Name,
"Mountpoint": volume.Path,
"Err": "",
})
})
router.POST("/VolumeDriver.Remove", func(c *gin.Context) {
var req RemoveRequest
if err := c.BindJSON(&req); err != nil {
log.Error().Err(err).Msg("Invalid request body for Remove")
c.JSON(http.StatusBadRequest, gin.H{"Err": "Invalid request body"})
return
}
status, err := volumeService.DeleteVolume(req.Name)
if err != nil {
c.JSON(status, gin.H{"Err": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{
"Err": "",
})
})
router.POST("/VolumeDriver.Mount", func(c *gin.Context) {
var req MountRequest
if err := c.BindJSON(&req); err != nil {
log.Error().Err(err).Msg("Invalid request body")
c.JSON(http.StatusBadRequest, gin.H{"Err": "Invalid request body"})
return
}
volume, err := volumeService.GetVolume(req.Name)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
if volume == nil {
c.JSON(http.StatusNotFound, gin.H{"error": "Volume not found"})
return
}
c.JSON(http.StatusOK, gin.H{
"Name": volume.Name,
"Mountpoint": volume.Path,
"Err": "",
})
})
// VolumeDriver.Unmount is a no-op in this implementation
router.POST("/VolumeDriver.Unmount", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"Err": "",
})
})
// VolumeDriver.Path returns the mount point of the volume
router.POST("/VolumeDriver.Path", func(c *gin.Context) {
var req PathRequest
if err := c.BindJSON(&req); err != nil {
log.Error().Err(err).Msg("Invalid request body for Path")
c.JSON(http.StatusBadRequest, gin.H{"Err": "Invalid request body"})
return
}
vol, err := volumeService.GetVolume(req.Name)
if err != nil {
c.JSON(http.StatusNotFound, gin.H{"Err": err.Error()})
return
}
if vol == nil {
c.JSON(http.StatusNotFound, gin.H{"Err": "Volume not found"})
return
}
c.JSON(http.StatusOK, gin.H{
"Mountpoint": vol.Path,
"Err": "",
})
})
router.POST("/VolumeDriver.Get", func(c *gin.Context) {
var req GetRequest
if err := c.BindJSON(&req); err != nil {
log.Error().Err(err).Msg("Invalid request body for Get")
c.JSON(http.StatusBadRequest, gin.H{"Err": "Invalid request body"})
return
}
vol, err := volumeService.GetVolume(req.Name)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"Err": err.Error()})
return
}
if vol == nil {
c.JSON(http.StatusNotFound, gin.H{"Err": "Volume not found"})
return
}
data := map[string]any{
"Volume": map[string]string{
"Name": vol.Name,
"Mountpoint": vol.Path,
"CreatedAt": vol.CreatedAt.Format(volumes.DateFormat),
},
"Err": "",
}
c.JSON(http.StatusOK, data)
})
router.POST("/VolumeDriver.List", func(c *gin.Context) {
volumesList := volumeService.ListVolumes()
c.JSON(http.StatusOK, gin.H{
"Volumes": volumesList,
})
})
}

View File

@@ -1,26 +0,0 @@
package driver
// CreateRequest is the JSON request for Create
type CreateRequest struct {
Name string
}
type GetRequest struct {
Name string
}
// RemoveRequest is the JSON request for Remove
type RemoveRequest struct {
Name string
}
// MountRequest is the JSON request for Mount
type MountRequest struct {
Name string
ID string
}
// PathRequest is the JSON request for Path
type PathRequest struct {
Name string
}

View File

@@ -1,63 +0,0 @@
// Package volumes provides tools for managing volumes in the application.
package volumes
import (
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
)
// SetupHandlers sets up the API routes for the application.
func SetupHandlers(router *gin.Engine) {
volumeService := VolumeService{}
router.GET("/api/volumes", func(c *gin.Context) {
volumes := volumeService.ListVolumes()
log.Debug().Msgf("Listing volumes: %v", volumes)
c.JSON(200, gin.H{"volumes": volumes})
})
router.POST("/api/volumes", func(c *gin.Context) {
var body VolumeCreateRequest
if err := c.ShouldBindJSON(&body); err != nil {
log.Error().Err(err).Msg("Failed to bind JSON for volume creation")
c.JSON(400, gin.H{"error": "Invalid request body"})
return
}
volume, status, err := volumeService.CreateVolume(body)
if err != nil {
c.JSON(status, gin.H{"error": err.Error()})
return
}
c.JSON(status, volume)
})
router.GET("/api/volumes/:name", func(c *gin.Context) {
volume, err := volumeService.GetVolume(c.Param("name"))
if err != nil {
c.JSON(500, gin.H{"error": err.Error()})
return
}
if volume == nil {
c.JSON(404, gin.H{"error": "Volume not found"})
return
}
c.JSON(200, gin.H{
"name": volume.Name,
"mountpoint": volume.Path,
"created_at": volume.CreatedAt.String(),
"err": "",
})
})
router.DELETE("/api/volumes/:name", func(c *gin.Context) {
status, err := volumeService.DeleteVolume(c.Param("name"))
if err != nil {
c.JSON(status, gin.H{"error": err.Error()})
return
}
c.JSON(200, gin.H{"message": "Volume deleted successfully"})
})
}

View File

@@ -1,72 +0,0 @@
package volumes
import (
"context"
"github.com/go-playground/validator/v10"
"ironmount/internal/db"
"github.com/rs/zerolog/log"
"gorm.io/gorm"
)
type VolumeQueries struct{}
func (q *VolumeQueries) QueryVolumeByName(n string) (*db.Volume, error) {
ctx := context.Background()
volume, err := gorm.G[*db.Volume](db.DB).Where("name = ?", n).First(ctx)
if err != nil {
if (err.Error() == "record not found") || (err == gorm.ErrRecordNotFound) {
log.Warn().Str("name", n).Msg("Volume not found")
return nil, nil
}
return nil, err
}
return volume, nil
}
func (q *VolumeQueries) InsertVolume(name string, path string, volType VolumeBackendType, config string) error {
ctx := context.Background()
validate := validator.New(validator.WithRequiredStructEnabled())
data := &db.Volume{}
if err := validate.Struct(data); err != nil {
log.Error().Err(err).Str("name", name).Msg("Validation error while inserting volume")
return err
}
err := gorm.G[db.Volume](db.DB).Create(ctx, &db.Volume{})
if err != nil {
return err
}
return nil
}
func (q *VolumeQueries) RemoveVolume(name string) error {
ctx := context.Background()
log.Info().Str("volume", name).Msg("Removing volume")
_, err := gorm.G[db.Volume](db.DB).Where("name = ?", name).Delete(ctx)
if err != nil {
log.Error().Err(err).Str("volume", name).Msg("Error removing volume")
return err
}
return nil
}
func (q *VolumeQueries) QueryVolumes() ([]db.Volume, error) {
rows, err := gorm.G[db.Volume](db.DB).Select("name", "path", "created_at").Find(context.Background())
if err != nil {
return []db.Volume{}, err
}
return rows, nil
}

View File

@@ -1,133 +0,0 @@
package volumes
import (
"fmt"
"ironmount/internal/constants"
"ironmount/internal/core"
"ironmount/internal/db"
"net/http"
"os"
"path/filepath"
"strings"
"github.com/rs/zerolog/log"
"k8s.io/utils/mount"
)
type VolumeService struct{}
var volumeQueries = VolumeQueries{}
// CreateVolume handles the creation of a new volume.
func (v *VolumeService) CreateVolume(body VolumeCreateRequest) (*db.Volume, int, error) {
name := core.Slugify(body.Name)
if name == "" || name != body.Name {
return nil, http.StatusBadRequest, fmt.Errorf("invalid volume name: %s", body.Name)
}
existingVol, _ := volumeQueries.QueryVolumeByName(name)
if existingVol != nil {
return nil, http.StatusConflict, fmt.Errorf("volume %s already exists", name)
}
cfg := core.LoadConfig()
volPathHost := filepath.Join(cfg.VolumeRootHost, name, "_data")
volPathLocal := filepath.Join(constants.VolumeRootLocal, name, "_data")
if err := os.MkdirAll(volPathLocal, 0755); err != nil {
return nil, http.StatusInternalServerError, fmt.Errorf("failed to create volume directory: %w", err)
}
switch body.Type {
case VolumeBackendTypeNFS:
var cfg NFSConfig
cfg, err := core.DecodeStrict[NFSConfig](body.Config)
if err != nil {
return nil, http.StatusBadRequest, fmt.Errorf("invalid NFS configuration: %w", err)
}
mounter := mount.New("")
source := fmt.Sprintf("%s:%s", cfg.Server, cfg.ExportPath)
options := []string{"vers=" + cfg.Version, "port=" + fmt.Sprintf("%d", cfg.Port)}
if err := UnmountVolume(volPathLocal); err != nil {
return nil, http.StatusInternalServerError, fmt.Errorf("failed to unmount existing volume: %w", err)
}
if err := mounter.Mount(source, volPathLocal, "nfs", options); err != nil {
return nil, http.StatusInternalServerError, fmt.Errorf("failed to mount NFS volume: %w", err)
}
case VolumeBackendTypeSMB:
var _ SMBConfig
case VolumeBackendTypeLocal:
var cfg DirectoryConfig
log.Debug().Str("directory_path", cfg.Path).Msg("Using local directory for volume")
}
bytesConfig, err := body.Config.MarshalJSON()
if err != nil {
return nil, http.StatusBadRequest, fmt.Errorf("failed to marshal volume configuration: %w", err)
}
stringConfig := string(bytesConfig)
if err := volumeQueries.InsertVolume(name, volPathHost, VolumeBackendTypeLocal, stringConfig); err != nil {
if strings.Contains(err.Error(), "UNIQUE") {
return nil, http.StatusConflict, fmt.Errorf("volume %s already exists", name)
}
return nil, http.StatusInternalServerError, fmt.Errorf("failed to create volume in database: %w", err)
}
return &db.Volume{
Name: name,
Path: volPathHost,
}, http.StatusOK, nil
}
func (v *VolumeService) GetVolume(name string) (*db.Volume, error) {
vol, err := volumeQueries.QueryVolumeByName(name)
return vol, err
}
func (v *VolumeService) ListVolumes() []VolumeInfo {
vols, _ := volumeQueries.QueryVolumes()
volumes := []VolumeInfo{}
for _, vol := range vols {
volumes = append(volumes, VolumeInfo{
Name: vol.Name,
Mountpoint: vol.Path,
CreatedAt: vol.CreatedAt.Format(DateFormat),
Err: "",
})
}
return volumes
}
func (v *VolumeService) DeleteVolume(name string) (int, error) {
vol, _ := volumeQueries.QueryVolumeByName(name)
if vol == nil {
return http.StatusNotFound, fmt.Errorf("volume %s not found", name)
}
if err := volumeQueries.RemoveVolume(name); err != nil {
return http.StatusInternalServerError, fmt.Errorf("failed to remove volume from database: %w", err)
}
volPathLocal := filepath.Join(constants.VolumeRootLocal, name)
log.Debug().Str("volume_path", volPathLocal).Msg("Deleting volume directory")
if err := UnmountVolume(volPathLocal); err != nil {
return http.StatusInternalServerError, fmt.Errorf("failed to unmount volume: %w", err)
}
os.RemoveAll(volPathLocal)
return http.StatusOK, nil
}

View File

@@ -1,87 +0,0 @@
package volumes
import (
"encoding/json"
"fmt"
"strings"
)
var DateFormat = "2006-01-02T15:04:05Z"
type CreateVolumeResponse struct {
Name string `json:"name"`
Mountpoint string `json:"mountpoint"`
Err string `json:"err,omitempty"`
}
type GetVolumeResponse struct {
Name string `json:"name"`
Mountpoint string `json:"mountpoint"`
Err string `json:"err,omitempty"`
}
type VolumeInfo struct {
Name string `json:"name"`
Mountpoint string `json:"mountpoint"`
Err string `json:"err,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
}
type ListVolumesResponse struct {
Volumes []VolumeInfo `json:"volumes"`
Err string `json:"err,omitempty"`
}
type VolumeBackendType string
const (
VolumeBackendTypeSMB VolumeBackendType = "smb"
VolumeBackendTypeNFS VolumeBackendType = "nfs"
VolumeBackendTypeLocal VolumeBackendType = "local"
)
func (vbt VolumeBackendType) String() string {
return string(vbt)
}
func (vbt *VolumeBackendType) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return fmt.Errorf("volume backend type should be a string: %w", err)
}
lower := strings.ToLower(s)
switch VolumeBackendType(lower) {
case VolumeBackendTypeSMB, VolumeBackendTypeNFS, VolumeBackendTypeLocal:
*vbt = VolumeBackendType(lower)
return nil
default:
return fmt.Errorf("invalid volume backend type: '%s'. Allowed types are: smb, nfs, local", lower)
}
}
type VolumeCreateRequest struct {
Name string `json:"name" binding:"required"`
Type VolumeBackendType `json:"type" binding:"required,oneof=nfs smb directory"`
Config json.RawMessage `json:"config" binding:"required"`
}
type NFSConfig struct {
Server string `json:"server" binding:"required,hostname|ip"`
ExportPath string `json:"exportPath" binding:"required"`
Port int `json:"port" binding:"required,min=1,max=65535"`
Version string `json:"version" binding:"required,oneof=3 4"`
}
type SMBConfig struct {
Server string `json:"server" binding:"required"`
Share string `json:"share" binding:"required"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Domain string `json:"domain,omitempty"`
}
type DirectoryConfig struct {
Path string `json:"path" binding:"required"`
}

View File

@@ -1,21 +0,0 @@
package volumes
import (
"fmt"
"strings"
"k8s.io/utils/mount"
)
func UnmountVolume(path string) error {
mounter := mount.New("")
if err := mounter.Unmount(path); err != nil {
if strings.Contains(err.Error(), "not mounted") || strings.Contains(err.Error(), "No such file or directory") || strings.Contains(err.Error(), "Invalid argument") {
// Volume is not mounted
return nil
}
return fmt.Errorf("failed to unmount volume at %s: %w", path, err)
}
return nil
}

View File

@@ -1,77 +0,0 @@
package main
import (
"ironmount/internal/constants"
"ironmount/internal/core"
"ironmount/internal/db"
"ironmount/internal/modules/driver"
"ironmount/internal/modules/volumes"
"net"
"net/http"
"os"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
)
func main() {
db.InitDB()
if err := os.MkdirAll("/run/docker/plugins", 0755); err != nil {
log.Fatal().Err(err).Msg("Failed to create plugin directory")
}
if err := os.MkdirAll(constants.VolumeRootLocal, 0755); err != nil {
log.Fatal().Err(err).Msg("Failed to create volume root")
}
if err := os.MkdirAll("/run/docker/plugins", 0755); err != nil {
log.Fatal().Err(err).Msg("Failed to create plugin directory")
}
socketPath := "/run/docker/plugins/ironmount.sock"
if err := os.RemoveAll(socketPath); err != nil {
log.Fatal().Err(err).Msg("Failed to remove existing socket")
}
gin.SetMode(gin.ReleaseMode)
router := gin.New()
router.Use(cors.Default())
router.Use(core.GinLogger())
router.Use(gin.Recovery())
router.GET("/api/health", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "ok"})
})
driver.SetupHandlers(router)
volumes.SetupHandlers(router)
unixListener, err := net.Listen("unix", socketPath)
if err != nil {
log.Fatal().Err(err).Msg("Failed to listen on socket")
}
tcpListener, err := net.Listen("tcp", ":8080")
if err != nil {
log.Fatal().Err(err).Msg("Failed to listen on TCP port 8080")
}
unixServer := &http.Server{Handler: router}
tcpServer := &http.Server{Handler: router}
go func() {
log.Info().Msg("Listening on TCP :8080")
if err := tcpServer.Serve(tcpListener); err != nil && err != http.ErrServerClosed {
log.Fatal().Err(err).Msg("TCP server error")
}
}()
log.Info().Msg("Listening on UNIX " + socketPath)
if err := unixServer.Serve(unixListener); err != nil && err != http.ErrServerClosed {
log.Fatal().Err(err).Msg("Unix server error")
}
}