feat(cli): display devcontainers in show command (#16515)

Displays running devcontainers into the `coder show` CLI command.
This commit is contained in:
Cian Johnston
2025-02-11 09:20:55 +00:00
committed by GitHub
parent 72f62578c1
commit 4867cbe53d
5 changed files with 121 additions and 19 deletions
+6 -1
View File
@@ -8,9 +8,14 @@ import (
// Subset returns true if all the keys of a are present
// in b and have the same values.
// If the corresponding value of a[k] is the zero value in
// b, Subset will skip comparing that value.
// This allows checking for the presence of map keys.
func Subset[T, U comparable](a, b map[T]U) bool {
var uz U
for ka, va := range a {
if vb, ok := b[ka]; !ok || va != vb {
ignoreZeroValue := va == uz
if vb, ok := b[ka]; !ok || (!ignoreZeroValue && va != vb) {
return false
}
}
+21 -2
View File
@@ -11,8 +11,9 @@ func TestSubset(t *testing.T) {
t.Parallel()
for idx, tc := range []struct {
a map[string]string
b map[string]string
a map[string]string
b map[string]string
// expected value from Subset
expected bool
}{
{
@@ -50,6 +51,24 @@ func TestSubset(t *testing.T) {
b: map[string]string{"a": "1", "b": "3"},
expected: false,
},
// Zero value
{
a: map[string]string{"a": "1", "b": ""},
b: map[string]string{"a": "1", "b": "3"},
expected: true,
},
// Zero value, but the other way round
{
a: map[string]string{"a": "1", "b": "3"},
b: map[string]string{"a": "1", "b": ""},
expected: false,
},
// Both zero values
{
a: map[string]string{"a": "1", "b": ""},
b: map[string]string{"a": "1", "b": ""},
expected: true,
},
} {
tc := tc
t.Run("#"+strconv.Itoa(idx), func(t *testing.T) {