当前位置: 首页>>代码示例>>Golang>>正文


Golang api.ServiceSpec类代码示例

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


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

示例1: ServiceSpec

func ServiceSpec(srvcSpecs []interface{}) api.ServiceSpec {
	if len(srvcSpecs) == 0 {
		return api.ServiceSpec{}
	}

	userServiceSpec := srvcSpecs[0].(map[string]interface{})

	srvcSpec := api.ServiceSpec{
		Ports: ServicePorts(userServiceSpec["ports"].([]interface{})),
	}

	if _, ok := userServiceSpec["selector"]; ok {
		srvcSpec.Selector = convertMapTypeToStringMap(userServiceSpec["selector"].(map[string]interface{}))
	}

	if _, ok := userServiceSpec["cluster_ip"]; ok {
		srvcSpec.ClusterIP = userServiceSpec["cluster_ip"].(string)
	}

	if _, ok := userServiceSpec["type"]; ok {
		srvcSpec.Type = api.ServiceType(userServiceSpec["type"].(string))
	}

	if _, ok := userServiceSpec["session_affinity"]; ok {
		srvcSpec.SessionAffinity = api.ServiceAffinity(userServiceSpec["session_affinity"].(string))
	}

	return srvcSpec
}
开发者ID:brendangibat,项目名称:terraform-provider-kubernetes,代码行数:29,代码来源:service.go

示例2: convert_v1_ServiceSpec_To_api_ServiceSpec

func convert_v1_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.ServiceSpec, s conversion.Scope) error {
	if err := autoconvert_v1_ServiceSpec_To_api_ServiceSpec(in, out, s); err != nil {
		return err
	}
	// Prefer the legacy deprecatedPublicIPs field, if provided.
	if len(in.DeprecatedPublicIPs) > 0 {
		out.ExternalIPs = nil
		for _, ip := range in.DeprecatedPublicIPs {
			out.ExternalIPs = append(out.ExternalIPs, ip)
		}
	}
	return nil
}
开发者ID:resouer,项目名称:contrib,代码行数:13,代码来源:conversion.go

示例3: Convert_v1_ServiceSpec_To_api_ServiceSpec

func Convert_v1_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.ServiceSpec, s conversion.Scope) error {
	if err := autoConvert_v1_ServiceSpec_To_api_ServiceSpec(in, out, s); err != nil {
		return err
	}
	// Prefer the legacy deprecatedPublicIPs field, if provided.
	if len(in.DeprecatedPublicIPs) > 0 {
		out.ExternalIPs = in.DeprecatedPublicIPs
	}
	return nil
}
开发者ID:spxtr,项目名称:contrib,代码行数:10,代码来源:conversion.go

示例4: convert_v1beta3_ServiceSpec_To_api_ServiceSpec

func convert_v1beta3_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.ServiceSpec, s conversion.Scope) error {
	if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
		defaulting.(func(*ServiceSpec))(in)
	}
	if in.Ports != nil {
		out.Ports = make([]api.ServicePort, len(in.Ports))
		for i := range in.Ports {
			if err := convert_v1beta3_ServicePort_To_api_ServicePort(&in.Ports[i], &out.Ports[i], s); err != nil {
				return err
			}
		}
	} else {
		out.Ports = nil
	}
	if in.Selector != nil {
		out.Selector = make(map[string]string)
		for key, val := range in.Selector {
			out.Selector[key] = val
		}
	} else {
		out.Selector = nil
	}
	out.ClusterIP = in.PortalIP

	typeIn := in.Type
	if typeIn == "" {
		if in.CreateExternalLoadBalancer {
			typeIn = ServiceTypeLoadBalancer
		} else {
			typeIn = ServiceTypeClusterIP
		}
	}
	if err := s.Convert(&typeIn, &out.Type, 0); err != nil {
		return err
	}

	if in.PublicIPs != nil {
		out.ExternalIPs = make([]string, len(in.PublicIPs))
		for i := range in.PublicIPs {
			out.ExternalIPs[i] = in.PublicIPs[i]
		}
	} else {
		out.ExternalIPs = nil
	}
	out.SessionAffinity = api.ServiceAffinity(in.SessionAffinity)
	out.LoadBalancerIP = in.LoadBalancerIP
	return nil
}
开发者ID:johnmccawley,项目名称:origin,代码行数:48,代码来源:conversion.go


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