Skip to content

Commit 80ac43d

Browse files
Merge pull request #157 from IBM/ashima-server
GRPC server changes
2 parents b6c6f1a + cf3f488 commit 80ac43d

14 files changed

+876
-9
lines changed

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-05-07T06:35:25Z",
6+
"generated_at": "2025-05-19T05:44:40Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
dist: bionic
33
language: go
44
go:
5-
- 1.24.1
5+
- 1.24.2
66

77
group: bluezone
88

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FROM registry.access.redhat.com/ubi8/ubi as rclone-builder
3030
RUN yum install wget git gcc -y
3131

3232
ENV ARCH=amd64
33-
ENV GO_VERSION=1.24.1
33+
ENV GO_VERSION=1.24.2
3434

3535
RUN echo $ARCH $GO_VERSION
3636

Dockerfile.builder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24.1
1+
FROM golang:1.24.2
22

33
WORKDIR /go/src/github.com/IBM/ibm-object-csi-driver
44
ADD . /go/src/github.com/IBM/ibm-object-csi-driver

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ deps:
3838
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${LINT_VERSION}; \
3939
fi
4040

41+
.PHONY: run-gosec
42+
run-gosec:
43+
go install github.com/securego/gosec/v2/cmd/gosec@latest
44+
@go list -f '{{.Dir}}' ./... | grep -v '/cos-csi-mounter/' | xargs gosec
4145

4246
.PHONY: fmt
4347
fmt: lint
@@ -58,6 +62,7 @@ test-sanity:
5862
.PHONY: lint
5963
lint:
6064
hack/verify-golint.sh
65+
make run-gosec
6166

6267
.PHONY: driver
6368
driver: deps buildimage

cos-csi-mounter/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ut-coverage: test
2121
go mod tidy
2222

2323
build-linux:
24-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod mod -o ${BIN_DIR}/cos-csi-mounter-server -ldflags "-s -w" -a ./server/server.go
24+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod mod -o ${BIN_DIR}/cos-csi-mounter-server -ldflags "-s -w" -a ./server
2525

2626
deb-build:
2727
deb-build: build-linux

cos-csi-mounter/go.mod

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1-
module cos-csi-mounter
1+
module github.com/IBM/ibm-object-csi-driver/cos-csi-mounter
22

3-
go 1.24.1
3+
go 1.24.2
4+
5+
require (
6+
github.com/IBM/ibm-object-csi-driver v0.1.0
7+
github.com/gin-gonic/gin v1.10.0
8+
go.uber.org/zap v1.27.0
9+
)
10+
11+
require (
12+
github.com/bytedance/sonic v1.11.6 // indirect
13+
github.com/bytedance/sonic/loader v0.1.1 // indirect
14+
github.com/cloudwego/base64x v0.1.4 // indirect
15+
github.com/cloudwego/iasm v0.2.0 // indirect
16+
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
17+
github.com/gin-contrib/sse v0.1.0 // indirect
18+
github.com/go-logr/logr v1.4.2 // indirect
19+
github.com/go-playground/locales v0.14.1 // indirect
20+
github.com/go-playground/universal-translator v0.18.1 // indirect
21+
github.com/go-playground/validator/v10 v10.24.0 // indirect
22+
github.com/goccy/go-json v0.10.2 // indirect
23+
github.com/json-iterator/go v1.1.12 // indirect
24+
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
25+
github.com/leodido/go-urn v1.4.0 // indirect
26+
github.com/mattn/go-isatty v0.0.20 // indirect
27+
github.com/mitchellh/go-ps v1.0.0 // indirect
28+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
29+
github.com/modern-go/reflect2 v1.0.2 // indirect
30+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
31+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
32+
github.com/ugorji/go/codec v1.2.12 // indirect
33+
go.uber.org/multierr v1.11.0 // indirect
34+
golang.org/x/arch v0.8.0 // indirect
35+
golang.org/x/crypto v0.36.0 // indirect
36+
golang.org/x/net v0.37.0 // indirect
37+
golang.org/x/sys v0.31.0 // indirect
38+
golang.org/x/text v0.23.0 // indirect
39+
google.golang.org/protobuf v1.36.1 // indirect
40+
gopkg.in/yaml.v3 v3.0.1 // indirect
41+
k8s.io/klog/v2 v2.130.1 // indirect
42+
)

cos-csi-mounter/go.sum

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
github.com/IBM/ibm-object-csi-driver v0.1.0 h1:2b95Eh98JK1eewLCFDHZW0pJiD+xhRXcWx2DlAUXPnc=
2+
github.com/IBM/ibm-object-csi-driver v0.1.0/go.mod h1:RLNxw4esPAlYYKHVAnlmi5TExNpuDl/6Luf+t0Du4Ik=
3+
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
4+
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
5+
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
6+
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
7+
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
8+
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
9+
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
10+
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
11+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
12+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
13+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
14+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
15+
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
16+
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
17+
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
18+
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
19+
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
20+
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
21+
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
22+
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
23+
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
24+
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
25+
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
26+
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
27+
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
28+
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
29+
github.com/go-playground/validator/v10 v10.24.0 h1:KHQckvo8G6hlWnrPX4NJJ+aBfWNAE/HH+qdL2cBpCmg=
30+
github.com/go-playground/validator/v10 v10.24.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
31+
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
32+
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
33+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
34+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
35+
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
36+
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
37+
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
38+
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
39+
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
40+
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
41+
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
42+
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
43+
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
44+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
45+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
46+
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=
47+
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
48+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
49+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
50+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
51+
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
52+
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
53+
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
54+
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
55+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
56+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
57+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
58+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
59+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
60+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
61+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
62+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
63+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
64+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
65+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
66+
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
67+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
68+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
69+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
70+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
71+
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
72+
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
73+
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
74+
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
75+
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
76+
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
77+
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
78+
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
79+
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
80+
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
81+
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
82+
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
83+
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
84+
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
85+
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
86+
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
87+
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
88+
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
89+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
90+
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
91+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
92+
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
93+
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
94+
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
95+
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
96+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
97+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
98+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
99+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
100+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
101+
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
102+
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
103+
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
104+
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

cos-csi-mounter/install/postinst.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22
set -e
33

4+
# Reload systemd unit files
5+
systemctl daemon-reload || true
6+
47
# Once package is installed this script will called to enable the service
58
systemctl enable cos-csi-mounter.service
69
systemctl start cos-csi-mounter.service

cos-csi-mounter/server/rclone.go

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
7+
"go.uber.org/zap"
8+
)
9+
10+
type RCloneArgs struct {
11+
AllowOther string `json:"allow-other,omitempty"`
12+
AllowRoot string `json:"allow-root,omitempty"`
13+
AsyncRead string `json:"async-read,omitempty"`
14+
AttrTimeout string `json:"attr-timeout,omitempty"`
15+
ConfigPath string `json:"config,omitempty"`
16+
Daemon string `json:"daemon,omitempty"`
17+
DaemonTimeout string `json:"daemon-timeout,omitempty"`
18+
DaemonWait string `json:"daemon-wait,omitempty"`
19+
DirCacheTime string `json:"dir-cache-time,omitempty"`
20+
DirectIO string `json:"direct-io,omitempty"`
21+
GID string `json:"gid,omitempty"`
22+
LogFile string `json:"log-file,omitempty"`
23+
NoModificationTime string `json:"no-modtime,omitempty"`
24+
PollInterval string `json:"poll-interval,omitempty"`
25+
ReadOnly string `json:"read-only,omitempty"`
26+
UID string `json:"uid,omitempty"`
27+
UMask string `json:"umask,omitempty"`
28+
VfsCacheMaxAge string `json:"vfs-cache-max-age,omitempty"`
29+
VfsCacheMaxSize string `json:"vfs-cache-max-size,omitempty"`
30+
VfsCacheMinFreeSpace string `json:"vfs-cache-min-free-space,omitempty"`
31+
VfsCacheMode string `json:"vfs-cache-mode,omitempty"`
32+
VfsCachePollInterval string `json:"vfs-cache-poll-interval,omitempty"`
33+
VfsDiskSpaceTotalSize string `json:"vfs-disk-space-total-size,omitempty"`
34+
VfsReadAhead string `json:"vfs-read-ahead,omitempty"`
35+
VfsReadChunkSize string `json:"vfs-read-chunk-size,omitempty"`
36+
VfsReadChunkSizeLimit string `json:"vfs-read-chunk-size-limit,omitempty"`
37+
VfsReadChunkStreams string `json:"vfs-read-chunk-streams,omitempty"`
38+
VfsReadWait string `json:"vfs-read-wait,omitempty"`
39+
VfsRefresh string `json:"vfs-refresh,omitempty"`
40+
VfsWriteBack string `json:"vfs-write-back,omitempty"`
41+
VfsWriteWait string `json:"vfs-write-wait,omitempty"`
42+
WriteBackCache string `json:"write-back-cache,omitempty"`
43+
}
44+
45+
func (args RCloneArgs) PopulateArgsSlice(bucket, targetPath string) ([]string, error) {
46+
// Marshal to JSON
47+
raw, err := json.Marshal(args)
48+
if err != nil {
49+
return nil, err
50+
}
51+
52+
// Unmarshal into map[string]string
53+
var m map[string]string
54+
if err := json.Unmarshal(raw, &m); err != nil {
55+
return nil, err
56+
}
57+
58+
// Convert to key=value slice
59+
result := []string{"mount", bucket, targetPath}
60+
for k, v := range m {
61+
result = append(result, fmt.Sprintf("--%s=%v", k, v)) // --key=value
62+
}
63+
64+
return result, nil // [mount, bucket, path, --key1=value1, --key2=value2, ...]
65+
}
66+
67+
func (args RCloneArgs) Validate(targetPath string) error {
68+
if err := pathValidator(targetPath); err != nil {
69+
return err
70+
}
71+
72+
// Check if value of allow-other parameter is boolean "true" or "false"
73+
if args.AllowOther != "" {
74+
if isBool := isBoolString(args.AllowOther); !isBool {
75+
logger.Error("cannot convert value of allow-other into boolean", zap.Any("allow-other", args.AllowOther))
76+
return fmt.Errorf("cannot convert value of allow-other into boolean: %v", args.AllowOther)
77+
}
78+
}
79+
80+
// Check if value of allow-root parameter is boolean "true" or "false"
81+
if args.AllowRoot != "" {
82+
if isBool := isBoolString(args.AllowRoot); !isBool {
83+
logger.Error("cannot convert value of allow-root into boolean", zap.Any("allow-root", args.AllowRoot))
84+
return fmt.Errorf("cannot convert value of allow-root into boolean: %v", args.AllowRoot)
85+
}
86+
}
87+
88+
// Check if value of async-read parameter is boolean "true" or "false"
89+
if args.AsyncRead != "" {
90+
if isBool := isBoolString(args.AsyncRead); !isBool {
91+
logger.Error("cannot convert value of async-read into boolean", zap.Any("async-read", args.AsyncRead))
92+
return fmt.Errorf("cannot convert value of async-read into boolean: %v", args.AsyncRead)
93+
}
94+
}
95+
96+
// Check if rclone config file exists or not
97+
if exists, err := fileExists(args.ConfigPath); err != nil {
98+
logger.Error("error checking rclone config file existence")
99+
return fmt.Errorf("error checking rclone config file existence")
100+
} else if !exists {
101+
logger.Error("rclone config file not found")
102+
return fmt.Errorf("rclone config file not found")
103+
}
104+
105+
// Check if value of daemon parameter is boolean "true" or "false"
106+
if args.Daemon != "" {
107+
if isBool := isBoolString(args.Daemon); !isBool {
108+
logger.Error("cannot convert value of daemon into boolean", zap.Any("daemon", args.Daemon))
109+
return fmt.Errorf("cannot convert value of daemon into boolean: %v", args.Daemon)
110+
}
111+
}
112+
113+
// Check if value of direct-io parameter is boolean "true" or "false"
114+
if args.DirectIO != "" {
115+
if isBool := isBoolString(args.DirectIO); !isBool {
116+
logger.Error("cannot convert value of direct-io into boolean", zap.Any("direct-io", args.DirectIO))
117+
return fmt.Errorf("cannot convert value of direct-io into boolean: %v", args.DirectIO)
118+
}
119+
}
120+
121+
// Check if value of no-modtime parameter is boolean "true" or "false"
122+
if args.NoModificationTime != "" {
123+
if isBool := isBoolString(args.NoModificationTime); !isBool {
124+
logger.Error("cannot convert value of no-modtime into boolean", zap.Any("no-modtime", args.NoModificationTime))
125+
return fmt.Errorf("cannot convert value of no-modtime into boolean: %v", args.NoModificationTime)
126+
}
127+
}
128+
129+
// Check if value of read-only parameter is boolean "true" or "false"
130+
if args.ReadOnly != "" {
131+
if isBool := isBoolString(args.ReadOnly); !isBool {
132+
logger.Error("cannot convert value of read-only into boolean", zap.Any("read-only", args.ReadOnly))
133+
return fmt.Errorf("cannot convert value of read-only into boolean: %v", args.ReadOnly)
134+
}
135+
}
136+
137+
// Check if value of vfs-refresh parameter is boolean "true" or "false"
138+
if args.VfsRefresh != "" {
139+
if isBool := isBoolString(args.VfsRefresh); !isBool {
140+
logger.Error("cannot convert value of vfs-refresh into boolean", zap.Any("vfs-refresh", args.VfsRefresh))
141+
return fmt.Errorf("cannot convert value of vfs-refresh into boolean: %v", args.VfsRefresh)
142+
}
143+
}
144+
145+
// Check if value of write-back-cache parameter is boolean "true" or "false"
146+
if args.WriteBackCache != "" {
147+
if isBool := isBoolString(args.WriteBackCache); !isBool {
148+
logger.Error("cannot convert value of write-back-cache into boolean", zap.Any("write-back-cache", args.WriteBackCache))
149+
return fmt.Errorf("cannot convert value of write-back-cache into boolean: %v", args.WriteBackCache)
150+
}
151+
}
152+
153+
return nil
154+
}

0 commit comments

Comments
 (0)