mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Make deterministic
This commit is contained in:
parent
c27ad1390d
commit
3b980bd9dc
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package labels
|
package labels
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,6 +36,8 @@ func (ls Set) String() string {
|
|||||||
for key, value := range ls {
|
for key, value := range ls {
|
||||||
query = append(query, key+"="+value)
|
query = append(query, key+"="+value)
|
||||||
}
|
}
|
||||||
|
// Sort for determinism.
|
||||||
|
sort.StringSlice(query).Sort()
|
||||||
return strings.Join(query, ",")
|
return strings.Join(query, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ func matches(t *testing.T, ls Set, want string) {
|
|||||||
func TestSetString(t *testing.T) {
|
func TestSetString(t *testing.T) {
|
||||||
matches(t, Set{"x": "y"}, "x=y")
|
matches(t, Set{"x": "y"}, "x=y")
|
||||||
matches(t, Set{"foo": "bar"}, "foo=bar")
|
matches(t, Set{"foo": "bar"}, "foo=bar")
|
||||||
matches(t, Set{"foo": "bar", "baz": "qup"}, "foo=bar,baz=qup")
|
matches(t, Set{"foo": "bar", "baz": "qup"}, "baz=qup,foo=bar")
|
||||||
|
|
||||||
// TODO: Make our label representation robust enough to handel labels
|
// TODO: Make our label representation robust enough to handel labels
|
||||||
// with ",=!" characters in their names.
|
// with ",=!" characters in their names.
|
||||||
|
Loading…
Reference in New Issue
Block a user