Auto-update dependencies (#187)

Produced via:
  `dep ensure -update knative.dev/test-infra knative.dev/pkg`
/assign n3wscott
/cc n3wscott
This commit is contained in:
Matt Moore 2020-01-22 07:40:23 -08:00 committed by Knative Prow Robot
parent b404df2fb4
commit 853d602284
3 changed files with 68 additions and 6 deletions

6
Gopkg.lock generated
View File

@ -966,7 +966,7 @@
[[projects]]
branch = "master"
digest = "1:342e150dd5c3ce921be78ce3e8cbfb03aaf01b07a26258f39dc9e90caf277a2b"
digest = "1:6a467fb3198c259dffa78ca86c8b7acfdaa73db62439d21b135558c6dab76473"
name = "knative.dev/pkg"
packages = [
"apis",
@ -985,7 +985,7 @@
"metrics/metricskey",
]
pruneopts = "T"
revision = "96d3b8c24c34ea7a8d9da9e7dbb65610aa9ac7b0"
revision = "4e81bc3c320ff3e4ed0ab600963a8685b629c09e"
[[projects]]
branch = "master"
@ -996,7 +996,7 @@
"tools/dep-collector",
]
pruneopts = "UT"
revision = "aebda4a107f44e1622e9770cdd64ebfb382e3e53"
revision = "dfeb254e57938f9e30b179034e9833e196ec899f"
[[projects]]
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"

47
vendor/knative.dev/pkg/apis/convert.go vendored Normal file
View File

@ -0,0 +1,47 @@
/*
Copyright 2020 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 apis
import "context"
// ConvertUpViaProxy attempts to convert a specific source to a sink
// through a proxy
func ConvertUpViaProxy(
ctx context.Context,
source, proxy, sink Convertible,
) error {
if err := source.ConvertUp(ctx, proxy); err != nil {
return err
}
return proxy.ConvertUp(ctx, sink)
}
// ConvertDownViaProxy attempts to convert a specific sink from a source
// through a proxy
func ConvertDownViaProxy(
ctx context.Context,
source, proxy, sink Convertible,
) error {
if err := proxy.ConvertDown(ctx, source); err != nil {
return err
}
return sink.ConvertDown(ctx, proxy)
}

View File

@ -99,17 +99,32 @@ func (s *Status) GetCondition(t apis.ConditionType) *apis.Condition {
}
// ConvertTo helps implement apis.Convertible for types embedding this Status.
func (source *Status) ConvertTo(ctx context.Context, sink *Status) {
//
// By default apis.ConditionReady and apis.ConditionSucceeded will be copied over to the
// sink. Other conditions types are tested against a list of predicates. If any of the predicates
// return true the condition type will be copied to the sink
func (source *Status) ConvertTo(ctx context.Context, sink *Status, predicates ...func(apis.ConditionType) bool) {
sink.ObservedGeneration = source.ObservedGeneration
conditions := make(apis.Conditions, 0, len(source.Conditions))
for _, c := range source.Conditions {
switch c.Type {
// Copy over the "happy" condition, which is the only condition that
// we can reliably transfer.
case apis.ConditionReady, apis.ConditionSucceeded:
sink.SetConditions(apis.Conditions{c})
return
conditions = append(conditions, c)
break
}
for _, predicate := range predicates {
if predicate(c.Type) {
conditions = append(conditions, c)
break
}
}
}
sink.SetConditions(conditions)
}
// Populate implements duck.Populatable