@@ -42,9 +42,12 @@ const snapshotGroup = "snapshot.storage.k8s.io"
42
42
const snapshotAPIVersion = "snapshot.storage.k8s.io/v1beta1"
43
43
44
44
var (
45
- snapshotGVR = schema.GroupVersionResource {Group : snapshotGroup , Version : "v1beta1" , Resource : "volumesnapshots" }
46
- snapshotClassGVR = schema.GroupVersionResource {Group : snapshotGroup , Version : "v1beta1" , Resource : "volumesnapshotclasses" }
47
- snapshotContentGVR = schema.GroupVersionResource {Group : snapshotGroup , Version : "v1beta1" , Resource : "volumesnapshotcontents" }
45
+ // SnapshotGVR is GroupVersionResource for volumesnapshots
46
+ SnapshotGVR = schema.GroupVersionResource {Group : snapshotGroup , Version : "v1beta1" , Resource : "volumesnapshots" }
47
+ // SnapshotClassGVR is GroupVersionResource for volumesnapshotclasses
48
+ SnapshotClassGVR = schema.GroupVersionResource {Group : snapshotGroup , Version : "v1beta1" , Resource : "volumesnapshotclasses" }
49
+ // SnapshotContentGVR is GroupVersionResource for volumesnapshotcontents
50
+ SnapshotContentGVR = schema.GroupVersionResource {Group : snapshotGroup , Version : "v1beta1" , Resource : "volumesnapshotcontents" }
48
51
)
49
52
50
53
type snapshottableTestSuite struct {
@@ -167,22 +170,22 @@ func (s *snapshottableTestSuite) DefineTests(driver TestDriver, pattern testpatt
167
170
framework .ExpectNoError (err )
168
171
169
172
ginkgo .By ("creating a SnapshotClass" )
170
- vsc , err = dc .Resource (snapshotClassGVR ).Create (vsc , metav1.CreateOptions {})
173
+ vsc , err = dc .Resource (SnapshotClassGVR ).Create (vsc , metav1.CreateOptions {})
171
174
framework .ExpectNoError (err )
172
175
defer func () {
173
176
framework .Logf ("deleting SnapshotClass %s" , vsc .GetName ())
174
- framework .ExpectNoError (dc .Resource (snapshotClassGVR ).Delete (vsc .GetName (), nil ))
177
+ framework .ExpectNoError (dc .Resource (SnapshotClassGVR ).Delete (vsc .GetName (), nil ))
175
178
}()
176
179
177
180
ginkgo .By ("creating a snapshot" )
178
181
snapshot := getSnapshot (pvc .Name , pvc .Namespace , vsc .GetName ())
179
182
180
- snapshot , err = dc .Resource (snapshotGVR ).Namespace (snapshot .GetNamespace ()).Create (snapshot , metav1.CreateOptions {})
183
+ snapshot , err = dc .Resource (SnapshotGVR ).Namespace (snapshot .GetNamespace ()).Create (snapshot , metav1.CreateOptions {})
181
184
framework .ExpectNoError (err )
182
185
defer func () {
183
186
framework .Logf ("deleting snapshot %q/%q" , snapshot .GetNamespace (), snapshot .GetName ())
184
187
// typically this snapshot has already been deleted
185
- err = dc .Resource (snapshotGVR ).Namespace (snapshot .GetNamespace ()).Delete (snapshot .GetName (), nil )
188
+ err = dc .Resource (SnapshotGVR ).Namespace (snapshot .GetNamespace ()).Delete (snapshot .GetName (), nil )
186
189
if err != nil && ! apierrors .IsNotFound (err ) {
187
190
framework .Failf ("Error deleting snapshot %q. Error: %v" , pvc .Name , err )
188
191
}
@@ -192,13 +195,13 @@ func (s *snapshottableTestSuite) DefineTests(driver TestDriver, pattern testpatt
192
195
193
196
ginkgo .By ("checking the snapshot" )
194
197
// Get new copy of the snapshot
195
- snapshot , err = dc .Resource (snapshotGVR ).Namespace (snapshot .GetNamespace ()).Get (snapshot .GetName (), metav1.GetOptions {})
198
+ snapshot , err = dc .Resource (SnapshotGVR ).Namespace (snapshot .GetNamespace ()).Get (snapshot .GetName (), metav1.GetOptions {})
196
199
framework .ExpectNoError (err )
197
200
198
201
// Get the bound snapshotContent
199
202
snapshotStatus := snapshot .Object ["status" ].(map [string ]interface {})
200
203
snapshotContentName := snapshotStatus ["boundVolumeSnapshotContentName" ].(string )
201
- snapshotContent , err := dc .Resource (snapshotContentGVR ).Get (snapshotContentName , metav1.GetOptions {})
204
+ snapshotContent , err := dc .Resource (SnapshotContentGVR ).Get (snapshotContentName , metav1.GetOptions {})
202
205
framework .ExpectNoError (err )
203
206
204
207
snapshotContentSpec := snapshotContent .Object ["spec" ].(map [string ]interface {})
@@ -216,7 +219,7 @@ func (s *snapshottableTestSuite) DefineTests(driver TestDriver, pattern testpatt
216
219
func WaitForSnapshotReady (c dynamic.Interface , ns string , snapshotName string , Poll , timeout time.Duration ) error {
217
220
framework .Logf ("Waiting up to %v for VolumeSnapshot %s to become ready" , timeout , snapshotName )
218
221
for start := time .Now (); time .Since (start ) < timeout ; time .Sleep (Poll ) {
219
- snapshot , err := c .Resource (snapshotGVR ).Namespace (ns ).Get (snapshotName , metav1.GetOptions {})
222
+ snapshot , err := c .Resource (SnapshotGVR ).Namespace (ns ).Get (snapshotName , metav1.GetOptions {})
220
223
if err != nil {
221
224
framework .Logf ("Failed to get claim %q, retrying in %v. Error: %v" , snapshotName , Poll , err )
222
225
continue
0 commit comments