Esempio n. 1
0
    def plan_layers(self, layers, output_files):
        next_config = BuildConfig()
        next_config.add_config(layers["layers"][0].config)

        layers["layers"][-1].url = self.name

        for i, layer in enumerate(layers["layers"]):
            log.info("Processing layer: %s%s", layer.url,
                     "" if 'deps' in layer.directory.splitall()
                     else " (from %s)" % layer.directory.relpath())
            if i + 1 < len(layers["layers"]):
                next_layer = layers["layers"][i + 1]
                next_config = next_config.add_config(next_layer.config)
            else:
                # Add an empty level to the configs to represent that there
                # is no layer after the current one.  This is important for
                # the IgnoreTactic, which needs to look ahead so that it can
                # handle ignoring entire directories.
                next_config = next_config.add_config({})
            list(e for e in utils.walk(layer.directory,
                                       self.build_tactics,
                                       layer=layer,
                                       next_config=next_config,
                                       output_files=output_files))
        plan = [t for t in output_files.values() if t]
        return plan
Esempio n. 2
0
 def test_tactics(self):
     # configure from empty and a layer with tactics
     c = BuildConfig()
     c._tactics = ['a', 'b', 'c']
     c = c.new_child()
     c._tactics = ['d', 'c']
     self.assertEqual(c.tactics[:5], ['d', 'c', 'a', 'b', 'c'])
Esempio n. 3
0
    def plan_layers(self, layers, output_files):
        config = BuildConfig()
        cfgfn = layers["layers"][0] / BuildConfig.DEFAULT_FILE
        if cfgfn.exists():
            config = config.add_config(
                cfgfn, True)
        else:
            cfgfn = layers["layers"][0] / BuildConfig.OLD_CONFIG
            config = config.add_config(
                cfgfn, True)

        layers["layers"][-1].url = self.name

        for i, layer in enumerate(layers["layers"]):
            log.info("Processing layer: %s", layer.url)
            if i + 1 < len(layers["layers"]):
                next_layer = layers["layers"][i + 1]
                config = config.add_config(
                    next_layer / BuildConfig.DEFAULT_FILE, True)
            list(e for e in utils.walk(layer.directory,
                                       self.build_tactics,
                                       current=layer,
                                       config=config,
                                       output_files=output_files))
        plan = [t for t in output_files.values() if t]
        return plan
Esempio n. 4
0
 def test_tactics(self):
     # configure from empty and a layer with tactics
     c = BuildConfig()
     c._tactics = ["a", "b", "c"]
     c = c.new_child()
     c._tactics = ["d", "c"]
     self.assertEqual(c.tactics()[:5], ["d", "c", "a", "b", "c"])
Esempio n. 5
0
 def test_rget(self):
     c = BuildConfig()
     c['a'] = 1
     c = c.new_child()
     c['a'] = 99
     c['b'] = "alpha"
     self.assertEqual(c.get('a'), 99)
     self.assertEqual(c.get('b'), "alpha")
     self.assertEqual(c.rget('a'), [99, 1])
Esempio n. 6
0
 def test_rget(self):
     c = BuildConfig()
     c["a"] = 1
     c = c.new_child()
     c["a"] = 99
     c["b"] = "alpha"
     self.assertEqual(c.get("a"), 99)
     self.assertEqual(c.get("b"), "alpha")
     self.assertEqual(c.rget("a"), [99, 1])
Esempio n. 7
0
 def __init__(self):
     self.config = BuildConfig()
     self.force = False
     self._name = None
     self._charm = None
     self._top_layer = None
     self.hide_metrics = False
Esempio n. 8
0
class Configable(object):
    CONFIG_FILE = None

    def __init__(self):
        self._config = BuildConfig()
        self.config_file = None

    @property
    def config(self):
        if self._config.configured:
            return self._config
        if self.config_file and self.config_file.exists():
            self._config.configure(self.config_file)
        return self._config

    @property
    def configured(self):
        return bool(self.config is not None and self.config.configured)
Esempio n. 9
0
class Configable(object):
    CONFIG_FILE = None

    def __init__(self):
        self._config = BuildConfig()
        self.config_file = None

    @property
    def config(self):
        if self._config.configured:
            return self._config
        if self.config_file and self.config_file.exists():
            self._config.configure(self.config_file)
        return self._config

    @property
    def configured(self):
        return bool(self.config is not None and self.config.configured)
Esempio n. 10
0
 def __init__(self):
     self.config = BuildConfig()
     self.force = False
     self._name = None
     self._charm = None
     self._top_layer = None
     self.hide_metrics = os.environ.get('CHARM_HIDE_METRICS', False)
     self.wheelhouse_overrides = None
     self._warned_home = False
Esempio n. 11
0
 def __init__(self):
     self.config = BuildConfig()
     self.force = False
     self._name = None
     self._charm = None
     self._top_layer = None
     self.hide_metrics = False
     self.wheelhouse_overrides = None
     self._warned_home = False
Esempio n. 12
0
    def plan_layers(self, layers, output_files):
        current_config = BuildConfig()
        next_config = current_config.add_config(layers["layers"][0].config)

        layers["layers"][-1].url = self.name

        for i, layer in enumerate(layers["layers"]):
            log.info(
                "Processing layer: %s%s", layer.url,
                "" if layer.directory.startswith(self.cache_dir) else
                " (from %s)" % layer.directory.relpath())
            current_config = current_config.add_config(layer.config)
            if i + 1 < len(layers["layers"]):
                next_layer = layers["layers"][i + 1]
                next_config = next_config.add_config(next_layer.config)
            else:
                # Add an empty level to the configs to represent that there
                # is no layer after the current one.  This is important for
                # the IgnoreTactic, which needs to look ahead so that it can
                # handle ignoring entire directories.
                next_config = next_config.add_config({})
            list(e for e in utils.walk(layer.directory,
                                       self.build_tactics,
                                       layer=layer,
                                       next_config=next_config,
                                       current_config=current_config,
                                       output_files=output_files))
        if self.wheelhouse_overrides:
            existing_tactic = output_files.get('wheelhouse.txt')
            wh_over_layer = Layer('--wheelhouse-overrides',
                                  layers["layers"][-1].target_repo.dirname())
            wh_over_layer.directory = layers["layers"][-1].directory
            output_files['wheelhouse.txt'] = WheelhouseTactic(
                self.wheelhouse_overrides,
                self.target,
                wh_over_layer,
                next_config,
            )
            output_files['wheelhouse.txt'].purge_wheels = True
            if existing_tactic is not None:
                output_files['wheelhouse.txt'].combine(existing_tactic)
        plan = [t for t in output_files.values() if t]
        return plan
Esempio n. 13
0
    def plan_layers(self, layers, output_files):
        next_config = BuildConfig()
        next_config.add_config(layers["layers"][0].config)

        layers["layers"][-1].url = self.name

        for i, layer in enumerate(layers["layers"]):
            log.info(
                "Processing layer: %s%s", layer.url,
                "" if 'deps' in layer.directory.splitall() else " (from %s)" %
                layer.directory.relpath())
            if i + 1 < len(layers["layers"]):
                next_layer = layers["layers"][i + 1]
                next_config = next_config.add_config(next_layer.config)
            else:
                # Add an empty level to the configs to represent that there
                # is no layer after the current one.  This is important for
                # the IgnoreTactic, which needs to look ahead so that it can
                # handle ignoring entire directories.
                next_config = next_config.add_config({})
            list(e for e in utils.walk(layer.directory,
                                       self.build_tactics,
                                       layer=layer,
                                       next_config=next_config,
                                       output_files=output_files))
        plan = [t for t in output_files.values() if t]
        return plan
Esempio n. 14
0
    def plan_layers(self, layers, output_files):
        current_config = BuildConfig()
        next_config = current_config.add_config(layers["layers"][0].config)

        layers["layers"][-1].url = self.name

        for i, layer in enumerate(layers["layers"]):
            log.info("Processing layer: %s%s", layer.url,
                     "" if layer.directory.startswith(self.cache_dir)
                     else " (from %s)" % layer.directory.relpath())
            current_config = current_config.add_config(layer.config)
            if i + 1 < len(layers["layers"]):
                next_layer = layers["layers"][i + 1]
                next_config = next_config.add_config(next_layer.config)
            else:
                # Add an empty level to the configs to represent that there
                # is no layer after the current one.  This is important for
                # the IgnoreTactic, which needs to look ahead so that it can
                # handle ignoring entire directories.
                next_config = next_config.add_config({})
            list(e for e in utils.walk(layer.directory,
                                       self.build_tactics,
                                       layer=layer,
                                       next_config=next_config,
                                       current_config=current_config,
                                       output_files=output_files))
        if self.wheelhouse_overrides:
            existing_tactic = output_files.get('wheelhouse.txt')
            output_files['wheelhouse.txt'] = WheelhouseTactic(
                str(self.wheelhouse_overrides),
                self.target,
                layers["layers"][-1],
                next_config,
            )
            output_files['wheelhouse.txt'].purge_wheels = True
            if existing_tactic is not None:
                output_files['wheelhouse.txt'].combine(existing_tactic)
        plan = [t for t in output_files.values() if t]
        return plan
Esempio n. 15
0
    def plan_layers(self, layers, output_files):
        config = BuildConfig()
        cfgfn = layers["layers"][0] / BuildConfig.DEFAULT_FILE
        if cfgfn.exists():
            config = config.add_config(cfgfn, True)
        else:
            cfgfn = layers["layers"][0] / BuildConfig.OLD_CONFIG
            config = config.add_config(cfgfn, True)

        layers["layers"][-1].url = self.name

        for i, layer in enumerate(layers["layers"]):
            log.info("Processing layer: %s", layer.url)
            if i + 1 < len(layers["layers"]):
                next_layer = layers["layers"][i + 1]
                config = config.add_config(
                    next_layer / BuildConfig.DEFAULT_FILE, True)
            list(e for e in utils.walk(layer.directory,
                                       self.build_tactics,
                                       current=layer,
                                       config=config,
                                       output_files=output_files))
        plan = [t for t in output_files.values() if t]
        return plan
Esempio n. 16
0
 def __init__(self):
     self._config = BuildConfig()
     self.config_file = None
Esempio n. 17
0
 def __init__(self):
     self._config = BuildConfig()
     self.config_file = None
Esempio n. 18
0
 def __init__(self):
     self._config = BuildConfig()
     self.config_file = self.CONFIG_FILE
     self.old_config_file = self.OLD_CONFIG_FILE
Esempio n. 19
0
 def test_utf8(self):
     """ Test that utf8 characters in the layer config work."""
     del os.environ['LANG']
     c = BuildConfig()
     c.configure("tests/layers/utf8-layer/interface.yaml")
Esempio n. 20
0
 def __init__(self):
     self._config = BuildConfig()
     self.config_file = self.CONFIG_FILE
     self.old_config_file = self.OLD_CONFIG_FILE
Esempio n. 21
0
    def plan_layers(self, layers, output_files):
        current_config = BuildConfig()
        next_config = current_config.add_config(layers["layers"][0].config)

        layers["layers"][-1].url = self.name

        for i, layer in enumerate(layers["layers"]):
            log.info(
                "Processing layer: %s%s", layer.url,
                "" if layer.directory.startswith(self.cache_dir) else
                " (from %s)" % layer.directory.relpath())
            current_config = current_config.add_config(layer.config)
            if i + 1 < len(layers["layers"]):
                next_layer = layers["layers"][i + 1]
                next_config = next_config.add_config(next_layer.config)
            else:
                # Add an empty level to the configs to represent that there
                # is no layer after the current one.  This is important for
                # the IgnoreTactic, which needs to look ahead so that it can
                # handle ignoring entire directories.
                next_config = next_config.add_config({})
            list(e for e in utils.walk(layer.directory,
                                       self.build_tactics,
                                       layer=layer,
                                       next_config=next_config,
                                       current_config=current_config,
                                       output_files=output_files))
        # now we do update the wheelhouse.txt output file with the lock file if
        # necessary.
        if not getattr(self, 'ignore_lock_file', False):
            lines = self.generate_python_modules_from_lock_file()
            # override any existing lines with the python modules from the lock
            # file.
            existing_tactic = output_files.get('wheelhouse.txt')
            lock_layer = Layer('lockfile-wheelhouse',
                               layers["layers"][-1].target_repo.dirname())
            lock_layer.directory = layers["layers"][-1].directory
            wh_tactic = WheelhouseTactic(
                "",
                self.target,
                lock_layer,
                next_config,
            )
            wh_tactic.lines = lines
            wh_tactic.purge_wheels = True
            if existing_tactic is not None:
                wh_tactic.combine(existing_tactic)
            output_files["wheelhouse.txt"] = wh_tactic

        if self.wheelhouse_overrides:
            existing_tactic = output_files.get('wheelhouse.txt')
            wh_over_layer = Layer('--wheelhouse-overrides',
                                  layers["layers"][-1].target_repo.dirname())
            wh_over_layer.directory = layers["layers"][-1].directory
            output_files['wheelhouse.txt'] = WheelhouseTactic(
                self.wheelhouse_overrides,
                self.target,
                wh_over_layer,
                next_config,
            )
            output_files['wheelhouse.txt'].purge_wheels = True
            if existing_tactic is not None:
                output_files['wheelhouse.txt'].combine(existing_tactic)
        plan = [t for t in output_files.values() if t]
        return plan