This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
results.go
139 lines (123 loc) · 4.55 KB
/
results.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package persistentvolumeclaims
import (
"github.com/huaweicloud/golangsdk"
"github.com/huaweicloud/golangsdk/pagination"
)
type PersistentVolumeClaim struct {
Kind string `json:"kind"`
ApiVersion string `json:"apiVersion"`
Metadata MetaResp `json:"metadata"`
Spec SpecResp `json:"spec"`
Status Status `json:"status"`
}
type MetaResp struct {
// The name of the Persistent Volume Claim.
Name string `json:"name"`
// The namespace where the Persistent Volume Claim is located.
Namespace string `json:"namespace"`
// An unstructured key value map stored with a resource that may be set by external tools to store and retrieve
// arbitrary metadata.
Annotations map[string]string `json:"annotations"`
// ID of the Persistent Volume Claim in UUID format.
UID string `json:"uid"`
// String that identifies the server's internal version of this object that can be used by clients to determine
// when objects have changed.
ResourceVersion string `json:"resourceVersion"`
// A timestamp representing the server time when this object was created.
CreationTimestamp string `json:"creationTimestamp"`
// SelfLink is a URL representing this object.
SelfLink string `json:"selfLink"`
// Map of string keys and values that can be used to organize and categorize (scope and select) objects.
Labels map[string]string `json:"labels"`
// Each finalizer string of array is an identifier for the responsible component that will remove the entry form
// the list.
Finalizers []string `json:"finalizers"`
// Enable identify whether the resource is available.
Enable bool `json:"enable"`
}
// The extra response of Persistent Volume are Capacity, FlexVolume, ClaimRef and PersistentVolumeReclaimPolicy.
type SpecResp struct {
// The name of the volume.
VolumeName string `json:"volumeName"`
// AccessModes contains the actual access modes the volume backing the PVC has.
AccessModes []string `json:"accessModes"`
// Resources represents the minimum resources the volume should have.
Resources ResourceRequirement `json:"resources"`
// Name of the storage class required by the claim.
StorageClassName string `json:"storageClassName"`
// Mode of the volume.
VolumeMode string `json:"volumeMode"`
// The capacity of the storage.
Capacity ResourceName `json:"capacity"`
// PersistentVolumeClaim.
FlexVolume FlexVolume `json:"flexVolume"`
// Part of a bi-directional binding between persistentVolume and persistentVolumeClaim.
ClaimRef ClaimRef `json:"claimRef"`
// Specifies what happens to a persistent volume when released form its claim.
PersistentVolumeReclaimPolicy string `json:"persistentVolumeReclaimPolicy"`
}
type FlexVolume struct {
Driver string `json:"driver"`
FsType string `json:"fsType"`
Options Options `json:"options"`
}
type Options struct {
// The type of the file system.
FsType string `json:"fsType"`
// ID of the volume.
VolumeID string `json:"volumeID"`
// The Shared path of the SFS and the SFS Turbo.
DeviceMountPath string `json:"deviceMountPath"`
}
type ClaimRef struct {
// Kind of the referent.
Kind string `json:"kind"`
// Namespace of the referent.
Namespace string `json:"namespace"`
// Name of the referent.
Name string `json:"name"`
// UID of the referent.
UID string `json:"uid"`
// API version of the referent.
AapiVersion string `json:"apiVersion"`
// Specifies resource version to which this reference is made, If any.
ResourceVersion string `json:"resourceVersion"`
}
type Status struct {
// Phase represents the current phase of persistentVolumeClaim.
// pending: used for PersistentVolumeClaims that are not yet bound.
// Bound: used for PersistentVolumeClaims that are bound.
// Lost: used for PersistentVolumeClaims that lost their underlying.
Phase string `json:"phase"`
}
type commonResult struct {
golangsdk.Result
}
type CreateResult struct {
commonResult
}
func (r commonResult) Extract() (*PersistentVolumeClaim, error) {
var s PersistentVolumeClaim
err := r.ExtractInto(&s)
return &s, err
}
type ListResp struct {
PersistentVolumeClaim PersistentVolumeClaim `json:"persistentVolumeClaim"`
PersistentVolume PersistentVolumeClaim `json:"persistentVolume"`
}
type PersistentVolumeClaimPage struct {
pagination.SinglePageBase
}
func ExtractPersistentVolumeClaims(r pagination.Page) ([]ListResp, error) {
var s []ListResp
err := r.(PersistentVolumeClaimPage).Result.ExtractIntoSlicePtr(&s, "")
return s, err
}
type DeleteResult struct {
commonResult
}
func (r DeleteResult) Extract() ([]PersistentVolumeClaim, error) {
var s []PersistentVolumeClaim
err := r.ExtractInto(&s)
return s, err
}