Skip to content

Commit

Permalink
Merge pull request kubernetes#42575 from MaciekPytel/show_configmap_e…
Browse files Browse the repository at this point in the history
…vents

Automatic merge from submit-queue

Include events when describing configmap

**What this PR does / why we need it**:
Currently `kubectl describe configmap/xxx` does not list events, even if there are events related to this congfigmap (and --show-events=true is explicitly passed). This PR makes it include events, same as for other resource types.
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*:

**Special notes for your reviewer**:

**Release note**:

```release-note
```
  • Loading branch information
Kubernetes Submit Queue authored Apr 4, 2017
2 parents a8e5528 + 8551049 commit 2e6616d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/printers/internalversion/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -2564,10 +2564,6 @@ func (d *ConfigMapDescriber) Describe(namespace, name string, describerSettings
return "", err
}

return describeConfigMap(configMap)
}

func describeConfigMap(configMap *api.ConfigMap) (string, error) {
return tabbedString(func(out io.Writer) error {
w := NewPrefixWriter(out)
w.Write(LEVEL_0, "Name:\t%s\n", configMap.Name)
Expand All @@ -2580,7 +2576,15 @@ func describeConfigMap(configMap *api.ConfigMap) (string, error) {
w.Write(LEVEL_0, "%s:\n----\n", k)
w.Write(LEVEL_0, "%s\n", string(v))
}

if describerSettings.ShowEvents {
events, err := d.Core().Events(namespace).Search(api.Scheme, configMap)
if err != nil {
return err
}
if events != nil {
DescribeEvents(events, w)
}
}
return nil
})
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/printers/internalversion/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,14 @@ func TestDescribeEvents(t *testing.T) {
},
}, events),
},
"ConfigMap": &ConfigMapDescriber{
fake.NewSimpleClientset(&api.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "bar",
Namespace: "foo",
},
}, events),
},
}

for name, d := range m {
Expand Down

0 comments on commit 2e6616d

Please sign in to comment.