@@ -11,10 +11,10 @@ type Subscription struct {
1111 // wildcard indicates if the subscription currently has a wildcard watch.
1212 wildcard bool
1313
14- // allowLegacyWildcard indicates that an empty request should be treated as a wildcard request.
15- // If in the stream at some point subscribes explicitly a resource or a explicitly makes wildcard
16- // request, then subsequent empty requests should not be treated as wildcard and so this
17- // flag will be set to false.
14+ // allowLegacyWildcard indicates that the stream never provided any resource
15+ // and is de facto wildcard.
16+ // As soon as a resource or an explicit subscription to wildcard is provided,
17+ // this flag will be set to false
1818 allowLegacyWildcard bool
1919
2020 // subscribedResourceNames provides the resources explicitly requested by the client
@@ -26,17 +26,7 @@ type Subscription struct {
2626}
2727
2828// newSubscription initializes a subscription state.
29- func newSubscription (emptyRequest bool , initialResourceVersions map [string ]string , opts config.Opts , typeURL string ) Subscription {
30- allowLegacyWildcard := emptyRequest
31-
32- if opts .LegacyWildcardDeactivated () {
33- allowLegacyWildcard = false
34- } else if typeMap := opts .LegacyWildcardDeactivatedTypes (); len (typeMap ) > 0 {
35- if _ , found := typeMap [typeURL ]; found {
36- allowLegacyWildcard = false
37- }
38- }
39-
29+ func newSubscription (emptyRequest , allowLegacyWildcard bool , initialResourceVersions map [string ]string ) Subscription {
4030 // By default we set the subscription as a wildcard only if the request was empty
4131 // and in legacy mode. Later on, outside of this constructor, when we actually
4232 // process the request, if the request was non-empty, it may have an
@@ -59,7 +49,7 @@ func newSubscription(emptyRequest bool, initialResourceVersions map[string]strin
5949}
6050
6151func NewSotwSubscription (subscribed []string , opts config.Opts , typeURL string ) Subscription {
62- sub := newSubscription (len (subscribed ) == 0 , nil , opts , typeURL )
52+ sub := newSubscription (len (subscribed ) == 0 , opts . IsLegacyWildcardActive ( typeURL ), nil )
6353 sub .SetResourceSubscription (subscribed )
6454 return sub
6555}
@@ -110,7 +100,7 @@ func (s *Subscription) SetResourceSubscription(subscribed []string) {
110100}
111101
112102func NewDeltaSubscription (subscribed , unsubscribed []string , initialResourceVersions map [string ]string , opts config.Opts , typeURL string ) Subscription {
113- sub := newSubscription (len (subscribed ) == 0 , initialResourceVersions , opts , typeURL )
103+ sub := newSubscription (len (subscribed ) == 0 , opts . IsLegacyWildcardActive ( typeURL ), initialResourceVersions )
114104 sub .UpdateResourceSubscriptions (subscribed , unsubscribed )
115105 return sub
116106}
0 commit comments