PV & PVC Client implementation
This commit is contained in:
@@ -68,6 +68,10 @@ func DescriberFor(kind string, c *client.Client) (Describer, bool) {
|
||||
return &ReplicationControllerDescriber{c}, true
|
||||
case "Service":
|
||||
return &ServiceDescriber{c}, true
|
||||
case "PersistentVolume":
|
||||
return &PersistentVolumeDescriber{c}, true
|
||||
case "PersistentVolumeClaim":
|
||||
return &PersistentVolumeClaimDescriber{c}, true
|
||||
case "Minion", "Node":
|
||||
return &NodeDescriber{c}, true
|
||||
case "LimitRange":
|
||||
@@ -269,6 +273,49 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
|
||||
})
|
||||
}
|
||||
|
||||
type PersistentVolumeDescriber struct {
|
||||
client.Interface
|
||||
}
|
||||
|
||||
func (d *PersistentVolumeDescriber) Describe(namespace, name string) (string, error) {
|
||||
c := d.PersistentVolumes()
|
||||
|
||||
pv, err := c.Get(name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", pv.Name)
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pv.Labels))
|
||||
fmt.Fprintf(out, "Status:\t%d\n", pv.Status.Phase)
|
||||
fmt.Fprintf(out, "Claim:\t%d\n", pv.Spec.ClaimRef.UID)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
type PersistentVolumeClaimDescriber struct {
|
||||
client.Interface
|
||||
}
|
||||
|
||||
func (d *PersistentVolumeClaimDescriber) Describe(namespace, name string) (string, error) {
|
||||
c := d.PersistentVolumeClaims(namespace)
|
||||
|
||||
psd, err := c.Get(name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", psd.Name)
|
||||
fmt.Fprintf(out, "Status:\t%d\n", psd.Status.Phase)
|
||||
fmt.Fprintf(out, "Volume:\t%d\n", psd.Status.VolumeRef.UID)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func describeContainers(containers []api.ContainerStatus, out io.Writer) {
|
||||
for _, container := range containers {
|
||||
fmt.Fprintf(out, " %v:\n", container.Name)
|
||||
|
Reference in New Issue
Block a user