https://pantsbuild.org/ logo
#general
Title
# general
r

ripe-cpu-85141

08/01/2022, 11:46 PM
Still in my plugin, I have a rule which has access to a target. Inside there is a field named "policies". I can see the data if I logger.info(mytarget) but I can't access it. mytarget.policies or mytarget["policies"] don't work. How can I access that field?
f

fast-nail-55400

08/02/2022, 1:26 AM
Access is indexed based on the type of the field, not its name.
mytarget.get(MyPoliciesField)
-- if the type of
policies
field was
MyPoliciesField
-- see https://www.pantsbuild.org/docs/target-api-concepts#a-field-driven-api
the name of the field as exposed in
BUILD
files becomes somewhat irrelevant to plugin code trying to access those fields.
r

ripe-cpu-85141

08/02/2022, 3:38 AM
ok, thanks!