本文整理汇总了Golang中k8s/io/kubernetes/pkg/api/rest.GetterWithOptions函数的典型用法代码示例。如果您正苦于以下问题:Golang GetterWithOptions函数的具体用法?Golang GetterWithOptions怎么用?Golang GetterWithOptions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetterWithOptions函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: resourceLocationHelper
func resourceLocationHelper(BuildPhase api.BuildPhase, podPhase string, ctx kapi.Context) (string, error) {
expectedBuild := mockBuild(BuildPhase, podPhase)
internal := &test.BuildStorage{Build: expectedBuild}
storage := &REST{
Getter: internal,
PodGetter: &testPodGetter{},
ConnectionInfo: &kclient.HTTPKubeletClient{Config: &kclient.KubeletConfig{EnableHttps: true, Port: 12345}, Client: &http.Client{}},
Timeout: defaultTimeout,
}
getter := rest.GetterWithOptions(storage)
obj, err := getter.Get(ctx, "foo-build", &api.BuildLogOptions{NoWait: true})
if err != nil {
return "", err
}
streamer, ok := obj.(*genericrest.LocationStreamer)
if !ok {
return "", fmt.Errorf("Result of get not LocationStreamer")
}
if streamer.Location != nil {
return streamer.Location.String(), nil
}
return "", nil
}
示例2: TestPreviousBuildLogs
func TestPreviousBuildLogs(t *testing.T) {
ctx := kapi.NewDefaultContext()
first := mockBuild(api.BuildPhaseComplete, "bc-1", 1)
second := mockBuild(api.BuildPhaseComplete, "bc-2", 2)
third := mockBuild(api.BuildPhaseComplete, "bc-3", 3)
internal := &test.BuildStorage{Builds: &api.BuildList{Items: []api.Build{*first, *second, *third}}}
storage := &REST{
Getter: internal,
PodGetter: &anotherTestPodGetter{},
ConnectionInfo: &fakeConnectionInfoGetter{},
Timeout: defaultTimeout,
}
getter := rest.GetterWithOptions(storage)
// Will expect the previous from bc-3 aka bc-2
obj, err := getter.Get(ctx, "bc-3", &api.BuildLogOptions{NoWait: true, Previous: true})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
streamer, ok := obj.(*genericrest.LocationStreamer)
if !ok {
t.Fatalf("unexpected object: %#v", obj)
}
expected := &url.URL{
Scheme: "https",
Host: "foo-host:12345",
Path: "/containerLogs/default/bc-2-build/foo-container",
}
if exp, got := expected.String(), streamer.Location.String(); exp != got {
t.Fatalf("expected location:\n\t%s\ngot location:\n\t%s\n", exp, got)
}
}
示例3: resourceLocationHelper
func resourceLocationHelper(BuildPhase api.BuildPhase, podPhase string, ctx kapi.Context, version int) (string, error) {
expectedBuild := mockBuild(BuildPhase, podPhase, version)
internal := &test.BuildStorage{Build: expectedBuild}
storage := &REST{
Getter: internal,
PodGetter: &testPodGetter{},
ConnectionInfo: &fakeConnectionInfoGetter{},
Timeout: defaultTimeout,
}
getter := rest.GetterWithOptions(storage)
obj, err := getter.Get(ctx, "foo-build", &api.BuildLogOptions{NoWait: true})
if err != nil {
return "", err
}
streamer, ok := obj.(*genericrest.LocationStreamer)
if !ok {
return "", fmt.Errorf("Result of get not LocationStreamer")
}
if streamer.Location != nil {
return streamer.Location.String(), nil
}
return "", nil
}
示例4: Update
return &api.Pod{}
}
// Update alters the status subset of an object.
func (r *StatusREST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, bool, error) {
return r.store.Update(ctx, obj)
}
// LogREST implements the log endpoint for a Pod
type LogREST struct {
store *etcdgeneric.Etcd
kubeletConn client.ConnectionInfoGetter
}
// LogREST implements GetterWithOptions
var _ = rest.GetterWithOptions(&LogREST{})
// New creates a new Pod log options object
func (r *LogREST) New() runtime.Object {
// TODO - return a resource that represents a log
return &api.Pod{}
}
// Get retrieves a runtime.Object that will stream the contents of the pod log
func (r *LogREST) Get(ctx api.Context, name string, opts runtime.Object) (runtime.Object, error) {
logOpts, ok := opts.(*api.PodLogOptions)
if !ok {
return nil, fmt.Errorf("Invalid options object: %#v", opts)
}
location, transport, err := pod.LogLocation(r.store, r.kubeletConn, ctx, name, logOpts)
if err != nil {