-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_data.go
58 lines (50 loc) · 1.47 KB
/
test_data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package installer
import (
"github.com/rook/rook/tests/framework/utils"
)
func BlockResourceOperation(k8sh *utils.K8sHelper, yaml string, action string) (string, error) {
return k8sh.ResourceOperation(action, yaml)
}
func GetBlockPoolDef(poolName string, namespace string, replicaSize string) string {
return `apiVersion: rook.io/v1alpha1
kind: Pool
metadata:
name: ` + poolName + `
namespace: ` + namespace + `
spec:
replicated:
size: ` + replicaSize
}
func GetBlockStorageClassDef(poolName string, storageClassName string, namespace string) string {
return `apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ` + storageClassName + `
provisioner: rook.io/block
parameters:
pool: ` + poolName + `
clusterName: ` + namespace
}
func GetBlockPvcDef(claimName string, storageClassName string) string {
return `apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ` + claimName + `
annotations:
volume.beta.kubernetes.io/storage-class: ` + storageClassName + `
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1M`
}
func concatYaml(first, second string) string {
return first + `
---
` + second
}
func GetBlockPoolStorageClassAndPvcDef(namespace string, poolName string, storageClassName string, blockName string) string {
return concatYaml(GetBlockPoolDef(poolName, namespace, "1"),
concatYaml(GetBlockStorageClassDef(poolName, storageClassName, namespace), GetBlockPvcDef(blockName, storageClassName)))
}