How to use the yay.ast.bind function in yay

To help you get started, we’ve selected a few yay examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yaybu / yaybu / yaybu / provisioner / resource.py View on Github external
kls = ResourceType.resources[typename]
        except KeyError:
            raise error.ParseError(
                "There is no resource type of '%s'" % typename, anchor=instance.anchor)

        resource = kls(instance)
        if resource.id in self:
            raise error.ParseError(
                "'%s' cannot be defined multiple times" % resource.id, anchor=instance.anchor)

        self[resource.id] = resource

        # Create implicit File[] nodes for any watched files
        try:
            for watched in resource.watch:
                res = bind({
                    "name": watched,
                    "policy": "watched",
                })
                res.parent = instance
                w = self.add("File", res)
                w._original_hash = None
        except errors.NoMatching:
            pass

        return resource