mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
refactor: move driver handlers to own file
This commit is contained in:
@@ -7,15 +7,15 @@ tmp_dir = "out"
|
|||||||
bin = "./out/main"
|
bin = "./out/main"
|
||||||
cmd = "go build -o ./out/main ."
|
cmd = "go build -o ./out/main ."
|
||||||
delay = 1000
|
delay = 1000
|
||||||
exclude_dir = ["assets", "out", "vendor", "testdata"]
|
exclude_dir = ["assets", "out", "vendor", "testdata", "frontend"]
|
||||||
exclude_file = []
|
exclude_file = []
|
||||||
exclude_regex = ["_test.go"]
|
exclude_regex = ["_test.go"]
|
||||||
exclude_unchanged = false
|
exclude_unchanged = false
|
||||||
follow_symlink = false
|
follow_symlink = false
|
||||||
full_bin = ""
|
full_bin = ""
|
||||||
include_dir = []
|
include_dir = []
|
||||||
include_ext = ["go", "tpl", "tmpl", "html"]
|
include_ext = ["go"]
|
||||||
include_file = []
|
include_file = ["main.go"]
|
||||||
kill_delay = "0s"
|
kill_delay = "0s"
|
||||||
log = "build-errors.log"
|
log = "build-errors.log"
|
||||||
poll = false
|
poll = false
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
FROM golang:1.24-alpine3.21 AS builder
|
FROM golang:1.24-alpine3.21 AS builder
|
||||||
|
|
||||||
WORKDIR /ironmount
|
WORKDIR /app
|
||||||
|
|
||||||
RUN go install github.com/air-verse/air@latest
|
RUN go install github.com/air-verse/air@latest
|
||||||
|
|
||||||
COPY go.mod ./
|
COPY go.mod ./
|
||||||
|
COPY go.sum ./
|
||||||
|
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
COPY . .
|
COPY ./internal ./internal
|
||||||
|
COPY ./main.go ./
|
||||||
|
COPY ./.air.toml ./
|
||||||
|
|
||||||
CMD ["air", "-c", ".air.toml"]
|
CMD ["air", "-c", ".air.toml"]
|
||||||
|
|||||||
@@ -15,10 +15,11 @@ services:
|
|||||||
# security_opt:
|
# security_opt:
|
||||||
# - apparmor:unconfined
|
# - apparmor:unconfined
|
||||||
volumes:
|
volumes:
|
||||||
- ./main.go:/ironmount/main.go
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- ./internal:/irounmount/internal
|
|
||||||
|
|
||||||
- /run/docker/plugins:/run/docker/plugins
|
- /run/docker/plugins:/run/docker/plugins
|
||||||
|
|
||||||
|
- ./:/app/
|
||||||
|
|
||||||
- /home/nicolas/ironmount/tmp:/mounts
|
- /home/nicolas/ironmount/tmp:/mounts
|
||||||
environment:
|
environment:
|
||||||
- GO_ENV=development
|
- GO_ENV=development
|
||||||
|
|||||||
17
internal/driver/handlers.go
Normal file
17
internal/driver/handlers.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package driver
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SetupHandlers(mux *http.ServeMux) {
|
||||||
|
mux.HandleFunc("/Plugin.Activate", Activate)
|
||||||
|
mux.HandleFunc("/VolumeDriver.Create", Create)
|
||||||
|
mux.HandleFunc("/VolumeDriver.Remove", Remove)
|
||||||
|
mux.HandleFunc("/VolumeDriver.Mount", Mount)
|
||||||
|
mux.HandleFunc("/VolumeDriver.Unmount", Unmount)
|
||||||
|
mux.HandleFunc("/VolumeDriver.Path", Path)
|
||||||
|
mux.HandleFunc("/VolumeDriver.Get", Get)
|
||||||
|
mux.HandleFunc("/VolumeDriver.List", List)
|
||||||
|
|
||||||
|
}
|
||||||
9
main.go
9
main.go
@@ -42,14 +42,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.HandleFunc("/Plugin.Activate", driver.Activate)
|
driver.SetupHandlers(mux)
|
||||||
mux.HandleFunc("/VolumeDriver.Create", driver.Create)
|
|
||||||
mux.HandleFunc("/VolumeDriver.Remove", driver.Remove)
|
|
||||||
mux.HandleFunc("/VolumeDriver.Mount", driver.Mount)
|
|
||||||
mux.HandleFunc("/VolumeDriver.Unmount", driver.Unmount)
|
|
||||||
mux.HandleFunc("/VolumeDriver.Path", driver.Path)
|
|
||||||
mux.HandleFunc("/VolumeDriver.Get", driver.Get)
|
|
||||||
mux.HandleFunc("/VolumeDriver.List", driver.List)
|
|
||||||
|
|
||||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, "Not Found", http.StatusNotFound)
|
http.Error(w, "Not Found", http.StatusNotFound)
|
||||||
|
|||||||
Reference in New Issue
Block a user