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

Commit 2c76ec0

Browse files
author
Dongsu Park
committed
fleetd: support also "==" operator for metadata
To follow the maintainer's suggestion, also support the operator "==", which is actually the same as "=".
1 parent af6c3ff commit 2c76ec0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

job/job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func (j *Job) RequiredTargetMetadata() map[string]pkg.Set {
285285
} {
286286
for _, valuePair := range j.requirements()[key] {
287287
var s []string
288-
for _, sep := range []string{"<=", ">=", "!=", "<", ">"} {
288+
for _, sep := range []string{"==", "<=", ">=", "!=", "<", ">"} {
289289
index := strings.Index(valuePair, sep)
290290
if index != -1 {
291291
s = []string{valuePair[0:index], valuePair[index:]}

machine/machine.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ func HasMetadata(state *MachineState, metadata map[string]pkg.Set) bool {
111111
log.Debugf("Local Metadata(%s) does not match requirement", key)
112112
return false
113113
}
114+
} else if index := strings.Index(v, "=="); strings.Contains(v, "==") && (index == 0) {
115+
if v[2:] == local {
116+
log.Debugf("Local Metadata(%s) meets requirement", key)
117+
continue
118+
} else {
119+
log.Debugf("Local Metadata(%s) does not match requirement", key)
120+
return false
121+
}
114122
} else {
115123
log.Debugf("Local Metadata(%s) does not match requirement", key)
116124
return false

0 commit comments

Comments
 (0)