本文整理汇总了Golang中github.com/openshift/geard/containers/jobs.Response.WritePendingSuccess方法的典型用法代码示例。如果您正苦于以下问题:Golang Response.WritePendingSuccess方法的具体用法?Golang Response.WritePendingSuccess怎么用?Golang Response.WritePendingSuccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/openshift/geard/containers/jobs.Response
的用法示例。
在下文中一共展示了Response.WritePendingSuccess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Execute
func (req *installContainer) Execute(resp jobs.Response) {
id := req.Id
unitName := id.UnitNameFor()
unitPath := id.UnitPathFor()
unitVersionPath := id.VersionedUnitPathFor(req.RequestIdentifier.String())
socketUnitName := id.SocketUnitNameFor()
socketUnitPath := id.SocketUnitPathFor()
var socketActivationType string
if req.SocketActivation {
socketActivationType = "enabled"
if !req.SkipSocketProxy {
socketActivationType = "proxied"
}
}
// attempt to download the environment if it is remote
env := req.Environment
if env != nil {
if err := env.Fetch(100 * 1024); err != nil {
resp.Failure(ErrContainerCreateFailed)
return
}
if env.Empty() {
env = nil
}
}
// open and lock the base path (to prevent simultaneous updates)
state, exists, err := utils.OpenFileExclusive(unitPath, 0664)
if err != nil {
log.Print("install_container: Unable to lock unit file: ", err)
resp.Failure(ErrContainerCreateFailed)
}
defer state.Close()
// write a new file to disk that describes the new service
unit, err := utils.CreateFileExclusive(unitVersionPath, 0664)
if err != nil {
log.Print("install_container: Unable to open unit file definition: ", err)
resp.Failure(ErrContainerCreateFailed)
return
}
defer unit.Close()
// if this is an existing container, read the currently reserved ports
existingPorts := port.PortPairs{}
if exists {
existingPorts, err = containers.GetExistingPorts(id)
if err != nil {
if _, ok := err.(*os.PathError); !ok {
log.Print("install_container: Unable to read existing ports from file: ", err)
resp.Failure(ErrContainerCreateFailed)
return
}
}
}
// allocate and reserve ports for this container
reserved, erra := portReserver.AtomicReserveExternalPorts(unitVersionPath, req.Ports, existingPorts)
if erra != nil {
log.Printf("install_container: Unable to reserve external ports: %+v", erra)
resp.Failure(ErrContainerCreateFailedPortsReserved)
return
}
if len(reserved) > 0 {
resp.WritePendingSuccess(PendingPortMappingName, reserved)
}
var portSpec string
if req.Simple && len(reserved) == 0 {
portSpec = "-P"
} else {
portSpec = dockerPortSpec(reserved)
}
// write the environment to disk
var environmentPath string
if env != nil {
if errw := env.Write(false); errw != nil {
resp.Failure(ErrContainerCreateFailed)
return
}
environmentPath = env.Id.EnvironmentPathFor()
}
// write the network links (if any) to disk
if req.NetworkLinks != nil {
if errw := req.NetworkLinks.Write(id.NetworkLinksPathFor(), false); errw != nil {
resp.Failure(ErrContainerCreateFailed)
return
}
}
var sliceName string
if "" == req.SystemdSlice {
sliceName = DefaultSlice
} else {
sliceNames := []string{}
sliceFound := false
//.........这里部分代码省略.........