Skip to content

Commit

Permalink
upgrade to latest dependencies (#754)
Browse files Browse the repository at this point in the history
bumping knative.dev/pkg a170a07...52ff2ac:%0A  > 52ff2ac drop dynamic client wrappers (# 2744)

Signed-off-by: Knative Automation <automation@knative.team>
  • Loading branch information
knative-automation committed May 23, 2023
1 parent 181e8f1 commit 40d1e6a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 58 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1
knative.dev/hack v0.0.0-20230501013555-7d81248b4638
knative.dev/hack/schema v0.0.0-20230501013555-7d81248b4638
knative.dev/pkg v0.0.0-20230518144313-a170a07b346d
knative.dev/pkg v0.0.0-20230519200515-52ff2acf870d
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ knative.dev/hack v0.0.0-20230501013555-7d81248b4638 h1:9IuXHdwp5jNmIg+0LVTQr8o4u
knative.dev/hack v0.0.0-20230501013555-7d81248b4638/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
knative.dev/hack/schema v0.0.0-20230501013555-7d81248b4638 h1:h5jdbAWKVBaH4zEYrm+E0wqR6ZcO+XywXwGrNZwiNhg=
knative.dev/hack/schema v0.0.0-20230501013555-7d81248b4638/go.mod h1:GeIb+PLd5mllawcpHEGF5J5fYTQrvgEO5liao8lUKUs=
knative.dev/pkg v0.0.0-20230518144313-a170a07b346d h1:/FRiyfiNBVIuBUFio56ReL0/GCiU50OxXLJ+7eByMVQ=
knative.dev/pkg v0.0.0-20230518144313-a170a07b346d/go.mod h1:WLTHHHc/dhrDmhx03nm5F8AeqpNx3RQGggMI2N0/oks=
knative.dev/pkg v0.0.0-20230519200515-52ff2acf870d h1:7SnDEbArYmc8swy5LUB0o+YnoRHL6/BXKYy4HeHlDmM=
knative.dev/pkg v0.0.0-20230519200515-52ff2acf870d/go.mod h1:WLTHHHc/dhrDmhx03nm5F8AeqpNx3RQGggMI2N0/oks=
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=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ package secret
import (
context "context"

apicorev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
v1 "k8s.io/client-go/informers/core/v1"
kubernetes "k8s.io/client-go/kubernetes"
corev1 "k8s.io/client-go/listers/core/v1"
cache "k8s.io/client-go/tools/cache"
client "knative.dev/pkg/client/injection/kube/client"
controller "knative.dev/pkg/controller"
injection "knative.dev/pkg/injection"
factory "knative.dev/pkg/injection/clients/namespacedkube/informers/factory"
Expand All @@ -35,7 +28,6 @@ import (

func init() {
injection.Default.RegisterInformer(withInformer)
injection.Dynamic.RegisterDynamicInformer(withDynamicInformer)
}

// Key is used for associating the Informer inside the context.Context.
Expand All @@ -47,11 +39,6 @@ func withInformer(ctx context.Context) (context.Context, controller.Informer) {
return context.WithValue(ctx, Key{}, inf), inf.Informer()
}

func withDynamicInformer(ctx context.Context) context.Context {
inf := &wrapper{client: client.Get(ctx)}
return context.WithValue(ctx, Key{}, inf)
}

// Get extracts the typed informer from the context.
func Get(ctx context.Context) v1.SecretInformer {
untyped := ctx.Value(Key{})
Expand All @@ -61,44 +48,3 @@ func Get(ctx context.Context) v1.SecretInformer {
}
return untyped.(v1.SecretInformer)
}

type wrapper struct {
client kubernetes.Interface

namespace string
}

var _ v1.SecretInformer = (*wrapper)(nil)
var _ corev1.SecretLister = (*wrapper)(nil)

func (w *wrapper) Informer() cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(nil, &apicorev1.Secret{}, 0, nil)
}

func (w *wrapper) Lister() corev1.SecretLister {
return w
}

func (w *wrapper) Secrets(namespace string) corev1.SecretNamespaceLister {
return &wrapper{client: w.client, namespace: namespace}
}

func (w *wrapper) List(selector labels.Selector) (ret []*apicorev1.Secret, err error) {
lo, err := w.client.CoreV1().Secrets(w.namespace).List(context.TODO(), metav1.ListOptions{
LabelSelector: selector.String(),
// TODO(mattmoor): Incorporate resourceVersion bounds based on staleness criteria.
})
if err != nil {
return nil, err
}
for idx := range lo.Items {
ret = append(ret, &lo.Items[idx])
}
return ret, nil
}

func (w *wrapper) Get(name string) (*apicorev1.Secret, error) {
return w.client.CoreV1().Secrets(w.namespace).Get(context.TODO(), name, metav1.GetOptions{
// TODO(mattmoor): Incorporate resourceVersion bounds based on staleness criteria.
})
}
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ knative.dev/hack/schema/commands
knative.dev/hack/schema/docs
knative.dev/hack/schema/registry
knative.dev/hack/schema/schema
# knative.dev/pkg v0.0.0-20230518144313-a170a07b346d
# knative.dev/pkg v0.0.0-20230519200515-52ff2acf870d
## explicit; go 1.18
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
Expand Down

0 comments on commit 40d1e6a

Please sign in to comment.