Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 05eba5b

Browse files
author
Dongsu Park
committed
fleetctl: make list-machines print out metadata operators
fleetctl list-machines should distinguish normal metadata from metadata with operators, to print out human-readable messages.
1 parent a110b45 commit 05eba5b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

fleetctl/list_machines.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ func formatMetadata(metadata map[string]string) string {
123123
sorted.Sort()
124124
for _, key := range sorted {
125125
value := metadata[key]
126-
pairs[idx] = fmt.Sprintf("%s=%s", key, value)
126+
if hasMetadataOperator(value) {
127+
pairs[idx] = fmt.Sprintf("%s%s", key, value)
128+
} else {
129+
pairs[idx] = fmt.Sprintf("%s=%s", key, value)
130+
}
127131
idx++
128132
}
129133
return strings.Join(pairs, ",")
@@ -135,3 +139,12 @@ func machineToFieldKeys(m map[string]machineToField) (keys []string) {
135139
}
136140
return
137141
}
142+
143+
func hasMetadataOperator(instr string) bool {
144+
for _, op := range []string{"<=", ">=", "!=", "==", "<", ">"} {
145+
if strings.HasPrefix(instr, op) {
146+
return true
147+
}
148+
}
149+
return false
150+
}

0 commit comments

Comments
 (0)