本文整理汇总了Golang中github.com/hyperhq/runv/hypervisor/pod.UserContainer类的典型用法代码示例。如果您正苦于以下问题:Golang UserContainer类的具体用法?Golang UserContainer怎么用?Golang UserContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserContainer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ProcessPodBytes
func ProcessPodBytes(body []byte, podId string) (*pod.UserPod, error) {
var containers []pod.UserContainer
var serviceDir string = path.Join(utils.HYPER_ROOT, "services", podId)
userPod, err := pod.ProcessPodBytes(body)
if err != nil {
glog.V(1).Infof("Process POD file error: %s", err.Error())
return nil, err
}
if len(userPod.Services) == 0 {
return userPod, nil
}
userPod.Type = "service-discovery"
serviceContainer := pod.UserContainer{
Name: ServiceDiscoveryContainerName(userPod.Name),
Image: servicediscovery.ServiceImage,
Command: []string{"haproxy", "-D", "-f", "/usr/local/etc/haproxy/haproxy.cfg", "-p", "/var/run/haproxy.pid"},
}
serviceVolRef := pod.UserVolumeReference{
Volume: "service-volume",
Path: servicediscovery.ServiceVolume,
ReadOnly: false,
}
/* PrepareServices will check service volume */
serviceVolume := pod.UserVolume{
Name: "service-volume",
Source: serviceDir,
Driver: "vfs",
}
userPod.Volumes = append(userPod.Volumes, serviceVolume)
serviceContainer.Volumes = append(serviceContainer.Volumes, serviceVolRef)
containers = append(containers, serviceContainer)
for _, c := range userPod.Containers {
containers = append(containers, c)
}
userPod.Containers = containers
return userPod, nil
}
开发者ID:m1911,项目名称:hyper,代码行数:48,代码来源:servicediscovery.go
示例2: processImageVolumes
func (p *Pod) processImageVolumes(config *dockertypes.ContainerJSON, id string, container *pod.UserContainer) {
if config.Config.Volumes == nil {
return
}
userPod := p.Spec
existed := make(map[string]bool)
for _, v := range container.Volumes {
existed[v.Path] = true
}
for tgt := range config.Config.Volumes {
if _, ok := existed[tgt]; ok {
continue
}
n := id + strings.Replace(tgt, "/", "_", -1)
v := pod.UserVolume{
Name: n,
Source: "",
}
r := pod.UserVolumeReference{
Volume: n,
Path: tgt,
ReadOnly: false,
}
p.volumes[n] = &hypervisor.VolumeInfo{Name: n, DockerVolume: true}
userPod.Volumes = append(userPod.Volumes, v)
container.Volumes = append(container.Volumes, r)
}
}
开发者ID:juito,项目名称:hyper,代码行数:33,代码来源:pod.go
示例3: ParseServiceDiscovery
func ParseServiceDiscovery(id string, spec *pod.UserPod) error {
var containers []pod.UserContainer
var serviceType string = "service-discovery"
var serviceDir string = path.Join(utils.HYPER_ROOT, "services", id)
if len(spec.Services) == 0 || spec.Type == serviceType {
return nil
}
spec.Type = serviceType
serviceContainer := pod.UserContainer{
Name: ServiceDiscoveryContainerName(spec.Name),
Image: servicediscovery.ServiceImage,
Command: []string{"haproxy", "-D", "-f", "/usr/local/etc/haproxy/haproxy.cfg", "-p", "/var/run/haproxy.pid"},
}
serviceVolRef := pod.UserVolumeReference{
Volume: "service-volume",
Path: servicediscovery.ServiceVolume,
ReadOnly: false,
}
/* PrepareServices will check service volume */
serviceVolume := pod.UserVolume{
Name: "service-volume",
Source: serviceDir,
Driver: "vfs",
}
spec.Volumes = append(spec.Volumes, serviceVolume)
serviceContainer.Volumes = append(serviceContainer.Volumes, serviceVolRef)
containers = append(containers, serviceContainer)
for _, c := range spec.Containers {
containers = append(containers, c)
}
spec.Containers = containers
return nil
}
开发者ID:juito,项目名称:hyper,代码行数:43,代码来源:servicediscovery.go
示例4: processImageVolumes
func processImageVolumes(config *dockertypes.ContainerJSONRaw, id string, userPod *pod.UserPod, container *pod.UserContainer) {
if config.Config.Volumes == nil {
return
}
for tgt := range config.Config.Volumes {
n := id + strings.Replace(tgt, "/", "_", -1)
v := pod.UserVolume{
Name: n,
Source: "",
}
r := pod.UserVolumeReference{
Volume: n,
Path: tgt,
ReadOnly: false,
}
userPod.Volumes = append(userPod.Volumes, v)
container.Volumes = append(container.Volumes, r)
}
}
开发者ID:Astray-git,项目名称:hyper,代码行数:20,代码来源:pod.go
示例5: processImageVolumes
func processImageVolumes(config *dockertypes.ContainerJSONRaw, id string, userPod *pod.UserPod, container *pod.UserContainer) {
if config.Config.Volumes == nil {
return
}
for tgt := range config.Config.Volumes {
n := id + "-" + tgt
v := pod.UserVolume{
Name: n,
Source: "",
Driver: "vfs", //will check if it should equal to the storage engine, and it should be reclaim after
//after the container finished
}
r := pod.UserVolumeReference{
Volume: n,
Path: tgt,
ReadOnly: false,
}
userPod.Volumes = append(userPod.Volumes, v)
container.Volumes = append(container.Volumes, r)
}
}
开发者ID:WeiZhang555,项目名称:hyper,代码行数:22,代码来源:pod.go
示例6: convertToRunvContainerSpec
func convertToRunvContainerSpec(v *apitypes.UserContainer, podTTY bool) pod.UserContainer {
container := pod.UserContainer{
Tty: v.Tty || podTTY,
Name: v.Name,
Image: v.Image,
Command: v.Command,
Workdir: v.Workdir,
Entrypoint: v.Entrypoint,
Sysctl: v.Sysctl,
RestartPolicy: v.RestartPolicy,
Labels: v.Labels,
}
if v.User != nil {
container.User = pod.UserUser{
Name: v.User.Name,
Group: v.User.Group,
AdditionalGroups: v.User.AdditionalGroups,
}
}
if len(v.Ports) > 0 {
ports := make([]pod.UserContainerPort, 0, len(v.Ports))
for _, p := range v.Ports {
ports = append(ports, pod.UserContainerPort{
Protocol: p.Protocol,
ContainerPort: int(p.ContainerPort),
ServicePort: int(p.ServicePort),
HostPort: int(p.HostPort),
})
}
container.Ports = ports
}
if len(v.Envs) > 0 {
envs := make([]pod.UserEnvironmentVar, 0, len(v.Envs))
for _, env := range v.Envs {
envs = append(envs, pod.UserEnvironmentVar{
Env: env.Env,
Value: env.Value,
})
}
container.Envs = envs
}
if len(v.Volumes) > 0 {
volumes := make([]pod.UserVolumeReference, 0, len(v.Volumes))
for _, vol := range v.Volumes {
volumes = append(volumes, pod.UserVolumeReference{
Path: vol.Path,
ReadOnly: vol.ReadOnly,
Volume: vol.Volume,
})
}
container.Volumes = volumes
}
if len(v.Files) > 0 {
files := make([]pod.UserFileReference, 0, len(v.Files))
for _, f := range v.Files {
files = append(files, pod.UserFileReference{
Path: f.Path,
Filename: f.Filename,
Perm: f.Perm,
User: f.User,
Group: f.Group,
})
}
container.Files = files
}
return container
}
开发者ID:juito,项目名称:hyper,代码行数:73,代码来源:pod.go
注:本文中的github.com/hyperhq/runv/hypervisor/pod.UserContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论