本文整理汇总了Golang中k8s/io/kubernetes/pkg/volume.GetAccessModesAsString函数的典型用法代码示例。如果您正苦于以下问题:Golang GetAccessModesAsString函数的具体用法?Golang GetAccessModesAsString怎么用?Golang GetAccessModesAsString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetAccessModesAsString函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: printPersistentVolume
func printPersistentVolume(pv *api.PersistentVolume, w io.Writer, withNamespace bool, wide bool, columnLabels []string) error {
if withNamespace {
return fmt.Errorf("persistentVolume is not namespaced")
}
name := pv.Name
claimRefUID := ""
if pv.Spec.ClaimRef != nil {
claimRefUID += pv.Spec.ClaimRef.Namespace
claimRefUID += "/"
claimRefUID += pv.Spec.ClaimRef.Name
}
modesStr := volume.GetAccessModesAsString(pv.Spec.AccessModes)
aQty := pv.Spec.Capacity[api.ResourceStorage]
aSize := aQty.Value()
if _, err := fmt.Fprintf(w, "%s\t%s\t%d\t%s\t%s\t%s\t%s\t%s",
name,
formatLabels(pv.Labels),
aSize, modesStr,
pv.Status.Phase,
claimRefUID,
pv.Status.Reason,
translateTimestamp(pv.CreationTimestamp),
); err != nil {
return err
}
_, err := fmt.Fprint(w, appendLabels(pv.Labels, columnLabels))
return err
}
示例2: printPersistentVolumeClaim
func printPersistentVolumeClaim(pvc *api.PersistentVolumeClaim, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error {
name := pvc.Name
namespace := pvc.Namespace
if withNamespace {
if _, err := fmt.Fprintf(w, "%s\t", namespace); err != nil {
return err
}
}
labels := formatLabels(pvc.Labels)
phase := pvc.Status.Phase
storage := pvc.Spec.Resources.Requests[api.ResourceStorage]
capacity := ""
accessModes := ""
if pvc.Spec.VolumeName != "" {
accessModes = volume.GetAccessModesAsString(pvc.Status.AccessModes)
storage = pvc.Status.Capacity[api.ResourceStorage]
capacity = storage.String()
}
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s", name, labels, phase, pvc.Spec.VolumeName, capacity, accessModes, translateTimestamp(pvc.CreationTimestamp)); err != nil {
return err
}
_, err := fmt.Fprint(w, appendLabels(pvc.Labels, columnLabels))
return err
}
示例3: accessModesIndexFunc
// accessModesIndexFunc is an indexing function that returns a persistent volume's AccessModes as a string
func accessModesIndexFunc(obj interface{}) ([]string, error) {
if pv, ok := obj.(*api.PersistentVolume); ok {
modes := volume.GetAccessModesAsString(pv.Spec.AccessModes)
return []string{modes}, nil
}
return []string{""}, fmt.Errorf("object is not a persistent volume: %v", obj)
}
示例4: Describe
func (d *PersistentVolumeClaimDescriber) Describe(namespace, name string) (string, error) {
c := d.PersistentVolumeClaims(namespace)
pvc, err := c.Get(name)
if err != nil {
return "", err
}
labels := formatLabels(pvc.Labels)
storage := pvc.Spec.Resources.Requests[api.ResourceStorage]
capacity := ""
accessModes := ""
if pvc.Spec.VolumeName != "" {
accessModes = volume.GetAccessModesAsString(pvc.Status.AccessModes)
storage = pvc.Status.Capacity[api.ResourceStorage]
capacity = storage.String()
}
return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", pvc.Name)
fmt.Fprintf(out, "Namespace:\t%s\n", pvc.Namespace)
fmt.Fprintf(out, "Status:\t%v\n", pvc.Status.Phase)
fmt.Fprintf(out, "Volume:\t%s\n", pvc.Spec.VolumeName)
fmt.Fprintf(out, "Labels:\t%s\n", labels)
fmt.Fprintf(out, "Capacity:\t%s\n", capacity)
fmt.Fprintf(out, "Access Modes:\t%s\n", accessModes)
return nil
})
}
示例5: Describe
func (d *PersistentVolumeDescriber) Describe(namespace, name string) (string, error) {
c := d.PersistentVolumes()
pv, err := c.Get(name)
if err != nil {
return "", err
}
storage := pv.Spec.Capacity[api.ResourceStorage]
return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", pv.Name)
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(pv.Labels))
fmt.Fprintf(out, "Status:\t%s\n", pv.Status.Phase)
if pv.Spec.ClaimRef != nil {
fmt.Fprintf(out, "Claim:\t%s\n", pv.Spec.ClaimRef.Namespace+"/"+pv.Spec.ClaimRef.Name)
} else {
fmt.Fprintf(out, "Claim:\t%s\n", "")
}
fmt.Fprintf(out, "Reclaim Policy:\t%v\n", pv.Spec.PersistentVolumeReclaimPolicy)
fmt.Fprintf(out, "Access Modes:\t%s\n", volume.GetAccessModesAsString(pv.Spec.AccessModes))
fmt.Fprintf(out, "Capacity:\t%s\n", storage.String())
fmt.Fprintf(out, "Message:\t%s\n", pv.Status.Message)
fmt.Fprintf(out, "Source:\n")
switch {
case pv.Spec.HostPath != nil:
printHostPathVolumeSource(pv.Spec.HostPath, out)
case pv.Spec.GCEPersistentDisk != nil:
printGCEPersistentDiskVolumeSource(pv.Spec.GCEPersistentDisk, out)
case pv.Spec.AWSElasticBlockStore != nil:
printAWSElasticBlockStoreVolumeSource(pv.Spec.AWSElasticBlockStore, out)
case pv.Spec.NFS != nil:
printNFSVolumeSource(pv.Spec.NFS, out)
case pv.Spec.ISCSI != nil:
printISCSIVolumeSource(pv.Spec.ISCSI, out)
case pv.Spec.Glusterfs != nil:
printGlusterfsVolumeSource(pv.Spec.Glusterfs, out)
case pv.Spec.RBD != nil:
printRBDVolumeSource(pv.Spec.RBD, out)
}
return nil
})
}