Skip to content

Improve get_context_parameter

Current situation

opentf.commons.get_context_parameter() does not handles default values the same way it handles defined parameters, leading to possible type mismatch.

Also, the specified default function parameter is only used if no default is specified in the descriptor, which is unexpected.

Desired outcome

There should be one path for validation, whether the value comes from the user, from a default value specified in the call or in the descriptor.

Also, allowing for alternative names would be nice.

A specification example (from a service descriptor):

spec:
  contextParameters:
  - name: availability_check_delay_seconds
    deprecatedNames: ['availability_check_delay']
    descriptiveName: how often to check if agents are available (in seconds)
    type: int
    default: 10
    minValue: 10
Edited by Martin Lafaix