Beispiel #1
0
        def convert_image(path, val):
            log.info("Converting %s", path)
            everything = path.configuration.root().wrapped()
            meta = Meta(everything, [])
            configuration.converters.started(path)

            base = path.configuration.root().wrapped()
            base.update(configuration.as_dict(ignore=["images"]))
            base.update(val.as_dict(ignore=["images"]))

            base["__image__"] = base
            everything["__image__"] = base

            base["harpoon"] = configuration["harpoon"]
            base["configuration"] = configuration
            return harpoon_spec.image_spec.normalise(meta.at("images").at(image), base)
Beispiel #2
0
        def convert_image(path, val):
            log.info("Converting %s", path)
            everything = path.configuration.root().wrapped()
            meta = Meta(everything, [])
            configuration.converters.started(path)

            base = path.configuration.root().wrapped()
            base.update(configuration.as_dict(ignore=["images"]))
            base.update(val.as_dict(ignore=["images"]))

            base["__image__"] = base
            everything["__image__"] = base

            base["harpoon"] = configuration["harpoon"]
            base["configuration"] = configuration
            return harpoon_spec.image_spec.normalise(
                meta.at("images").at(image), base)
Beispiel #3
0
            , "ADD something /somewhere"
            , "COPY --from=blah something /somewhere"
            , ["ENV ONE", "{one}"]
            , ["ENV", ["TWO {two}", "THREE {three}"]]
            , ["ADD", {"get": ["blah", "and", "stuff"], "prefix": "/projects"}]
            , {"ADD": {"content": content, "dest": "the_destination"}}
            , {"ADD": {"content": content, "dest": "the_destination2"}}
            , {"ADD": {"content": {"image": "{images.blah2}", "path": "/tmp/stuff"}, "dest": "the_destination3"}}
            , {"COPY": {"from": "{images.blah2}", "path": "/tmp/stuff", "to": "copy_destination"}}
            , {"COPY": {"from": 1, "path": "/tmp/stuff", "to": "copy_destination"}}
            , ["FROM", "{images.blah3}", "as wat"]
            , "COPY --from=wat things stuff"
            , "CMD cacafire"
            ]

        result = self.spec.normalise(meta.at("images").at("blah").at("commands"), commands)
        self.assertEqual([cmd.as_string for cmd in result.commands]
            , [ "FROM somewhere as base"
              , "FROM {0}".format(blah_image)
              , "ADD something /somewhere"
              , "COPY --from=blah something /somewhere"
              , "ENV ONE 1"
              , "ENV TWO 2"
              , "ENV THREE 3"
              , "ADD blah /projects/blah"
              , "ADD and /projects/and"
              , "ADD stuff /projects/stuff"
              , "ADD {0}-the_destination the_destination".format(md5)
              , "ADD {0}-the_destination2 the_destination2".format(md5)
              , "ADD {0}-the_destination3 the_destination3".format(md52)
              , "COPY --from=somewhere-blah2 /tmp/stuff copy_destination"
Beispiel #4
0
            )
        meta = Meta(everything, [])

        commands = [
              ["FROM", "{images.blah}"]
            , "ADD something /somewhere"
            , ["ENV ONE", "{one}"]
            , ["ENV", ["TWO {two}", "THREE {three}"]]
            , ["ADD", {"get": ["blah", "and", "stuff"], "prefix": "/projects"}]
            , {"ADD": {"content": content, "dest": "the_destination"}}
            , {"ADD": {"content": content, "dest": "the_destination2", "mtime": 1530660298}}
            , {"ADD": {"content": {"image": "{images.blah2}", "path": "/tmp/stuff"}, "dest": "the_destination3"}}
            , "CMD cacafire"
            ]

        result = self.spec.normalise(meta.at("images").at("blah").at("commands"), commands)
        self.assertEqual([cmd.as_string for cmd in result.commands]
            , [ "FROM {0}".format(blah_image)
              , "ADD something /somewhere"
              , "ENV ONE 1"
              , "ENV TWO 2"
              , "ENV THREE 3"
              , "ADD blah /projects/blah"
              , "ADD and /projects/and"
              , "ADD stuff /projects/stuff"
              , "ADD {0}-the_destination-mtime(1430660297) the_destination".format(md5)
              , "ADD {0}-the_destination2-mtime(1530660298) the_destination2".format(md5)
              , "ADD {0}-the_destination3-mtime(1430660297) the_destination3".format(md52)
              , "CMD cacafire"
              ]
            )