upgrade to latest dependencies (#572)

bumping knative.dev/pkg 5708c4c...d016976:
  > d016976 Update community files (# 2353)
  > b35fcdd kmap changes (# 2355)
  > a99300d kmap (# 2354)

Signed-off-by: Knative Automation <automation@knative.team>
This commit is contained in:
knative-automation 2021-11-21 22:52:13 -08:00 committed by GitHub
parent 77b107b17f
commit d34fbbcce6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 172 additions and 37 deletions

2
go.mod
View File

@ -20,5 +20,5 @@ require (
k8s.io/code-generator v0.21.4
k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7
knative.dev/hack v0.0.0-20211117134436-69a2295d54ce
knative.dev/pkg v0.0.0-20211117215328-5708c4c44232
knative.dev/pkg v0.0.0-20211120133512-d016976f2567
)

4
go.sum
View File

@ -1133,8 +1133,8 @@ k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
knative.dev/hack v0.0.0-20211112192837-128cf0150a69/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/hack v0.0.0-20211117134436-69a2295d54ce h1:dPARWsX/9nmWg9g09MtGnsn7nZUwjA0UWpKSUozgS6g=
knative.dev/hack v0.0.0-20211117134436-69a2295d54ce/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/pkg v0.0.0-20211117215328-5708c4c44232 h1:mye0h0gL0sI2YraL1X5FjyfQZoYVaaaRemTJq+uw+/8=
knative.dev/pkg v0.0.0-20211117215328-5708c4c44232/go.mod h1:VqUp1KWJqpTDNoiSI/heaX3uMdubImslJE2tBkP+Bbw=
knative.dev/pkg v0.0.0-20211120133512-d016976f2567 h1:IPQ6QKOvMIRX9/UI1cAtSl36+CbGv8HErSvID03CRr4=
knative.dev/pkg v0.0.0-20211120133512-d016976f2567/go.mod h1:VqUp1KWJqpTDNoiSI/heaX3uMdubImslJE2tBkP+Bbw=
pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=

View File

@ -21,7 +21,7 @@ import (
"knative.dev/pkg/apis"
"knative.dev/pkg/apis/duck/ducktypes"
"knative.dev/pkg/kmeta"
"knative.dev/pkg/kmap"
)
// +genduck
@ -92,8 +92,7 @@ func (s *Status) GetCondition(t apis.ConditionType) *apis.Condition {
func (s *Status) ConvertTo(ctx context.Context, sink *Status, predicates ...func(apis.ConditionType) bool) {
sink.ObservedGeneration = s.ObservedGeneration
if s.Annotations != nil {
// This will deep copy the map.
sink.Annotations = kmeta.UnionMaps(s.Annotations)
sink.Annotations = kmap.Union(s.Annotations)
}
conditions := make(apis.Conditions, 0, len(s.Conditions))

77
vendor/knative.dev/pkg/kmap/lookup.go vendored Normal file
View File

@ -0,0 +1,77 @@
/*
Copyright 2021 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package kmap
// KeyPriority is a utility struct for getting values from a map
// given a list of ordered keys
//
// This is to help the migration/renaming of annotations & labels
type KeyPriority []string
// Key returns the default key that should be used for
// accessing the map
func (p KeyPriority) Key() string {
// this intentionally panics rather than returning an empty string
return p[0]
}
// Value iterates looks up the ordered keys in the map and returns
// a string value. An empty string will be returned if the keys
// are not present in the map
func (p KeyPriority) Value(m map[string]string) string {
_, v, _ := p.Get(m)
return v
}
// Get iterates over the ordered keys and looks up the corresponding
// values in the map
//
// It returns the key, value, and true|false signaling whether the
// key was present in the map
//
// If no key is present the default key (lowest ordinal) is returned
// with an empty string as the value
func (p KeyPriority) Get(m map[string]string) (string, string, bool) {
var k, v string
var ok bool
for _, k = range p {
v, ok = m[k]
if ok {
return k, v, ok
}
}
return p.Key(), "", false
}
// UpdateKey will update the map with the KeyPriority's default
// key iff any of the other synonym keys are present
func (p KeyPriority) UpdateKey(m map[string]string) {
if k, v, ok := p.Get(m); ok && k != p.Key() {
delete(m, k)
m[p.Key()] = v
}
}
// UpdateKeys iterates over the lookups and updates entries in the map
// to use the default key
func UpdateKeys(m map[string]string, keys ...KeyPriority) map[string]string {
for _, key := range keys {
key.UpdateKey(m)
}
return m
}

80
vendor/knative.dev/pkg/kmap/map.go vendored Normal file
View File

@ -0,0 +1,80 @@
/*
Copyright 2021 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package kmap
// Copy makes a copy of the map.
func Copy(a map[string]string) map[string]string {
ret := make(map[string]string, len(a))
for k, v := range a {
ret[k] = v
}
return ret
}
// Union returns a map constructed from the union of input maps.
// where values from latter maps win.
func Union(maps ...map[string]string) map[string]string {
if len(maps) == 0 {
return map[string]string{}
}
out := make(map[string]string, len(maps[0]))
for _, m := range maps {
for k, v := range m {
out[k] = v
}
}
return out
}
// Filter creates a copy of the provided map, filtering out the elements
// that match `filter`.
// nil `filter` is accepted.
func Filter(in map[string]string, filter func(string) bool) map[string]string {
ret := make(map[string]string, len(in))
for k, v := range in {
if filter != nil && filter(k) {
continue
}
ret[k] = v
}
return ret
}
// ExcludeKeys creates a copy of the provided map filtering out the excluded `keys`
func ExcludeKeys(in map[string]string, keys ...string) map[string]string {
return ExcludeKeyList(in, keys)
}
// ExcludeKeyList creates a copy of the provided map filtering out excluded `keys`
func ExcludeKeyList(in map[string]string, keys []string) map[string]string {
ret := make(map[string]string, len(in))
outer:
for k, v := range in {
// opted to skip memory allocation (creating a set) in favour of
// looping since the places Knative will use this we typically
// exclude one or two keys
for _, excluded := range keys {
if k == excluded {
continue outer
}
}
ret[k] = v
}
return ret
}

View File

@ -16,41 +16,19 @@ limitations under the License.
package kmeta
import "knative.dev/pkg/kmap"
// CopyMap makes a copy of the map.
func CopyMap(a map[string]string) map[string]string {
ret := make(map[string]string, len(a))
for k, v := range a {
ret[k] = v
}
return ret
}
// Deprecated: use kmap.Copy
var CopyMap = kmap.Copy
// UnionMaps returns a map constructed from the union of input maps.
// where values from latter maps win.
func UnionMaps(maps ...map[string]string) map[string]string {
if len(maps) == 0 {
return map[string]string{}
}
out := make(map[string]string, len(maps[0]))
for _, m := range maps {
for k, v := range m {
out[k] = v
}
}
return out
}
// Deprecated: use kmap.Union
var UnionMaps = kmap.Union
// FilterMap creates a copy of the provided map, filtering out the elements
// that match `filter`.
// nil `filter` is accepted.
func FilterMap(in map[string]string, filter func(string) bool) map[string]string {
ret := make(map[string]string, len(in))
for k, v := range in {
if filter != nil && filter(k) {
continue
}
ret[k] = v
}
return ret
}
// Deprecated: use kmap.Filter
var FilterMap = kmap.Filter

3
vendor/modules.txt vendored
View File

@ -611,7 +611,7 @@ k8s.io/utils/trace
# knative.dev/hack v0.0.0-20211117134436-69a2295d54ce
## explicit
knative.dev/hack
# knative.dev/pkg v0.0.0-20211117215328-5708c4c44232
# knative.dev/pkg v0.0.0-20211120133512-d016976f2567
## explicit
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
@ -630,6 +630,7 @@ knative.dev/pkg/hack
knative.dev/pkg/hash
knative.dev/pkg/injection
knative.dev/pkg/injection/clients/dynamicclient
knative.dev/pkg/kmap
knative.dev/pkg/kmeta
knative.dev/pkg/kmp
knative.dev/pkg/leaderelection