@@ -22,8 +22,7 @@ import (
22
22
"path/filepath"
23
23
"runtime"
24
24
25
- . "github.com/onsi/ginkgo"
26
- . "github.com/onsi/ginkgo/extensions/table"
25
+ . "github.com/onsi/ginkgo/v2"
27
26
. "github.com/onsi/gomega"
28
27
"github.com/spf13/afero"
29
28
"github.com/spf13/cobra"
@@ -63,7 +62,7 @@ var _ = Describe("Discover external plugins", func() {
63
62
pluginFileName = "externalPlugin.sh"
64
63
pluginFilePath = filepath .Join (pluginPath , "externalPlugin" , "v1" , pluginFileName )
65
64
66
- err = fs .FS .MkdirAll (filepath .Dir (pluginFilePath ), 0700 )
65
+ err = fs .FS .MkdirAll (filepath .Dir (pluginFilePath ), 0o700 )
67
66
Expect (err ).To (BeNil ())
68
67
69
68
f , err = fs .FS .Create (pluginFilePath )
@@ -125,7 +124,6 @@ var _ = Describe("Discover external plugins", func() {
125
124
126
125
Expect (ps [0 ].Name ()).To (Equal ("externalPlugin" ))
127
126
Expect (ps [1 ].Name ()).To (Equal ("myotherexternalPlugin" ))
128
-
129
127
})
130
128
131
129
Context ("that are invalid" , func () {
@@ -136,14 +134,13 @@ var _ = Describe("Discover external plugins", func() {
136
134
137
135
pluginPath , err = getPluginsRoot (runtime .GOOS )
138
136
Expect (err ).To (BeNil ())
139
-
140
137
})
141
138
142
139
It ("should error if the plugin found is not an executable" , func () {
143
140
pluginFileName = "externalPlugin.sh"
144
141
pluginFilePath = filepath .Join (pluginPath , "externalPlugin" , "v1" , pluginFileName )
145
142
146
- err = fs .FS .MkdirAll (filepath .Dir (pluginFilePath ), 0700 )
143
+ err = fs .FS .MkdirAll (filepath .Dir (pluginFilePath ), 0o700 )
147
144
Expect (err ).To (BeNil ())
148
145
149
146
f , err := fs .FS .Create (pluginFilePath )
@@ -154,21 +151,20 @@ var _ = Describe("Discover external plugins", func() {
154
151
Expect (err ).To (BeNil ())
155
152
156
153
// set the plugin file permissions to read-only
157
- err = fs .FS .Chmod (pluginFilePath , 0444 )
154
+ err = fs .FS .Chmod (pluginFilePath , 0o444 )
158
155
Expect (err ).To (Not (HaveOccurred ()))
159
156
160
157
ps , err := DiscoverExternalPlugins (fs .FS )
161
158
Expect (err ).NotTo (BeNil ())
162
159
Expect (err .Error ()).To (ContainSubstring ("not an executable" ))
163
160
Expect (len (ps )).To (Equal (0 ))
164
-
165
161
})
166
162
167
163
It ("should error if the plugin found has an invalid plugin name" , func () {
168
164
pluginFileName = ".sh"
169
165
pluginFilePath = filepath .Join (pluginPath , "externalPlugin" , "v1" , pluginFileName )
170
166
171
- err = fs .FS .MkdirAll (filepath .Dir (pluginFilePath ), 0700 )
167
+ err = fs .FS .MkdirAll (filepath .Dir (pluginFilePath ), 0o700 )
172
168
Expect (err ).To (BeNil ())
173
169
174
170
f , err = fs .FS .Create (pluginFilePath )
@@ -179,7 +175,6 @@ var _ = Describe("Discover external plugins", func() {
179
175
Expect (err ).NotTo (BeNil ())
180
176
Expect (err .Error ()).To (ContainSubstring ("Invalid plugin name found" ))
181
177
Expect (len (ps )).To (Equal (0 ))
182
-
183
178
})
184
179
})
185
180
@@ -191,14 +186,13 @@ var _ = Describe("Discover external plugins", func() {
191
186
192
187
pluginPath , err = getPluginsRoot (runtime .GOOS )
193
188
Expect (err ).To (BeNil ())
194
-
195
189
})
196
190
197
191
It ("should skip adding the external plugin and not return any errors" , func () {
198
192
pluginFileName = "random.sh"
199
193
pluginFilePath = filepath .Join (pluginPath , "externalPlugin" , "v1" , pluginFileName )
200
194
201
- err = fs .FS .MkdirAll (filepath .Dir (pluginFilePath ), 0700 )
195
+ err = fs .FS .MkdirAll (filepath .Dir (pluginFilePath ), 0o700 )
202
196
Expect (err ).To (BeNil ())
203
197
204
198
f , err = fs .FS .Create (pluginFilePath )
@@ -211,11 +205,10 @@ var _ = Describe("Discover external plugins", func() {
211
205
ps , err := DiscoverExternalPlugins (fs .FS )
212
206
Expect (err ).To (BeNil ())
213
207
Expect (len (ps )).To (Equal (0 ))
214
-
215
208
})
216
209
217
210
It ("should fail if pluginsroot is empty" , func () {
218
- var errPluginsRoot = errors .New ("could not retrieve plugins root" )
211
+ errPluginsRoot : = errors .New ("could not retrieve plugins root" )
219
212
retrievePluginsRoot = func (host string ) (string , error ) {
220
213
return "" , errPluginsRoot
221
214
}
@@ -224,7 +217,6 @@ var _ = Describe("Discover external plugins", func() {
224
217
Expect (err ).NotTo (BeNil ())
225
218
226
219
Expect (err ).To (Equal (errPluginsRoot ))
227
-
228
220
})
229
221
230
222
It ("should fail for any other host that is not supported" , func () {
@@ -280,7 +272,6 @@ var _ = Describe("Discover external plugins", func() {
280
272
Expect (pluginsroot ).To (Equal ("" ))
281
273
Expect (err .Error ()).To (ContainSubstring ("error retrieving home dir" ))
282
274
})
283
-
284
275
})
285
276
})
286
277
@@ -323,7 +314,6 @@ var _ = Describe("Discover external plugins", func() {
323
314
})
324
315
325
316
var _ = Describe ("CLI options" , func () {
326
-
327
317
const (
328
318
pluginName = "plugin"
329
319
pluginVersion = "v1"
@@ -549,5 +539,4 @@ var _ = Describe("CLI options", func() {
549
539
Expect (c .completionCommand ).To (BeTrue ())
550
540
})
551
541
})
552
-
553
542
})
0 commit comments