本文整理汇总了Golang中github.com/cloudfoundry-incubator/runtime-schema/cc_messages.StagingRequestFromCC类的典型用法代码示例。如果您正苦于以下问题:Golang StagingRequestFromCC类的具体用法?Golang StagingRequestFromCC怎么用?Golang StagingRequestFromCC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StagingRequestFromCC类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: BuildRecipe
func (backend *dockerBackend) BuildRecipe(stagingGuid string, request cc_messages.StagingRequestFromCC) (*models.TaskDefinition, string, string, error) {
logger := backend.logger.Session("build-recipe", lager.Data{"app-id": request.AppId, "staging-guid": stagingGuid})
logger.Info("staging-request")
var lifecycleData cc_messages.DockerStagingData
err := json.Unmarshal(*request.LifecycleData, &lifecycleData)
if err != nil {
return &models.TaskDefinition{}, "", "", err
}
err = backend.validateRequest(request, lifecycleData)
if err != nil {
return &models.TaskDefinition{}, "", "", err
}
compilerURL, err := backend.compilerDownloadURL()
if err != nil {
return &models.TaskDefinition{}, "", "", err
}
cachedDependencies := []*models.CachedDependency{
&models.CachedDependency{
From: compilerURL.String(),
To: path.Dir(DockerBuilderExecutablePath),
CacheKey: "docker-lifecycle",
},
}
runActionArguments := []string{
"-outputMetadataJSONFilename", DockerBuilderOutputPath,
"-dockerRef", lifecycleData.DockerImageUrl,
}
if len(backend.config.InsecureDockerRegistries) > 0 {
insecureDockerRegistries := strings.Join(backend.config.InsecureDockerRegistries, ",")
runActionArguments = append(runActionArguments, "-insecureDockerRegistries", insecureDockerRegistries)
}
fileDescriptorLimit := uint64(request.FileDescriptors)
runAs := "vcap"
actions := []models.ActionInterface{}
if cacheDockerImage(request.Environment) {
runAs = "root"
additionalEgressRules, additionalArgs, err := cachingEgressRulesAndArgs(
logger,
backend.config.DockerRegistryAddress,
backend.config.ConsulCluster,
lifecycleData,
)
if err != nil {
return &models.TaskDefinition{}, "", "", err
}
runActionArguments = append(runActionArguments, additionalArgs...)
request.EgressRules = append(request.EgressRules, additionalEgressRules...)
actions = append(
actions,
models.EmitProgressFor(
&models.RunAction{
Path: MountCgroupsPath,
ResourceLimits: &models.ResourceLimits{
Nofile: &fileDescriptorLimit,
},
User: runAs,
},
"Preparing docker daemon...",
"",
"Failed to set up docker environment",
),
)
}
actions = append(
actions,
models.EmitProgressFor(
&models.RunAction{
Path: DockerBuilderExecutablePath,
Args: runActionArguments,
Env: request.Environment,
ResourceLimits: &models.ResourceLimits{
Nofile: &fileDescriptorLimit,
},
User: runAs,
},
"Staging...",
"Staging Complete",
"Staging Failed",
),
)
annotationJson, _ := json.Marshal(cc_messages.StagingTaskAnnotation{
Lifecycle: DockerLifecycleName,
CompletionCallback: request.CompletionCallback,
})
taskDefinition := &models.TaskDefinition{
//.........这里部分代码省略.........
开发者ID:cfibmers,项目名称:stager,代码行数:101,代码来源:docker_backend.go
示例2: BuildRecipe
func (backend *dockerBackend) BuildRecipe(stagingGuid string, request cc_messages.StagingRequestFromCC) (*models.TaskDefinition, string, string, error) {
logger := backend.logger.Session("build-recipe", lager.Data{"app-id": request.AppId, "staging-guid": stagingGuid})
logger.Info("staging-request")
var lifecycleData cc_messages.DockerStagingData
err := json.Unmarshal(*request.LifecycleData, &lifecycleData)
if err != nil {
return &models.TaskDefinition{}, "", "", err
}
err = backend.validateRequest(request, lifecycleData)
if err != nil {
return &models.TaskDefinition{}, "", "", err
}
compilerURL, err := backend.compilerDownloadURL()
if err != nil {
return &models.TaskDefinition{}, "", "", err
}
cacheDockerImage := false
for _, envVar := range request.Environment {
if envVar.Name == "DIEGO_DOCKER_CACHE" && envVar.Value == "true" {
cacheDockerImage = true
break
}
}
actions := []models.ActionInterface{}
//Download builder
actions = append(
actions,
models.EmitProgressFor(
&models.DownloadAction{
From: compilerURL.String(),
To: path.Dir(DockerBuilderExecutablePath),
CacheKey: "docker-lifecycle",
User: "vcap",
},
"",
"",
"Failed to set up docker environment",
),
)
runActionArguments := []string{"-outputMetadataJSONFilename", DockerBuilderOutputPath, "-dockerRef", lifecycleData.DockerImageUrl}
runAs := "vcap"
if cacheDockerImage {
runAs = "root"
host, port, err := net.SplitHostPort(backend.config.DockerRegistryAddress)
if err != nil {
logger.Debug("invalid docker registry address", lager.Data{"address": backend.config.DockerRegistryAddress, "error": err.Error()})
return &models.TaskDefinition{}, "", "", ErrInvalidDockerRegistryAddress
}
registryServices, err := getDockerRegistryServices(backend.config.ConsulCluster, backend.logger)
if err != nil {
return &models.TaskDefinition{}, "", "", err
}
registryRules := addDockerRegistryRules(request.EgressRules, registryServices)
request.EgressRules = append(request.EgressRules, registryRules...)
registryIPs := strings.Join(buildDockerRegistryAddresses(registryServices), ",")
runActionArguments, err = addDockerCachingArguments(runActionArguments, registryIPs, backend.config.InsecureDockerRegistry, host, port, lifecycleData)
if err != nil {
return &models.TaskDefinition{}, "", "", err
}
}
fileDescriptorLimit := uint64(request.FileDescriptors)
// Run builder
actions = append(
actions,
models.EmitProgressFor(
&models.RunAction{
Path: DockerBuilderExecutablePath,
Args: runActionArguments,
Env: request.Environment,
ResourceLimits: &models.ResourceLimits{
Nofile: &fileDescriptorLimit,
},
User: runAs,
},
"Staging...",
"Staging Complete",
"Staging Failed",
),
)
annotationJson, _ := json.Marshal(cc_messages.StagingTaskAnnotation{
Lifecycle: DockerLifecycleName,
})
taskDefinition := &models.TaskDefinition{
RootFs: models.PreloadedRootFS(backend.config.DockerStagingStack),
ResultFile: DockerBuilderOutputPath,
//.........这里部分代码省略.........
开发者ID:guanglinlv,项目名称:stager,代码行数:101,代码来源:docker_backend.go
示例3:
"github.com/pivotal-golang/lager"
"github.com/pivotal-golang/lager/lagertest"
)
var _ = Describe("DockerBackend", func() {
var (
stagingRequest cc_messages.StagingRequestFromCC
downloadBuilderAction models.ActionInterface
runAction models.ActionInterface
config backend.Config
logger lager.Logger
docker backend.Backend
stagingGuid string
appId string
dockerImageUrl string
dockerLoginServer string
dockerUser string
dockerPassword string
dockerEmail string
fileDescriptors int
memoryMb int32
diskMb int32
timeout int
egressRules []*models.SecurityGroupRule
)
BeforeEach(func() {
appId = "bunny"
dockerImageUrl = "busybox"
dockerLoginServer = ""
开发者ID:guanglinlv,项目名称:stager,代码行数:31,代码来源:docker_backend_test.go
示例4:
)
var _ = Describe("TraditionalBackend", func() {
var (
traditional backend.Backend
stagingRequest cc_messages.StagingRequestFromCC
config backend.Config
buildpackOrder string
timeout int
stack string
memoryMb int32
diskMb int32
fileDescriptors int
buildArtifactsCacheDownloadUri string
appId string
stagingGuid string
buildpacks []cc_messages.Buildpack
appBitsDownloadUri string
downloadBuilderAction models.ActionInterface
downloadAppAction models.ActionInterface
downloadFirstBuildpackAction models.ActionInterface
downloadSecondBuildpackAction models.ActionInterface
downloadBuildArtifactsAction models.ActionInterface
runAction models.ActionInterface
uploadDropletAction models.ActionInterface
uploadBuildArtifactsAction models.ActionInterface
egressRules []*models.SecurityGroupRule
environment []*models.EnvironmentVariable
)
BeforeEach(func() {
stagerURL := "http://the-stager.example.com"
开发者ID:emc-xchallenge,项目名称:stager,代码行数:32,代码来源:buildpack_backend_test.go
示例5:
DockerPassword: password,
DockerEmail: email,
})
Expect(err).NotTo(HaveOccurred())
lifecycleData := json.RawMessage(rawJsonBytes)
Expect(err).NotTo(HaveOccurred())
stagingRequest := cc_messages.StagingRequestFromCC{
AppId: "bunny",
FileDescriptors: 512,
MemoryMB: 512,
DiskMB: 512,
Timeout: 512,
LifecycleData: &lifecycleData,
EgressRules: []*models.SecurityGroupRule{
{
Protocol: "TCP",
Destinations: []string{"0.0.0.0/0"},
PortRange: &models.PortRange{Start: 80, End: 443},
},
},
}
if dockerImageCachingEnabled {
stagingRequest.Environment = append(stagingRequest.Environment, &models.EnvironmentVariable{
Name: "DIEGO_DOCKER_CACHE",
Value: "true",
})
}
开发者ID:emc-xchallenge,项目名称:stager,代码行数:30,代码来源:docker_registry_test.go
示例6:
LifecycleData: &lifecycleData,
}
}
BeforeEach(func() {
loginServer = ""
user = ""
password = ""
email = ""
})
Context("when docker registry is running", func() {
var (
downloadBuilderAction models.ActionInterface
docker backend.Backend
expectedRunAction models.ActionInterface
expectedEgressRules []*models.SecurityGroupRule
insecureDockerRegistry bool
stagingRequest cc_messages.StagingRequestFromCC
)
setupEgressRules := func(ips []string) []*models.SecurityGroupRule {
rules := []*models.SecurityGroupRule{}
for _, ip := range ips {
rules = append(rules, &models.SecurityGroupRule{
Protocol: models.TCPProtocol,
Destinations: []string{ip},
Ports: []uint32{dockerRegistryPort},
})
}
return rules
}
开发者ID:guanglinlv,项目名称:stager,代码行数:32,代码来源:docker_registry_test.go
注:本文中的github.com/cloudfoundry-incubator/runtime-schema/cc_messages.StagingRequestFromCC类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论