From d51173c6a1468b6c2fdb58907a924348719a23a7 Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Fri, 2 Nov 2018 23:46:19 +0000 Subject: [PATCH] Pull in https://github.com/knative/pkg/pull/161 --- Gopkg.lock | 5 +-- Gopkg.toml | 5 +-- .../pkg/apis/duck/v1alpha1/condition_set.go | 36 ++++++++++++------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 3dd3cb59b2c9..58198ce89bea 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -353,7 +353,7 @@ revision = "f0d7bb60956f88d4743f5fea66b5607b96d262c9" [[projects]] - digest = "1:159e58c92785cb1c10eb2f72dbc42cb2cf6cc6d4134b66c2b365273d638354c7" + digest = "1:42f47ab7042b57be76fb23b3385cd8b60d0ca939b8dda31908a3d9e5905f9bd8" name = "github.com/knative/pkg" packages = [ "apis", @@ -395,7 +395,8 @@ "webhook", ] pruneopts = "NUT" - revision = "a8160c7d728d26da67e596c5b1975877082a26e6" + revision = "d0878e83aa1d5911c49c9c30df152b861fb16703" + source = "github.com/mattmoor/pkg-1" [[projects]] branch = "master" diff --git a/Gopkg.toml b/Gopkg.toml index ec0cd54339d9..35250b77da48 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -22,8 +22,9 @@ required = [ [[override]] name = "github.com/knative/pkg" - # HEAD as of 2018-11-02 - revision = "a8160c7d728d26da67e596c5b1975877082a26e6" + source = "github.com/mattmoor/pkg-1" + # DO NOT SUBMIT https://github.com/knative/pkg/pull/161 + revision = "d0878e83aa1d5911c49c9c30df152b861fb16703" [[override]] name = "go.uber.org/zap" diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/condition_set.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/condition_set.go index 30b76a5f6671..f3a91df1eb42 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/condition_set.go +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/condition_set.go @@ -62,7 +62,7 @@ type ConditionManager interface { SetCondition(new Condition) // MarkTrue sets the status of t to true, and then marks the happy condition to - // true if all other dependents are also true. + // true if all dependents are true. MarkTrue(t ConditionType) // MarkUnknown sets the status of t to Unknown and also sets the happy condition @@ -82,12 +82,14 @@ type ConditionManager interface { // NewLivingConditionSet returns a ConditionSet to hold the conditions for the // living resource. ConditionReady is used as the happy condition. +// The set of condition types provided are those of the terminal subconditions. func NewLivingConditionSet(d ...ConditionType) ConditionSet { return newConditionSet(ConditionReady, d...) } // NewBatchConditionSet returns a ConditionSet to hold the conditions for the // batch resource. ConditionSucceeded is used as the happy condition. +// The set of condition types provided are those of the terminal subconditions. func NewBatchConditionSet(d ...ConditionType) ConditionSet { return newConditionSet(ConditionSucceeded, d...) } @@ -246,6 +248,7 @@ func (r conditionsImpl) MarkUnknown(t ConditionType, reason, messageFormat strin }) // check the dependents. + isDependent := false for _, cond := range r.dependents { c := r.GetCondition(cond) // Failed conditions trump Unknown conditions @@ -257,23 +260,32 @@ func (r conditionsImpl) MarkUnknown(t ConditionType, reason, messageFormat strin } return } + if cond == t { + isDependent = true + } } - // set the happy condition - r.SetCondition(Condition{ - Type: r.happy, - Status: corev1.ConditionUnknown, - Reason: reason, - Message: fmt.Sprintf(messageFormat, messageA...), - }) + if isDependent { + // set the happy condition, if it is one of our dependent subconditions. + r.SetCondition(Condition{ + Type: r.happy, + Status: corev1.ConditionUnknown, + Reason: reason, + Message: fmt.Sprintf(messageFormat, messageA...), + }) + } } // MarkFalse sets the status of t and the happy condition to False. func (r conditionsImpl) MarkFalse(t ConditionType, reason, messageFormat string, messageA ...interface{}) { - for _, t := range []ConditionType{ - t, - r.happy, - } { + types := []ConditionType{t} + for _, cond := range r.dependents { + if cond == t { + types = append(types, r.happy) + } + } + + for _, t := range types { r.SetCondition(Condition{ Type: t, Status: corev1.ConditionFalse,