@@ -23,53 +23,48 @@ import (
23
23
)
24
24
25
25
// Mounter interface defined in mounter.go
26
- // mntS3Mounter Implements Mounter
27
- type mntS3Mounter struct {
28
- bucketName string //From Secret in SC
29
- objPath string //From Secret in SC
30
- endPoint string //From Secret in SC
31
- locConstraint string //From Secret in SC
32
- authType string
33
- accessKey string
34
- secretKey string
35
- mountOptions []string
36
- MounterUtils utils.MounterUtils
26
+ // MountpointMounter Implements Mounter
27
+ type MountpointMounter struct {
28
+ BucketName string //From Secret in SC
29
+ ObjPath string //From Secret in SC
30
+ EndPoint string //From Secret in SC
31
+ AccessKey string
32
+ SecretKey string
33
+ MountOptions []string
34
+ MounterUtils utils.MounterUtils
37
35
}
38
36
39
- func NewMntS3Mounter (secretMap map [string ]string , mountOptions []string , mounterUtils utils.MounterUtils ) Mounter {
40
- klog .Info ("-newMntS3Mounter -" )
37
+ func NewMountpointMounter (secretMap map [string ]string , mountOptions []string , mounterUtils utils.MounterUtils ) Mounter {
38
+ klog .Info ("-newMountpointMounter -" )
41
39
42
40
var (
43
41
val string
44
42
check bool
45
- mounter * mntS3Mounter
43
+ mounter * MountpointMounter
46
44
)
47
45
48
- mounter = & mntS3Mounter {}
46
+ mounter = & MountpointMounter {}
49
47
50
48
if val , check = secretMap ["cosEndpoint" ]; check {
51
- mounter .endPoint = val
52
- }
53
- if val , check = secretMap ["locationConstraint" ]; check {
54
- mounter .locConstraint = val
49
+ mounter .EndPoint = val
55
50
}
56
51
if val , check = secretMap ["bucketName" ]; check {
57
- mounter .bucketName = val
52
+ mounter .BucketName = val
58
53
}
59
54
if val , check = secretMap ["objPath" ]; check {
60
- mounter .objPath = val
55
+ mounter .ObjPath = val
61
56
}
62
57
if val , check = secretMap ["accessKey" ]; check {
63
- mounter .accessKey = val
58
+ mounter .AccessKey = val
64
59
}
65
60
if val , check = secretMap ["secretKey" ]; check {
66
- mounter .secretKey = val
61
+ mounter .SecretKey = val
67
62
}
68
63
69
- klog .Infof ("newMntS3Mounter args:\n \t bucketName: [%s]\n \t objPath: [%s]\n \t endPoint: [%s]\n \t locationConstraint: [%s] \n \t authType: [%s] " ,
70
- mounter .bucketName , mounter .objPath , mounter .endPoint , mounter . locConstraint , mounter . authType )
64
+ klog .Infof ("newMntS3Mounter args:\n \t bucketName: [%s]\n \t objPath: [%s]\n \t endPoint: [%s]" ,
65
+ mounter .BucketName , mounter .ObjPath , mounter .EndPoint )
71
66
72
- mounter .mountOptions = mountOptions
67
+ mounter .MountOptions = mountOptions
73
68
mounter .MounterUtils = mounterUtils
74
69
75
70
return mounter
@@ -80,48 +75,48 @@ const (
80
75
metaRootMntS3 = "/var/lib/ibmc-mntS3"
81
76
)
82
77
83
- func (mntS3 * mntS3Mounter ) Stage (stagePath string ) error {
78
+ func (mntS3 * MountpointMounter ) Stage (stagePath string ) error {
84
79
return nil
85
80
}
86
- func (mntS3 * mntS3Mounter ) Unstage (stagePath string ) error {
81
+ func (mntS3 * MountpointMounter ) Unstage (stagePath string ) error {
87
82
return nil
88
83
}
89
- func (mntS3 * mntS3Mounter ) Mount (source string , target string ) error {
90
- klog .Info ("-MntS3Mounter Mount-" )
84
+ func (mntS3 * MountpointMounter ) Mount (source string , target string ) error {
85
+ klog .Info ("-MountpointMounter Mount-" )
91
86
klog .Infof ("Mount args:\n \t source: <%s>\n \t target: <%s>" , source , target )
92
87
var pathExist bool
93
88
var err error
94
89
metaPath := path .Join (metaRootMntS3 , fmt .Sprintf ("%x" , sha256 .Sum256 ([]byte (target ))))
95
90
96
91
if pathExist , err = checkPath (metaPath ); err != nil {
97
- klog .Errorf ("MntS3Mounter Mount: Cannot stat directory %s: %v" , metaPath , err )
92
+ klog .Errorf ("MountpointMounter Mount: Cannot stat directory %s: %v" , metaPath , err )
98
93
return err
99
94
}
100
95
101
96
if ! pathExist {
102
- if err = os . MkdirAll (metaPath , 0755 ); // #nosec G301: used for mntS3
97
+ if err = mkdirAll (metaPath , 0755 ); // #nosec G301: used for mntS3
103
98
err != nil {
104
- klog .Errorf ("MntS3Mounter Mount: Cannot create directory %s: %v" , metaPath , err )
99
+ klog .Errorf ("MountpointMounter Mount: Cannot create directory %s: %v" , metaPath , err )
105
100
return err
106
101
}
107
102
}
108
103
109
- os .Setenv ("AWS_ACCESS_KEY_ID" , mntS3 .accessKey )
110
- os .Setenv ("AWS_SECRET_ACCESS_KEY" , mntS3 .secretKey )
104
+ os .Setenv ("AWS_ACCESS_KEY_ID" , mntS3 .AccessKey )
105
+ os .Setenv ("AWS_SECRET_ACCESS_KEY" , mntS3 .SecretKey )
111
106
112
107
args := []string {
113
- fmt .Sprintf ("--endpoint-url=%v" , mntS3 .endPoint ),
114
- mntS3 .bucketName ,
108
+ fmt .Sprintf ("--endpoint-url=%v" , mntS3 .EndPoint ),
109
+ mntS3 .BucketName ,
115
110
target ,
116
111
}
117
112
118
- if mntS3 .objPath != "" {
119
- args = append (args , fmt .Sprintf ("--prefix %s" , mntS3 .objPath ))
113
+ if mntS3 .ObjPath != "" {
114
+ args = append (args , fmt .Sprintf ("--prefix %s" , mntS3 .ObjPath ))
120
115
}
121
116
return mntS3 .MounterUtils .FuseMount (target , mntS3Cmd , args )
122
117
}
123
- func (mntS3 * mntS3Mounter ) Unmount (target string ) error {
124
- klog .Info ("-MntS3Mounter Unmount-" )
118
+ func (mntS3 * MountpointMounter ) Unmount (target string ) error {
119
+ klog .Info ("-MountpointMounter Unmount-" )
125
120
metaPath := path .Join (metaRootMntS3 , fmt .Sprintf ("%x" , sha256 .Sum256 ([]byte (target ))))
126
121
err := os .RemoveAll (metaPath )
127
122
if err != nil {
0 commit comments