Skip to main content

ConfigurationInfo

Provider that signals that a rule contains configuration info. This is used both as part of defining configurations (platform(), constraint_value()) and defining whether a target "matches" a configuration or not (config_setting(), constraint_value())

ConfigurationInfo.constraints

ConfigurationInfo.constraints: dict[TargetLabel, ConstraintValueInfo]

A dictionary mapping constraint setting labels to their corresponding constraint values.


ConfigurationInfo.copy

ConfigurationInfo.copy: ConfigurationInfo

Create a copy of the ConfigurationInfo.

Returns a new ConfigurationInfo instance with copies of the original one. Operations on the copy will not affect the original.

  • Returns

A new ConfigurationInfo with the same constraints and values as the original.

Example

# Create a copy and modify it without affecting the original
config_copy = config_info.copy()
config_copy.insert(new_constraint_value)
# Original config_info remains unchanged

ConfigurationInfo.get

ConfigurationInfo.get: None | ConstraintValueInfo

Get a constraint value by its constraint setting.

Accepts a ConstraintSettingInfo and returns the corresponding ConstraintValueInfo. If the constraint is not set, returns the default constraint value from the setting (if defined).

  • Arguments

    • key: A ConstraintSettingInfo to look up
  • Returns

The ConstraintValueInfo for the given setting. If not set in the constraints, returns the default constraint value from the setting. Returns None only if the constraint is not present and the constraint has no default.

Example

# Get constraint value by setting
cpu_setting = ref.cpu_setting[ConstraintSettingInfo]
value = config_info.get(cpu_setting)
if value:
print("CPU constraint: {}".format(value))

ConfigurationInfo.insert

ConfigurationInfo.insert: None | ConstraintValueInfo

Insert a ConstraintValueInfo into the constraints.

  • Arguments

    • value: The ConstraintValueInfo to insert
  • Returns

The previously set ConstraintValueInfo for this setting, if any. If no previous value existed, returns the default constraint value from the setting (if defined). Returns None only if there was no previous value and the constraint has no default.

Example

# Insert a new constraint value
new_value = ref.some_constraint[ConstraintValueInfo]
old_value = config_info.insert(new_value)
if old_value:
print("Replaced previous value: {}".format(old_value))

ConfigurationInfo.pop

ConfigurationInfo.pop: None | ConstraintValueInfo

Remove and return a constraint value by its setting.

Accepts a ConstraintSettingInfo and returns the corresponding ConstraintValueInfo. If the constraint is not set, returns the default constraint value from the setting (if defined).

  • Arguments

    • key: A ConstraintSettingInfo to remove
  • Returns

The removed ConstraintValueInfo if it was set. If not present, returns the default constraint value from the setting (if defined). Returns None only if the constraint was not set and the constraint has no default.

Example

# Remove a constraint
cpu_setting = ref.cpu_setting[ConstraintSettingInfo]
removed_value = config_info.pop(cpu_setting)
if removed_value:
print("Removed: {}".format(removed_value))

ConfigurationInfo.values

ConfigurationInfo.values: dict[str, str]

A dictionary of buckconfig section.key pairs and their values.