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),
	}
}
Example #2
0
			"Staging Complete",
			"Staging Failed",
		)

		egressRules = []*models.SecurityGroupRule{
			{
				Protocol:     "TCP",
				Destinations: []string{"0.0.0.0/0"},
				PortRange:    &models.PortRange{Start: 80, End: 443},
			},
		}
	})

	JustBeforeEach(func() {
		logger = lagertest.NewTestLogger("test")
		docker = backend.NewDockerBackend(config, logger)

		rawJsonBytes, err := json.Marshal(cc_messages.DockerStagingData{
			DockerImageUrl:    dockerImageUrl,
			DockerLoginServer: dockerLoginServer,
			DockerUser:        dockerUser,
			DockerPassword:    dockerPassword,
			DockerEmail:       dockerEmail,
		})
		Expect(err).NotTo(HaveOccurred())
		lifecycleData := json.RawMessage(rawJsonBytes)

		stagingRequest = cc_messages.StagingRequestFromCC{
			AppId:           appId,
			LogGuid:         "log-guid",
			FileDescriptors: fileDescriptors,
	) backend.Backend {
		config := backend.Config{
			FileServerURL:            "http://file-server.com",
			CCUploaderURL:            "http://cc-uploader.com",
			ConsulCluster:            consulCluster.URL(),
			DockerRegistryAddress:    dockerRegistryAddress,
			InsecureDockerRegistries: insecureDockerRegistries,
			Lifecycles: map[string]string{
				"docker": "docker_lifecycle/docker_app_lifecycle.tgz",
			},
		}

		logger := lager.NewLogger("fakelogger")
		logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG))

		return backend.NewDockerBackend(config, logger)
	}

	setupStagingRequest := func(dockerImageCachingEnabled bool, loginServer, user, password, email string) cc_messages.StagingRequestFromCC {
		rawJsonBytes, err := json.Marshal(cc_messages.DockerStagingData{
			DockerImageUrl:    "busybox",
			DockerLoginServer: loginServer,
			DockerUser:        user,
			DockerPassword:    password,
			DockerEmail:       email,
		})
		Expect(err).NotTo(HaveOccurred())
		lifecycleData := json.RawMessage(rawJsonBytes)

		Expect(err).NotTo(HaveOccurred())