Refactor CLI initialization (#562)

This cleans up the CLI code significantly.
Also makes some of this re-usable for providers who want to do so.

This also removes the main.go from the top of the tree of the repro,
instead moving it into cmd/virtual-kubelet.
This allows us to better utilize the package namespace (and e.g. mv the
`vkubelet` package to the top of the tree).
This commit is contained in:
Brian Goff
2019-04-19 17:02:39 -07:00
committed by GitHub
parent d3f13cc6ff
commit 8d0b843ae4
86 changed files with 765 additions and 15602 deletions

View File

@@ -0,0 +1,45 @@
package opencensus
import (
"testing"
"github.com/cpuguy83/strongerrors"
"go.opencensus.io/trace"
)
func TestGetTracingExporter(t *testing.T) {
defer delete(tracingExporters, "mock")
mockExporterFn := func(_ TracingExporterOptions) (trace.Exporter, error) {
return nil, nil
}
_, err := GetTracingExporter("notexist", TracingExporterOptions{})
if !strongerrors.IsNotFound(err) {
t.Fatalf("expected not found error, got: %v", err)
}
RegisterTracingExporter("mock", mockExporterFn)
if _, err := GetTracingExporter("mock", TracingExporterOptions{}); err != nil {
t.Fatal(err)
}
}
func TestAvailableExporters(t *testing.T) {
defer delete(tracingExporters, "mock")
mockExporterFn := func(_ TracingExporterOptions) (trace.Exporter, error) {
return nil, nil
}
RegisterTracingExporter("mock", mockExporterFn)
for _, e := range AvailableTraceExporters() {
if e == "mock" {
return
}
}
t.Fatal("could not find mock exporter in list of registered exporters")
}