ansible / ansible-sdk

The Ansible SDK
Apache License 2.0
25 stars 14 forks source link

Executor Options #32

Closed nitzmahone closed 2 years ago

nitzmahone commented 2 years ago

Changes the SDK executor submit_job methods to always require an options argument. The new argument contains execution options germane only to the executor, while the "common Ansible" bits remain in the job definition.

The options dataclasses use the frozen=True and the 3.10+ kw_only=True features- this makes the constructed values effectively immutable (so they can be safely referred to during and after the run without requiring a copy), and ensures that the generated constructors will not accept positional args (since it's difficult to control the order with dataclasses, and an inadvertent change to the order would break existing callers badly). It also includes a crusty polyfill for the basics of the kw_only behavior for Python 3.9, since we can't yet target 3.10, but really need the behavior it provides.

The intermediate generic base class for the container executors is not my favorite, but I don't really want to fork/duplicate them until we absolutely have to, and making the base executor generic doesn't really gain us much (I tried :laughing: )

(supersedes #23)