def override()

in src/buildspec.py [0:0]


    def override(self, yaml_object):
        """
        This method overrides anchors in a scalar string with
        values from the environment
        """
        # If the yaml object is a PlainScalarString or ScalarFloat and an environment variable
        # with the same name exists, return the environment variable otherwise,
        # return the original yaml_object
        scalar_types = (
            ruamel.yaml.scalarstring.ScalarString,
            ruamel.yaml.scalarfloat.ScalarFloat,
            ruamel.yaml.scalarstring.PlainScalarString,
            ruamel.yaml.scalarbool.ScalarBoolean,
        )

        if isinstance(yaml_object, ruamel.yaml.comments.CommentedMap):
            for key in yaml_object:
                yaml_object[key] = self.override(yaml_object[key])
        elif isinstance(yaml_object, scalar_types):
            if yaml_object.anchor is not None:
                if yaml_object.anchor.value is not None:
                    yaml_object = os.environ.get(yaml_object.anchor.value, yaml_object)

        # If the yaml object is not a PlainScalarString, does not have an anchor,
        # or it's anchor does not have a value, return
        # the original yaml object
        return yaml_object