Example #1
0
func initializeBackends(logger lager.Logger, lifecycles flags.LifecycleMap) map[string]backend.Backend {
	_, err := url.Parse(*stagingTaskCallbackURL)
	if err != nil {
		logger.Fatal("Invalid staging task callback url", err)
	}
	if *dockerStagingStack == "" {
		logger.Fatal("Invalid Docker staging stack", errors.New("dockerStagingStack cannot be blank"))
	}

	_, err = url.Parse(*consulCluster)
	if err != nil {
		logger.Fatal("Error parsing consul agent URL", err)
	}
	_, err = url.Parse(*dockerRegistryAddress)
	if err != nil {
		logger.Fatal("Error parsing Docker Registry address", err)
	}

	config := backend.Config{
		TaskDomain:               cc_messages.StagingTaskDomain,
		StagerURL:                *stagingTaskCallbackURL,
		FileServerURL:            *fileServerURL,
		CCUploaderURL:            *ccUploaderURL,
		Lifecycles:               lifecycles,
		DockerRegistryAddress:    *dockerRegistryAddress,
		InsecureDockerRegistries: insecureDockerRegistries.Values(),
		ConsulCluster:            *consulCluster,
		SkipCertVerify:           *skipCertVerify,
		PrivilegedContainers:     *privilegedContainers,
		Sanitizer:                backend.SanitizeErrorMessage,
		DockerStagingStack:       *dockerStagingStack,
	}

	return map[string]backend.Backend{
		"buildpack": backend.NewTraditionalBackend(config, logger),
		"docker":    backend.NewDockerBackend(config, logger),
	}
}
			FileServerURL: "http://file-server.com",
			CCUploaderURL: "http://cc-uploader.com",
			Lifecycles: map[string]string{
				"buildpack/penguin":                "penguin-compiler",
				"buildpack/rabbit_hole":            "rabbit-hole-compiler",
				"buildpack/compiler_with_full_url": "http://the-full-compiler-url",
				"buildpack/compiler_with_bad_url":  "ftp://the-bad-compiler-url",
			},
			Sanitizer: func(msg string) *cc_messages.StagingError {
				return &cc_messages.StagingError{Message: msg + " was totally sanitized"}
			},
		}

		logger := lagertest.NewTestLogger("test")

		traditional = backend.NewTraditionalBackend(config, logger)

		timeout = 900
		stack = "rabbit_hole"
		memoryMb = 2048
		diskMb = 3072
		fileDescriptors = 512
		buildArtifactsCacheDownloadUri = "http://example-uri.com/bunny-droppings"
		appId = "bunny"
		buildpacks = []cc_messages.Buildpack{
			{Name: "zfirst", Key: "zfirst-buildpack", Url: "first-buildpack-url"},
			{Name: "asecond", Key: "asecond-buildpack", Url: "second-buildpack-url"},
		}
		appBitsDownloadUri = "http://example-uri.com/bunny"

		downloadBuilderAction = models.EmitProgressFor(