本文整理匯總了Golang中k8s/io/kubernetes/pkg/api/v1.PersistentVolumeClaim.Annotations方法的典型用法代碼示例。如果您正苦於以下問題:Golang PersistentVolumeClaim.Annotations方法的具體用法?Golang PersistentVolumeClaim.Annotations怎麽用?Golang PersistentVolumeClaim.Annotations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/api/v1.PersistentVolumeClaim
的用法示例。
在下文中一共展示了PersistentVolumeClaim.Annotations方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newClaim
func newClaim(ns string, alpha bool) *v1.PersistentVolumeClaim {
claim := v1.PersistentVolumeClaim{
ObjectMeta: v1.ObjectMeta{
GenerateName: "pvc-",
Namespace: ns,
},
Spec: v1.PersistentVolumeClaimSpec{
AccessModes: []v1.PersistentVolumeAccessMode{
v1.ReadWriteOnce,
},
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceName(v1.ResourceStorage): resource.MustParse(requestedSize),
},
},
},
}
if alpha {
claim.Annotations = map[string]string{
storageutil.AlphaStorageClassAnnotation: "",
}
} else {
claim.Annotations = map[string]string{
storageutil.StorageClassAnnotation: "fast",
}
}
return &claim
}
示例2: newClaim
// newClaim returns a new claim with given attributes
func newClaim(name, claimUID, capacity, boundToVolume string, phase v1.PersistentVolumeClaimPhase, annotations ...string) *v1.PersistentVolumeClaim {
claim := v1.PersistentVolumeClaim{
ObjectMeta: v1.ObjectMeta{
Name: name,
Namespace: testNamespace,
UID: types.UID(claimUID),
ResourceVersion: "1",
},
Spec: v1.PersistentVolumeClaimSpec{
AccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce, v1.ReadOnlyMany},
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceName(v1.ResourceStorage): resource.MustParse(capacity),
},
},
VolumeName: boundToVolume,
},
Status: v1.PersistentVolumeClaimStatus{
Phase: phase,
},
}
// Make sure v1.GetReference(claim) works
claim.ObjectMeta.SelfLink = testapi.Default.SelfLink("pvc", name)
if len(annotations) > 0 {
claim.Annotations = make(map[string]string)
for _, a := range annotations {
switch a {
case storageutil.StorageClassAnnotation:
claim.Annotations[a] = "gold"
case annStorageProvisioner:
claim.Annotations[a] = mockPluginName
default:
claim.Annotations[a] = "yes"
}
}
}
// Bound claims must have proper Status.
if phase == v1.ClaimBound {
claim.Status.AccessModes = claim.Spec.AccessModes
// For most of the tests it's enough to copy claim's requested capacity,
// individual tests can adjust it using withExpectedCapacity()
claim.Status.Capacity = claim.Spec.Resources.Requests
}
return &claim
}