本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/api.Container类的典型用法代码示例。如果您正苦于以下问题:Golang Container类的具体用法?Golang Container怎么用?Golang Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Container类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: containerWithHostPorts
func containerWithHostPorts(ports ...int) api.Container {
c := api.Container{}
for _, p := range ports {
c.Ports = append(c.Ports, api.Port{HostPort: p})
}
return c
}
开发者ID:asim,项目名称:kubernetes,代码行数:7,代码来源:constraint_test.go
示例2: fakeDeploymentConfig
func fakeDeploymentConfig(name string, containers ...containerDesc) *deployapi.DeploymentConfig {
specContainers := []kapi.Container{}
for _, c := range containers {
container := kapi.Container{
Name: c.name,
}
container.Ports = []kapi.ContainerPort{}
for _, p := range c.ports {
container.Ports = append(container.Ports, kapi.ContainerPort{
Name: fmt.Sprintf("port-%d-%s", p.port, p.protocol),
ContainerPort: p.port,
Protocol: kapi.Protocol(p.protocol),
})
}
specContainers = append(specContainers, container)
}
return &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{
Name: name,
},
Template: deployapi.DeploymentTemplate{
ControllerTemplate: kapi.ReplicationControllerSpec{
Replicas: 1,
Selector: map[string]string{"name": "test"},
Template: &kapi.PodTemplateSpec{
Spec: kapi.PodSpec{
Containers: specContainers,
},
},
},
},
}
}
开发者ID:cjnygard,项目名称:origin,代码行数:35,代码来源:pipeline_test.go
示例3: ToAPIPod
// ToAPIPod converts Pod to api.Pod. Note that if a field in api.Pod has no
// corresponding field in Pod, the field would not be populated.
func (p *Pod) ToAPIPod() *api.Pod {
var pod api.Pod
pod.UID = p.ID
pod.Name = p.Name
pod.Namespace = p.Namespace
pod.Status = p.Status
for _, c := range p.Containers {
var container api.Container
container.Name = c.Name
container.Image = c.Image
pod.Spec.Containers = append(pod.Spec.Containers, container)
}
return &pod
}
开发者ID:nail-lian,项目名称:kubernetes,代码行数:17,代码来源:runtime.go
示例4: validatePullPolicyWithDefault
// TODO(dchen1107): Move this along with other defaulting values
func validatePullPolicyWithDefault(ctr *api.Container) errs.ValidationErrorList {
allErrors := errs.ValidationErrorList{}
// TODO(dchen1107): Move ParseImageName code to pkg/util
if len(ctr.ImagePullPolicy) == 0 {
parts := strings.Split(ctr.Image, ":")
// Check image tag
if parts[len(parts)-1] == "latest" {
ctr.ImagePullPolicy = api.PullAlways
} else {
ctr.ImagePullPolicy = api.PullIfNotPresent
}
}
if ctr.ImagePullPolicy != api.PullAlways &&
ctr.ImagePullPolicy != api.PullIfNotPresent &&
ctr.ImagePullPolicy != api.PullNever {
allErrors = append(allErrors, errs.NewFieldNotSupported("", ctr.ImagePullPolicy))
}
return allErrors
}
开发者ID:hortonworks,项目名称:kubernetes-yarn,代码行数:22,代码来源:validation.go
示例5: convert_v1beta3_Container_To_api_Container
func convert_v1beta3_Container_To_api_Container(in *Container, out *api.Container, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*Container))(in)
}
out.Name = in.Name
out.Image = in.Image
if in.Command != nil {
out.Command = make([]string, len(in.Command))
for i := range in.Command {
out.Command[i] = in.Command[i]
}
}
if in.Args != nil {
out.Args = make([]string, len(in.Args))
for i := range in.Args {
out.Args[i] = in.Args[i]
}
}
out.WorkingDir = in.WorkingDir
if in.Ports != nil {
out.Ports = make([]api.ContainerPort, len(in.Ports))
for i := range in.Ports {
if err := convert_v1beta3_ContainerPort_To_api_ContainerPort(&in.Ports[i], &out.Ports[i], s); err != nil {
return err
}
}
}
if in.Env != nil {
out.Env = make([]api.EnvVar, len(in.Env))
for i := range in.Env {
if err := convert_v1beta3_EnvVar_To_api_EnvVar(&in.Env[i], &out.Env[i], s); err != nil {
return err
}
}
}
if err := s.Convert(&in.Resources, &out.Resources, 0); err != nil {
return err
}
if in.VolumeMounts != nil {
out.VolumeMounts = make([]api.VolumeMount, len(in.VolumeMounts))
for i := range in.VolumeMounts {
if err := convert_v1beta3_VolumeMount_To_api_VolumeMount(&in.VolumeMounts[i], &out.VolumeMounts[i], s); err != nil {
return err
}
}
}
if in.LivenessProbe != nil {
out.LivenessProbe = new(api.Probe)
if err := convert_v1beta3_Probe_To_api_Probe(in.LivenessProbe, out.LivenessProbe, s); err != nil {
return err
}
} else {
out.LivenessProbe = nil
}
if in.ReadinessProbe != nil {
out.ReadinessProbe = new(api.Probe)
if err := convert_v1beta3_Probe_To_api_Probe(in.ReadinessProbe, out.ReadinessProbe, s); err != nil {
return err
}
} else {
out.ReadinessProbe = nil
}
if in.Lifecycle != nil {
out.Lifecycle = new(api.Lifecycle)
if err := convert_v1beta3_Lifecycle_To_api_Lifecycle(in.Lifecycle, out.Lifecycle, s); err != nil {
return err
}
} else {
out.Lifecycle = nil
}
out.TerminationMessagePath = in.TerminationMessagePath
out.ImagePullPolicy = api.PullPolicy(in.ImagePullPolicy)
if in.SecurityContext != nil {
if in.SecurityContext.Capabilities != nil {
if !reflect.DeepEqual(in.SecurityContext.Capabilities.Add, in.Capabilities.Add) ||
!reflect.DeepEqual(in.SecurityContext.Capabilities.Drop, in.Capabilities.Drop) {
return fmt.Errorf("container capability settings do not match security context settings, cannot convert")
}
}
if in.SecurityContext.Privileged != nil {
if in.Privileged != *in.SecurityContext.Privileged {
return fmt.Errorf("container privileged settings do not match security context settings, cannot convert")
}
}
}
if in.SecurityContext != nil {
out.SecurityContext = new(api.SecurityContext)
if err := convert_v1beta3_SecurityContext_To_api_SecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil {
return err
}
} else {
out.SecurityContext = nil
}
return nil
}
开发者ID:cjnygard,项目名称:origin,代码行数:95,代码来源:conversion.go
注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/api.Container类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论