本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd.InterpretGetError函数的典型用法代码示例。如果您正苦于以下问题:Golang InterpretGetError函数的具体用法?Golang InterpretGetError怎么用?Golang InterpretGetError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InterpretGetError函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestEtcdCreateBindingNoPod
// Ensure that when scheduler creates a binding for a pod that has already been deleted
// by the API server, API server returns not-found error.
func TestEtcdCreateBindingNoPod(t *testing.T) {
registry, bindingRegistry, _, fakeClient, _ := newStorage(t)
ctx := api.NewDefaultContext()
fakeClient.TestIndex = true
key, _ := registry.KeyFunc(ctx, "foo")
fakeClient.Data[key] = tools.EtcdResponseWithError{
R: &etcd.Response{
Node: nil,
},
E: tools.EtcdErrorNotFound,
}
// Assume that a pod has undergone the following:
// - Create (apiserver)
// - Schedule (scheduler)
// - Delete (apiserver)
_, err := bindingRegistry.Create(ctx, &api.Binding{
ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault, Name: "foo"},
Target: api.ObjectReference{Name: "machine"},
})
if err == nil {
t.Fatalf("Expected not-found-error but got nothing")
}
if !errors.IsNotFound(etcderrors.InterpretGetError(err, "Pod", "foo")) {
t.Fatalf("Unexpected error returned: %#v", err)
}
_, err = registry.Get(ctx, "foo")
if err == nil {
t.Fatalf("Expected not-found-error but got nothing")
}
if !errors.IsNotFound(etcderrors.InterpretGetError(err, "Pod", "foo")) {
t.Fatalf("Unexpected error: %v", err)
}
}
开发者ID:SivagnanamCiena,项目名称:calico-kubernetes,代码行数:37,代码来源:etcd_test.go
示例2: Get
// Get returns an api.RangeAllocation that represents the current state in
// etcd. If the key does not exist, the object will have an empty ResourceVersion.
func (e *Etcd) Get() (*api.RangeAllocation, error) {
existing := &api.RangeAllocation{}
if err := e.helper.ExtractObj(e.baseKey, existing, true); err != nil {
return nil, etcderr.InterpretGetError(err, e.kind, "")
}
return existing, nil
}
开发者ID:chenzhen411,项目名称:kubernetes,代码行数:9,代码来源:etcd.go
示例3: Get
// Get retrieves the item from etcd.
func (e *Etcd) Get(ctx api.Context, id string) (runtime.Object, error) {
obj := e.NewFunc()
err := e.Helper.ExtractObj(e.KeyFunc(id), obj, false)
if err != nil {
return nil, etcderr.InterpretGetError(err, e.EndpointName, id)
}
return obj, nil
}
开发者ID:ericcapricorn,项目名称:kubernetes,代码行数:9,代码来源:etcd.go
示例4: GetMinion
func (r *Registry) GetMinion(ctx api.Context, minionID string) (*api.Node, error) {
var minion api.Node
key := makeNodeKey(minionID)
err := r.ExtractObj(key, &minion, false)
if err != nil {
return nil, etcderr.InterpretGetError(err, "minion", minionID)
}
return &minion, nil
}
开发者ID:vrosnet,项目名称:kubernetes,代码行数:9,代码来源:etcd.go
示例5: GetController
// GetController gets a specific ReplicationController specified by its ID.
func (r *Registry) GetController(controllerID string) (*api.ReplicationController, error) {
var controller api.ReplicationController
key := makeControllerKey(controllerID)
err := r.ExtractObj(key, &controller, false)
if err != nil {
return nil, etcderr.InterpretGetError(err, "replicationController", controllerID)
}
return &controller, nil
}
开发者ID:linuxwhy,项目名称:kubernetes,代码行数:10,代码来源:etcd.go
示例6: GetEndpoints
// GetEndpoints obtains the endpoints for the service identified by 'name'.
func (r *Registry) GetEndpoints(name string) (*api.Endpoints, error) {
key := makeServiceEndpointsKey(name)
var endpoints api.Endpoints
err := r.ExtractObj(key, &endpoints, false)
if err != nil {
return nil, etcderr.InterpretGetError(err, "endpoints", name)
}
return &endpoints, nil
}
开发者ID:linuxwhy,项目名称:kubernetes,代码行数:10,代码来源:etcd.go
示例7: GetService
// GetService obtains a Service specified by its name.
func (r *Registry) GetService(name string) (*api.Service, error) {
key := makeServiceKey(name)
var svc api.Service
err := r.ExtractObj(key, &svc, false)
if err != nil {
return nil, etcderr.InterpretGetError(err, "service", name)
}
return &svc, nil
}
开发者ID:linuxwhy,项目名称:kubernetes,代码行数:10,代码来源:etcd.go
示例8: assignPod
// assignPod assigns the given pod to the given machine.
func (r *BindingREST) assignPod(ctx api.Context, podID string, machine string, annotations map[string]string) (err error) {
if _, err = r.setPodHostAndAnnotations(ctx, podID, "", machine, annotations); err != nil {
err = etcderr.InterpretGetError(err, "pod", podID)
err = etcderr.InterpretUpdateError(err, "pod", podID)
if _, ok := err.(*errors.StatusError); !ok {
err = errors.NewConflict("binding", podID, err)
}
}
return
}
开发者ID:cjnygard,项目名称:origin,代码行数:11,代码来源:etcd.go
示例9: GetPod
// GetPod gets a specific pod specified by its ID.
func (r *Registry) GetPod(ctx api.Context, id string) (*api.Pod, error) {
var pod api.Pod
key, err := makePodKey(ctx, id)
if err != nil {
return nil, err
}
if err = r.ExtractObj(key, &pod, false); err != nil {
return nil, etcderr.InterpretGetError(err, "pod", id)
}
return &pod, nil
}
开发者ID:hortonworks,项目名称:kubernetes-yarn,代码行数:12,代码来源:etcd.go
示例10: GetPod
// GetPod gets a specific pod specified by its ID.
func (r *Registry) GetPod(podID string) (*api.Pod, error) {
var pod api.Pod
if err := r.ExtractObj(makePodKey(podID), &pod, false); err != nil {
return nil, etcderr.InterpretGetError(err, "pod", podID)
}
// TODO: Currently nothing sets CurrentState.Host. We need a feedback loop that sets
// the CurrentState.Host and Status fields. Here we pretend that reality perfectly
// matches our desires.
pod.CurrentState.Host = pod.DesiredState.Host
return &pod, nil
}
开发者ID:linuxwhy,项目名称:kubernetes,代码行数:12,代码来源:etcd.go
示例11: GetService
// GetService obtains a Service specified by its name.
func (r *Registry) GetService(ctx api.Context, name string) (*api.Service, error) {
key, err := makeServiceKey(ctx, name)
if err != nil {
return nil, err
}
var svc api.Service
err = r.Get(key, &svc, false)
if err != nil {
return nil, etcderr.InterpretGetError(err, "service", name)
}
return &svc, nil
}
开发者ID:Ima8,项目名称:kubernetes,代码行数:13,代码来源:etcd.go
示例12: GetRoute
// GetRoute gets a specific Route specified by its ID.
func (registry *Etcd) GetRoute(ctx kapi.Context, routeID string) (*api.Route, error) {
route := api.Route{}
key, err := makeRouteKey(ctx, routeID)
if err != nil {
return nil, err
}
err = registry.Get(key, &route, false)
if err != nil {
return nil, etcderr.InterpretGetError(err, "route", routeID)
}
return &route, nil
}
开发者ID:dustintownsend,项目名称:origin,代码行数:13,代码来源:etcd.go
示例13: GetBuildConfig
// GetBuildConfig gets a specific BuildConfig specified by its ID.
func (r *Etcd) GetBuildConfig(ctx kapi.Context, id string) (*api.BuildConfig, error) {
var config api.BuildConfig
key, err := makeBuildConfigKey(ctx, id)
if err != nil {
return nil, err
}
err = r.ExtractObj(key, &config, false)
if err != nil {
return nil, etcderr.InterpretGetError(err, "buildConfig", id)
}
return &config, nil
}
开发者ID:pombredanne,项目名称:atomic-enterprise,代码行数:13,代码来源:etcd.go
示例14: GetBuild
// GetBuild gets a specific Build specified by its ID.
func (r *Etcd) GetBuild(ctx kapi.Context, id string) (*api.Build, error) {
var build api.Build
key, err := makeBuildKey(ctx, id)
if err != nil {
return nil, err
}
err = r.ExtractObj(key, &build, false)
if err != nil {
return nil, etcderr.InterpretGetError(err, "build", id)
}
setDuration(&build)
return &build, nil
}
开发者ID:pombredanne,项目名称:atomic-enterprise,代码行数:14,代码来源:etcd.go
示例15: Refresh
// Refresh reloads the RangeAllocation from etcd.
func (e *Etcd) Refresh() (*api.RangeAllocation, error) {
e.lock.Lock()
defer e.lock.Unlock()
existing := &api.RangeAllocation{}
if err := e.helper.ExtractObj(e.baseKey, existing, false); err != nil {
if tools.IsEtcdNotFound(err) {
return nil, nil
}
return nil, etcderr.InterpretGetError(err, e.kind, "")
}
return existing, nil
}
开发者ID:chenzhen411,项目名称:kubernetes,代码行数:15,代码来源:etcd.go
示例16: Get
// Get retrieves the item from etcd.
func (e *Etcd) Get(ctx api.Context, name string) (runtime.Object, error) {
obj := e.NewFunc()
key, err := e.KeyFunc(ctx, name)
if err != nil {
return nil, err
}
if err := e.Helper.ExtractObj(key, obj, false); err != nil {
return nil, etcderr.InterpretGetError(err, e.EndpointName, name)
}
if e.Decorator != nil {
if err := e.Decorator(obj); err != nil {
return nil, err
}
}
return obj, nil
}
开发者ID:SivagnanamCiena,项目名称:calico-kubernetes,代码行数:17,代码来源:etcd.go
示例17: Get
// Get retrieves the item from etcd.
func (e *Etcd) Get(ctx api.Context, name string) (runtime.Object, error) {
obj := e.NewFunc()
trace := util.NewTrace("Get " + reflect.TypeOf(obj).String())
defer trace.LogIfLong(time.Second)
key, err := e.KeyFunc(ctx, name)
if err != nil {
return nil, err
}
trace.Step("About to read object")
if err := e.Helper.ExtractObj(key, obj, false); err != nil {
return nil, etcderr.InterpretGetError(err, e.EndpointName, name)
}
trace.Step("Object read")
if e.Decorator != nil {
if err := e.Decorator(obj); err != nil {
return nil, err
}
}
return obj, nil
}
开发者ID:brandon-adams,项目名称:origin,代码行数:21,代码来源:etcd.go
注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd.InterpretGetError函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论