本文整理匯總了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{
//.........這裏部分代碼省略.........
示例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,
//.........這裏部分代碼省略.........
示例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 = ""
示例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"
示例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",
})
}
示例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
}