• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang apiserver.MakeAsync函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver.MakeAsync函数的典型用法代码示例。如果您正苦于以下问题:Golang MakeAsync函数的具体用法?Golang MakeAsync怎么用?Golang MakeAsync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MakeAsync函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Create

// Create registers the given ReplicationController.
func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) {
	controller, ok := obj.(*api.ReplicationController)
	if !ok {
		return nil, fmt.Errorf("not a replication controller: %#v", obj)
	}
	if !api.ValidNamespace(ctx, &controller.ObjectMeta) {
		return nil, errors.NewConflict("controller", controller.Namespace, fmt.Errorf("Controller.Namespace does not match the provided context"))
	}

	if len(controller.Name) == 0 {
		controller.Name = util.NewUUID().String()
	}
	if errs := validation.ValidateReplicationController(controller); len(errs) > 0 {
		return nil, errors.NewInvalid("replicationController", controller.Name, errs)
	}

	api.FillObjectMetaSystemFields(ctx, &controller.ObjectMeta)

	return apiserver.MakeAsync(func() (runtime.Object, error) {
		err := rs.registry.CreateController(ctx, controller)
		if err != nil {
			return nil, err
		}
		return rs.registry.GetController(ctx, controller.Name)
	}), nil
}
开发者ID:nhr,项目名称:kubernetes,代码行数:27,代码来源:rest.go


示例2: Create

func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) {
	minion, ok := obj.(*api.Minion)
	if !ok {
		return nil, fmt.Errorf("not a minion: %#v", obj)
	}
	if minion.Name == "" {
		return nil, fmt.Errorf("ID should not be empty: %#v", minion)
	}

	minion.CreationTimestamp = util.Now()

	return apiserver.MakeAsync(func() (runtime.Object, error) {
		err := rs.registry.CreateMinion(ctx, minion)
		if err != nil {
			return nil, err
		}
		minionName := minion.Name
		minion, err := rs.registry.GetMinion(ctx, minionName)
		if err == ErrNotHealty {
			return rs.toApiMinion(minionName), nil
		}
		if minion == nil {
			return nil, ErrDoesNotExist
		}
		if err != nil {
			return nil, err
		}
		return minion, nil
	}), nil
}
开发者ID:ericcapricorn,项目名称:kubernetes,代码行数:30,代码来源:rest.go


示例3: Create

func (rs *REST) Create(obj runtime.Object) (<-chan runtime.Object, error) {
	minion, ok := obj.(*api.Minion)
	if !ok {
		return nil, fmt.Errorf("not a minion: %#v", obj)
	}
	if minion.ID == "" {
		return nil, fmt.Errorf("ID should not be empty: %#v", minion)
	}

	minion.CreationTimestamp = util.Now()

	return apiserver.MakeAsync(func() (runtime.Object, error) {
		err := rs.registry.Insert(minion.ID)
		if err != nil {
			return nil, err
		}
		contains, err := rs.registry.Contains(minion.ID)
		if err != nil {
			return nil, err
		}
		if contains {
			return rs.toApiMinion(minion.ID), nil
		}
		return nil, fmt.Errorf("unable to add minion %#v", minion)
	}), nil
}
开发者ID:asim,项目名称:kubernetes,代码行数:26,代码来源:rest.go


示例4: Update

// Update satisfies the RESTStorage interface.
func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) {
	minion, ok := obj.(*api.Node)
	if !ok {
		return nil, fmt.Errorf("not a minion: %#v", obj)
	}
	// This is hacky, but minions don't really have a namespace, but kubectl currently automatically
	// stuffs one in there.  Fix it here temporarily until we fix kubectl
	if minion.Namespace == api.NamespaceDefault {
		minion.Namespace = api.NamespaceNone
	}
	// Clear out the self link, if specified, since it's not in the registry either.
	minion.SelfLink = ""

	// TODO: GetMinion will health check the minion, but we shouldn't require the minion to be
	// running for updating labels.
	oldMinion, err := rs.registry.GetMinion(ctx, minion.Name)
	if err != nil {
		return nil, err
	}
	if errs := validation.ValidateMinionUpdate(oldMinion, minion); len(errs) > 0 {
		return nil, kerrors.NewInvalid("minion", minion.Name, errs)
	}

	return apiserver.MakeAsync(func() (runtime.Object, error) {
		err := rs.registry.UpdateMinion(ctx, minion)
		if err != nil {
			return nil, err
		}
		return rs.registry.GetMinion(ctx, minion.Name)
	}), nil
}
开发者ID:hortonworks,项目名称:kubernetes-yarn,代码行数:32,代码来源:rest.go


示例5: Update

func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) {
	service := obj.(*api.Service)
	if !api.ValidNamespace(ctx, &service.ObjectMeta) {
		return nil, errors.NewConflict("service", service.Namespace, fmt.Errorf("Service.Namespace does not match the provided context"))
	}
	if errs := validation.ValidateService(service, rs.registry, ctx); len(errs) > 0 {
		return nil, errors.NewInvalid("service", service.Name, errs)
	}
	return apiserver.MakeAsync(func() (runtime.Object, error) {
		cur, err := rs.registry.GetService(ctx, service.Name)
		if err != nil {
			return nil, err
		}
		if service.Spec.PortalIP != cur.Spec.PortalIP {
			// TODO: Would be nice to pass "field is immutable" to users.
			el := errors.ValidationErrorList{errors.NewFieldInvalid("spec.portalIP", service.Spec.PortalIP)}
			return nil, errors.NewInvalid("service", service.Name, el)
		}
		// Copy over non-user fields.
		service.Spec.ProxyPort = cur.Spec.ProxyPort
		// TODO: check to see if external load balancer status changed
		err = rs.registry.UpdateService(ctx, service)
		if err != nil {
			return nil, err
		}
		return rs.registry.GetService(ctx, service.Name)
	}), nil
}
开发者ID:ericcapricorn,项目名称:kubernetes,代码行数:28,代码来源:rest.go


示例6: Create

func (sr *ServiceRegistryStorage) Create(obj interface{}) (<-chan interface{}, error) {
	srv := obj.(api.Service)
	if srv.ID == "" {
		return nil, fmt.Errorf("ID should not be empty: %#v", srv)
	}
	return apiserver.MakeAsync(func() (interface{}, error) {
		// TODO: Consider moving this to a rectification loop, so that we make/remove external load balancers
		// correctly no matter what http operations happen.
		if srv.CreateExternalLoadBalancer {
			var balancer cloudprovider.TCPLoadBalancer
			var ok bool
			if sr.cloud != nil {
				balancer, ok = sr.cloud.TCPLoadBalancer()
			}
			if ok && balancer != nil {
				hosts, err := sr.machines.List()
				if err != nil {
					return nil, err
				}
				err = balancer.CreateTCPLoadBalancer(srv.ID, "us-central1", srv.Port, hosts)
				if err != nil {
					return nil, err
				}
			} else {
				return nil, fmt.Errorf("requested an external service, but no cloud provider supplied.")
			}
		}
		// TODO actually wait for the object to be fully created here.
		err := sr.registry.CreateService(srv)
		if err != nil {
			return nil, err
		}
		return sr.registry.GetService(srv.ID)
	}), nil
}
开发者ID:heyox,项目名称:kubernetes,代码行数:35,代码来源:service_registry.go


示例7: Delete

func (rs *RegistryStorage) Delete(id string) (<-chan interface{}, error) {
	service, err := rs.registry.GetService(id)
	if err != nil {
		return nil, err
	}
	return apiserver.MakeAsync(func() (interface{}, error) {
		rs.deleteExternalLoadBalancer(service)
		return &api.Status{Status: api.StatusSuccess}, rs.registry.DeleteService(id)
	}), nil
}
开发者ID:hvdb,项目名称:kubernetes,代码行数:10,代码来源:storage.go


示例8: Delete

func (rs *REST) Delete(id string) (<-chan runtime.Object, error) {
	service, err := rs.registry.GetService(id)
	if err != nil {
		return nil, err
	}
	return apiserver.MakeAsync(func() (runtime.Object, error) {
		rs.deleteExternalLoadBalancer(service)
		return &api.Status{Status: api.StatusSuccess}, rs.registry.DeleteService(id)
	}), nil
}
开发者ID:asim,项目名称:kubernetes,代码行数:10,代码来源:rest.go


示例9: Delete

func (rs *REST) Delete(ctx api.Context, id string) (<-chan apiserver.RESTResult, error) {
	service, err := rs.registry.GetService(ctx, id)
	if err != nil {
		return nil, err
	}
	rs.portalMgr.Release(net.ParseIP(service.Spec.PortalIP))
	return apiserver.MakeAsync(func() (runtime.Object, error) {
		rs.deleteExternalLoadBalancer(service)
		return &api.Status{Status: api.StatusSuccess}, rs.registry.DeleteService(ctx, id)
	}), nil
}
开发者ID:ericcapricorn,项目名称:kubernetes,代码行数:11,代码来源:rest.go


示例10: Delete

func (storage *MinionRegistryStorage) Delete(id string) (<-chan interface{}, error) {
	exists, err := storage.registry.Contains(id)
	if !exists {
		return nil, ErrDoesNotExist
	}
	if err != nil {
		return nil, err
	}
	return apiserver.MakeAsync(func() (interface{}, error) {
		return api.Status{Status: api.StatusSuccess}, storage.registry.Delete(id)
	}), nil
}
开发者ID:RubanDeventhiran,项目名称:kubernetes,代码行数:12,代码来源:minion_registry.go


示例11: Update

func (rs *RegistryStorage) Update(obj interface{}) (<-chan interface{}, error) {
	pod := obj.(*api.Pod)
	if errs := api.ValidatePod(pod); len(errs) > 0 {
		return nil, apiserver.NewInvalidErr("pod", pod.ID, errs)
	}
	return apiserver.MakeAsync(func() (interface{}, error) {
		if err := rs.registry.UpdatePod(*pod); err != nil {
			return nil, err
		}
		return rs.registry.GetPod(pod.ID)
	}), nil
}
开发者ID:nvdnkpr,项目名称:kubernetes,代码行数:12,代码来源:storage.go


示例12: Create

func (storage *PodRegistryStorage) Create(pod interface{}) (<-chan interface{}, error) {
	podObj := pod.(api.Pod)
	if len(podObj.ID) == 0 {
		return nil, fmt.Errorf("id is unspecified: %#v", pod)
	}
	machine, err := storage.scheduler.Schedule(podObj)
	if err != nil {
		return nil, err
	}

	return apiserver.MakeAsync(func() interface{} { return pod }), storage.registry.CreatePod(machine, podObj)
}
开发者ID:haegyung,项目名称:kubernetes,代码行数:12,代码来源:pod_registry.go


示例13: Create

// Create attempts to make the assignment indicated by the binding it recieves.
func (b *BindingStorage) Create(obj interface{}) (<-chan interface{}, error) {
	binding, ok := obj.(*api.Binding)
	if !ok {
		return nil, fmt.Errorf("incorrect type: %#v", obj)
	}
	return apiserver.MakeAsync(func() (interface{}, error) {
		if err := b.registry.ApplyBinding(binding); err != nil {
			return nil, err
		}
		return &api.Status{Status: api.StatusSuccess}, nil
	}), nil
}
开发者ID:hvdb,项目名称:kubernetes,代码行数:13,代码来源:storage.go


示例14: Update

func (rs *REST) Update(obj runtime.Object) (<-chan runtime.Object, error) {
	pod := obj.(*api.Pod)
	if errs := validation.ValidatePod(pod); len(errs) > 0 {
		return nil, errors.NewInvalid("pod", pod.ID, errs)
	}
	return apiserver.MakeAsync(func() (runtime.Object, error) {
		if err := rs.registry.UpdatePod(pod); err != nil {
			return nil, err
		}
		return rs.registry.GetPod(pod.ID)
	}), nil
}
开发者ID:fabric8io,项目名称:kubernetes,代码行数:12,代码来源:rest.go


示例15: Create

// Create attempts to make the assignment indicated by the binding it recieves.
func (b *REST) Create(ctx api.Context, obj runtime.Object) (<-chan apiserver.RESTResult, error) {
	binding, ok := obj.(*api.Binding)
	if !ok {
		return nil, fmt.Errorf("incorrect type: %#v", obj)
	}
	return apiserver.MakeAsync(func() (runtime.Object, error) {
		if err := b.registry.ApplyBinding(ctx, binding); err != nil {
			return nil, err
		}
		return &api.Status{Status: api.StatusSuccess}, nil
	}), nil
}
开发者ID:hortonworks,项目名称:kubernetes-yarn,代码行数:13,代码来源:rest.go


示例16: Update

func (rs *RegistryStorage) Update(obj interface{}) (<-chan interface{}, error) {
	pod := obj.(*api.Pod)
	if errs := api.ValidatePod(pod); len(errs) > 0 {
		return nil, fmt.Errorf("Validation errors: %v", errs)
	}
	return apiserver.MakeAsync(func() (interface{}, error) {
		if err := rs.registry.UpdatePod(*pod); err != nil {
			return nil, err
		}
		return rs.waitForPodRunning(*pod)
	}), nil
}
开发者ID:kunallimaye,项目名称:kubernetes,代码行数:12,代码来源:storage.go


示例17: Update

func (sr *ServiceRegistryStorage) Update(obj interface{}) (<-chan interface{}, error) {
	srv := obj.(api.Service)
	if srv.ID == "" {
		return nil, fmt.Errorf("ID should not be empty: %#v", srv)
	}
	return apiserver.MakeAsync(func() (interface{}, error) {
		// TODO: check to see if external load balancer status changed
		err := sr.registry.UpdateService(srv)
		if err != nil {
			return nil, err
		}
		return sr.registry.GetService(srv.ID)
	}), nil
}
开发者ID:RubanDeventhiran,项目名称:kubernetes,代码行数:14,代码来源:service_registry.go


示例18: Update

func (rs *REST) Update(obj runtime.Object) (<-chan runtime.Object, error) {
	srv := obj.(*api.Service)
	if errs := validation.ValidateService(srv); len(errs) > 0 {
		return nil, errors.NewInvalid("service", srv.ID, errs)
	}
	return apiserver.MakeAsync(func() (runtime.Object, error) {
		// TODO: check to see if external load balancer status changed
		err := rs.registry.UpdateService(srv)
		if err != nil {
			return nil, err
		}
		return rs.registry.GetService(srv.ID)
	}), nil
}
开发者ID:asim,项目名称:kubernetes,代码行数:14,代码来源:rest.go


示例19: Update

func (storage *PodRegistryStorage) Update(obj interface{}) (<-chan interface{}, error) {
	pod := obj.(api.Pod)
	if len(pod.ID) == 0 {
		return nil, fmt.Errorf("id is unspecified: %#v", pod)
	}

	return apiserver.MakeAsync(func() (interface{}, error) {
		err := storage.registry.UpdatePod(pod)
		if err != nil {
			return nil, err
		}
		return storage.registry.GetPod(pod.ID)
	}), nil
}
开发者ID:jmoretti,项目名称:kubernetes,代码行数:14,代码来源:pod_registry.go


示例20: Update

func (storage *PodRegistryStorage) Update(obj interface{}) (<-chan interface{}, error) {
	pod := obj.(api.Pod)
	if len(pod.ID) == 0 {
		return nil, fmt.Errorf("ID should not be empty: %#v", pod)
	}

	return apiserver.MakeAsync(func() (interface{}, error) {
		err := storage.registry.UpdatePod(pod)
		if err != nil {
			return nil, err
		}
		return storage.waitForPodRunning(pod)
	}), nil
}
开发者ID:redfordtsai,项目名称:kubernetes,代码行数:14,代码来源:pod_registry.go



注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver.MakeAsync函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang apiserver.New函数代码示例发布时间:2022-05-23
下一篇:
Golang apiserver.IsNotFound函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap