@@ -42,6 +42,7 @@ type flexVolumePlugin struct {
42
42
runner exec.Interface
43
43
44
44
sync.Mutex
45
+ capabilities * driverCapabilities
45
46
unsupportedCommands []string
46
47
}
47
48
@@ -64,44 +65,30 @@ func NewFlexVolumePlugin(pluginDir, name string) (volume.VolumePlugin, error) {
64
65
unsupportedCommands : []string {},
65
66
}
66
67
67
- // Check whether the plugin is attachable.
68
- ok , err := isAttachable (flexPlugin )
68
+ // Retrieve driver reported capabilities
69
+ call := flexPlugin .NewDriverCall (initCmd )
70
+ ds , err := call .Run ()
69
71
if err != nil {
70
72
return nil , err
71
73
}
72
74
73
- if ok {
74
- // Plugin supports attach/detach, so return flexVolumeAttachablePlugin
75
+ driverCaps := ds .getDriverCapabilities ()
76
+ flexPlugin .capabilities = driverCaps
77
+
78
+ // Check whether the plugin is attachable.
79
+ if driverCaps .attach {
80
+ // Plugin supports attach/detach by default, so return flexVolumeAttachablePlugin
75
81
return & flexVolumeAttachablePlugin {flexVolumePlugin : flexPlugin }, nil
76
82
} else {
77
83
return flexPlugin , nil
78
84
}
79
85
}
80
86
81
- func isAttachable (plugin * flexVolumePlugin ) (bool , error ) {
82
- call := plugin .NewDriverCall (initCmd )
83
- res , err := call .Run ()
84
- if err != nil {
85
- return false , err
86
- }
87
-
88
- // By default all plugins are attachable, unless they report otherwise.
89
- cap , ok := res .Capabilities [attachCapability ]
90
- if ok {
91
- // cap is false, so plugin does not support attach/detach calls.
92
- return cap , nil
93
- }
94
-
95
- return true , nil
96
- }
97
-
98
87
// Init is part of the volume.VolumePlugin interface.
99
88
func (plugin * flexVolumePlugin ) Init (host volume.VolumeHost ) error {
100
89
plugin .host = host
101
- // call the init script
102
- call := plugin .NewDriverCall (initCmd )
103
- _ , err := call .Run ()
104
- return err
90
+ // Hardwired 'success' as any errors from calling init() will be caught by NewFlexVolumePlugin()
91
+ return nil
105
92
}
106
93
107
94
func (plugin * flexVolumePlugin ) getExecutable () string {
0 commit comments