本文整理匯總了Golang中k8s/io/kubernetes/pkg/api.ContainerPort.Protocol方法的典型用法代碼示例。如果您正苦於以下問題:Golang ContainerPort.Protocol方法的具體用法?Golang ContainerPort.Protocol怎麽用?Golang ContainerPort.Protocol使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/api.ContainerPort
的用法示例。
在下文中一共展示了ContainerPort.Protocol方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: buildContainerPorts
func buildContainerPorts(userPorts []interface{}) []api.ContainerPort {
if len(userPorts) == 0 {
return nil
}
var ports []api.ContainerPort
for _, p := range userPorts {
userPort := p.(map[string]interface{})
port := api.ContainerPort{
ContainerPort: userPort["container_port"].(int),
}
if _, ok := userPort["host_port"]; ok {
port.HostPort = userPort["host_port"].(int)
}
if _, ok := userPort["name"]; ok {
port.Name = userPort["name"].(string)
}
if _, ok := userPort["protocol"]; ok {
port.Protocol = api.Protocol(userPort["protocol"].(string))
}
if _, ok := userPort["host_ip"]; ok {
port.HostIP = userPort["host_ip"].(string)
}
ports = append(ports, port)
}
return ports
}
開發者ID:kelcecil,項目名稱:terraform-provider-kubernetes,代碼行數:31,代碼來源:build_kubernetes_resource_controller.go
示例2: deepCopy_api_ContainerPort
func deepCopy_api_ContainerPort(in api.ContainerPort, out *api.ContainerPort, c *conversion.Cloner) error {
out.Name = in.Name
out.HostPort = in.HostPort
out.ContainerPort = in.ContainerPort
out.Protocol = in.Protocol
out.HostIP = in.HostIP
return nil
}
示例3: writeContainerPort
func writeContainerPort(m map[string]interface{}, item *api.ContainerPort) {
if x, ok := m["name"].(string); ok {
item.Name = x
}
if x, ok := m["host_port"].(int); ok {
item.HostPort = x
}
if x, ok := m["host_ip"].(string); ok {
item.HostIP = x
}
if x, ok := m["container_port"].(int); ok {
item.ContainerPort = x
}
if x, ok := m["protocol"].(string); ok {
item.Protocol = api.Protocol(x)
}
}