本文整理匯總了Golang中k8s/io/kubernetes/pkg/api.ServiceSpec.Selector方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceSpec.Selector方法的具體用法?Golang ServiceSpec.Selector怎麽用?Golang ServiceSpec.Selector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/api.ServiceSpec
的用法示例。
在下文中一共展示了ServiceSpec.Selector方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例2: 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
}