packethost / packet-python

A Python client for the Equinix Metal API
http://metal.equinix.com/
GNU Lesser General Public License v3.0
40 stars 50 forks source link

centralized configuration and accessors for default parameters #119

Open displague opened 3 years ago

displague commented 3 years ago

As expressed in https://github.com/packethost/packngo/issues/189#issuecomment-802234842, users would benefit from a common configuration file location and format shared between tools.

What does this look like for packet-python? (Following a rename #106)

# ~/.config/equinix/metal.yaml
---
token: ...

This common file would serve as the default token for all Equinix Metal API client tools, regardless of language, regardless of tool.

Different tools will have their own means of setting provider tokens and this shared/central configuration will not prevent that.

In the packngo issue, the format is described as one that could be shared between Equinix tools. Metal tools could be configured in a metal specific block and individual clients could be configured within sub-blocks.

# ~/.config/equinix/metal.yaml
---
token: ... # default

clients: # this format has not been formalized, perhaps "profile" would be a better name. Tools could allow users to specify the profile to use.
- name: ansible
   token: ... # client specific

The configuration file would allow for defaults such as organization id, project id, facility, metro, device plan, and OS to be specified. Tools do not have to honor these defaults but they will be able to take advantage of them so long as defaults are configured and the tool documentation declares that these values will be used.

More ambitious aspects of the packngo issue express that the client should be able to fetch defaults from the Equinix Metal API. The user profile is configured with default organizations and projects, as defined in the Equinix Metal Portal.

This style of configuration is found in other cloud provider toolsets where common configuration is shared between tools. This simplifies the experience of using different tools because the defaults and secrets are already defined allowing client tools to work with little or no configuration.