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

Commit

Permalink
fleetctl: make list-machines print out metadata operators
Browse files Browse the repository at this point in the history
fleetctl list-machines should distinguish normal metadata from metadata
with operators, to print out human-readable messages.
  • Loading branch information
Dongsu Park committed Jul 13, 2016
1 parent a110b45 commit 05eba5b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion fleetctl/list_machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ func formatMetadata(metadata map[string]string) string {
sorted.Sort()
for _, key := range sorted {
value := metadata[key]
pairs[idx] = fmt.Sprintf("%s=%s", key, value)
if hasMetadataOperator(value) {
pairs[idx] = fmt.Sprintf("%s%s", key, value)
} else {
pairs[idx] = fmt.Sprintf("%s=%s", key, value)
}
idx++
}
return strings.Join(pairs, ",")
Expand All @@ -135,3 +139,12 @@ func machineToFieldKeys(m map[string]machineToField) (keys []string) {
}
return
}

func hasMetadataOperator(instr string) bool {
for _, op := range []string{"<=", ">=", "!=", "==", "<", ">"} {
if strings.HasPrefix(instr, op) {
return true
}
}
return false
}

0 comments on commit 05eba5b

Please sign in to comment.