Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up addons initialization #1309

Open
nirs opened this issue Mar 31, 2024 · 0 comments
Open

Clean up addons initialization #1309

nirs opened this issue Mar 31, 2024 · 0 comments
Labels
enhancement New feature or request test Testing related issue

Comments

@nirs
Copy link
Member

nirs commented Mar 31, 2024

Addons use too much boilerplate, and do not have good way to pass extra arguments:

This can be cleaned up using an drenv.addon module, similar to drenv.test:

#!/usr/bin/env python3                                                                                                                                                                    

from drenv import addon
from drenv import kubectl

args = addon.init()
addon.info("Deploying recipe crd")
kubectl.apply(
    "--kustomize",
    "https://github.com/RamenDR/recipe.git/config/crd?ref=main&timeout=120s",
    context=args.cluster,
)

addon.init() will:

  • change directory
  • configure logger
  • log start message
  • configure sys.excepthook
  • configure default addon arguments (cluster, -h, --help)
  • configure extra arguments that drenv can use to pass more info to the addon
  • parse arguments
  • print standard usage message
  • print standard --help text
  • fail if called more than once

To configure addon specific arguments we can use:

addon.add_argument(...)
@nirs nirs added enhancement New feature or request test Testing related issue labels Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request test Testing related issue
Projects
None yet
Development

No branches or pull requests

1 participant