-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Controller runtime 0.2.0 alpha0 vendor #1369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
025d852
4af1e67
8df5769
359ab47
4eca06b
3ee99f8
957eb9d
3b09df8
5796ad3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,9 @@ import ( | |
| "errors" | ||
| "fmt" | ||
| "io/ioutil" | ||
| "k8s.io/apimachinery/pkg/fields" | ||
| "k8s.io/apimachinery/pkg/labels" | ||
| "k8s.io/apimachinery/pkg/selection" | ||
| "net/http" | ||
| "net/http/httputil" | ||
| "strings" | ||
|
|
@@ -114,7 +117,7 @@ func CacheResponseHandler(h http.Handler, informerCache cache.Cache, restMapper | |
| log.Error(err, "Unable to decode list options from request") | ||
| break | ||
| } | ||
| lo := client.InNamespace(r.Namespace) | ||
| lo := client.ListOptions{Namespace: r.Namespace} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here we can do just as follows. lo := &client.ListOptions{}
lo.InNamespace(r.Namespace) |
||
| if err := lo.SetLabelSelector(listOptions.LabelSelector); err != nil { | ||
| log.Error(err, "Unable to set label selectors for the client") | ||
| break | ||
|
|
@@ -128,7 +131,25 @@ func CacheResponseHandler(h http.Handler, informerCache cache.Cache, restMapper | |
| k.Kind = k.Kind + "List" | ||
| un := unstructured.UnstructuredList{} | ||
| un.SetGroupVersionKind(k) | ||
| err = informerCache.List(context.Background(), lo, &un) | ||
| lbs, err := labels.ConvertSelectorToLabelsMap(lo.LabelSelector.String()) | ||
| if err != nil { | ||
| log.Error(err, "Unable to set label selectors for the client") | ||
| break | ||
| } | ||
| p := []client.ListOptionFunc{client.InNamespace(lo.Namespace)} | ||
| if len(lbs) > 0 { | ||
| p = append(p, client.MatchingLabels(lbs)) | ||
| } | ||
| s, err := fields.ParseSelector(lo.FieldSelector.String()) | ||
| reqs := s.Requirements() | ||
| if len(reqs) > 0 { | ||
| for idx, reg := range reqs { | ||
| if reg.Operator == selection.Equals || reg.Operator == selection.DoubleEquals { | ||
| p = append(p, client.MatchingField(reqs[idx].Field, reqs[idx].Value)) | ||
| } | ||
| } | ||
| } | ||
| err = informerCache.List(context.Background(), &un, p...) | ||
| if err != nil { | ||
| // break here in case resource doesn't exist in cache but exists on APIserver | ||
| // This is very unlikely but provides user with expected 404 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,6 @@ import ( | |
| "github.com/go-logr/zapr" | ||
| "go.uber.org/zap" | ||
| "go.uber.org/zap/zapcore" | ||
| logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" | ||
| ) | ||
|
|
||
| func Logger() logr.Logger { | ||
|
|
@@ -34,7 +33,6 @@ func LoggerTo(destWriter io.Writer) logr.Logger { | |
| syncer := zapcore.AddSync(destWriter) | ||
| conf := getConfig() | ||
|
|
||
| conf.encoder = &logf.KubeAwareEncoder{Encoder: conf.encoder, Verbose: conf.level.Level() < 0} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following it fixed made in the PR: f494845#diff-4407315726717f30063d558928ad9188R37 zapf "sigs.k8s.io/controller-runtime/pkg/log/zap"
conf.encoder = &zapf.KubeAwareEncoder{Encoder: conf.encoder, Verbose: conf.level.Level() < 0}
` |
||
| if conf.sample { | ||
| conf.opts = append(conf.opts, zap.WrapCore(func(core zapcore.Core) zapcore.Core { | ||
| return zapcore.NewSampler(core, time.Second, 100, 100) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @corinnekrych,
In the f494845#diff-b38c855ac3ed0aa95294c855ea839f99R176 it was solved as follows.