Пример #1
0
 def test_given_a_component_with_a_docker_image(self):
     self.assert_complete(
         "components:\n"
         "   server:\n"
         "      provides_services: [ Wonderful ]\n"
         "      implementation:\n"
         "         docker:\n"
         "            image: fchauvel/camp:dev\n"
         "goals:\n"
         "   running:\n"
         "      - Wonderful\n",
         expectations={
             "services": ["Wonderful"],
             "features": [],
             "components": {
                 "server": {
                     "provided_services": ["Wonderful"],
                     "required_services": [],
                     "provided_features": [],
                     "required_features": [],
                     "implementation": DockerImage("fchauvel/camp:dev"),
                     "variables": {}
                 }
             },
             "goals": {
                 "services": ["Wonderful"],
                 "features": []
             }
         })
Пример #2
0
    def test_when_a_component_host_is_implemented_by_a_docker_image(self):
        model = Model(
            [
                Component("server",
                          provided_services=[Service("Awesome")],
                          required_features=[Feature("JDK")],
                          implementation=DockerFile("server/Dockerfile")),
                Component("jdk",
                          provided_features=[Feature("JDK")],
                          implementation=DockerImage("fchauvel/test:1.0.1")),
            ],
            Goals(services=[Service("Awesome")])
        )

        server_0 = Instance("server_0", model.resolve("server"))
        jdk_0 = Instance("jdk_0", model.resolve("jdk"))
        server_0.feature_provider = jdk_0

        configuration = Configuration( model, [ server_0,
                                                jdk_0 ])
        self.build(configuration)

        self.assert_generated(
            "config_0/images/server_0/Dockerfile",
            with_patterns=[
                "FROM fchauvel/test:1.0.1"
            ])
Пример #3
0
    def test_when_a_component_is_implemented_by_a_docker_image(self):

        model = Model([
            Component("server",
                      provided_services=[Service("Awesome")],
                      implementation=DockerImage("fchauvel/test:1.0.0"))
        ], Goals(services=[Service("Awesome")]))

        instance = Instance("server_0", model.resolve("server"))
        configuration = Configuration(model, [instance])

        self.build(configuration)

        self.assert_no_image_generated(0)
Пример #4
0
    def _parse_docker(self, name, data):
        docker = None
        for key, item in data.items():
            if key == Keys.FILE:
                docker = DockerFile(self._escape(item))
            elif key == Keys.IMAGE:
                docker = DockerImage(self._escape(item))
            else:
                self._ignore(Keys.COMPONENTS, name, Keys.IMPLEMENTATION,
                             Keys.DOCKER, key)

        if not docker:
            self._missing([Keys.FILE, Keys.IMAGE], Keys.COMPONENTS, name,
                          Keys.IMPLEMENTATION, Keys.DOCKER)

        return docker