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

feat: load modules from multiple paths, support symlink as module #362

Merged
merged 6 commits into from
Feb 8, 2023

Conversation

diafour
Copy link
Contributor

@diafour diafour commented Feb 6, 2023

Overview

  • Resolve symlinks in modules directory, use symlink name to determine module name and order
  • Support multiple paths to search for modules.
  • Support directories without number prefix as module dirs. Default order is 1.
  • Remove '3 digits prefix' restriction.
  • Load values.yaml from all paths.

What this PR does / why we need it

Related issues:

Special notes for your reviewer

Does this PR introduce a user-facing change?


- Resolve symlinks in modules directory, use symlink name to determine module name and order
- Support multiple paths to search for modules.
- Support directories without number prefix as module dirs. Default order is 1.
- Remove '3 digits prefix' restriction.
- Load values.yaml from all paths.

Signed-off-by: Ivan Mikheykin <[email protected]>
@diafour diafour added the enhancement New feature or request label Feb 6, 2023
@diafour diafour requested review from yalosev and shvgn February 6, 2023 09:06
@diafour diafour self-assigned this Feb 6, 2023
Signed-off-by: Ivan Mikheykin <[email protected]>
Signed-off-by: Ivan Mikheykin <[email protected]>
Copy link
Contributor

@shvgn shvgn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real stoppers, but there are possible enhancements

**GLOBAL_HOOKS_DIR** — a directory with global hook files.

**ADDON_OPERATOR_NAMESPACE** — a required parameter with namespace where Addon-operator is deployed.
**MODULES_DIR** — paths separated by colon where modules are located.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MODULES_DIRS would be better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought about MODULES_PATH

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MODULES_PATHS !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rename is a huge thing, it'll require changes in manifests, I don't want to make it in this PR.

RUNNING.md Outdated
**ADDON_OPERATOR_NAMESPACE** — a required parameter with namespace where Addon-operator is deployed.
**MODULES_DIR** — paths separated by colon where modules are located.

**UNNUMBERED_MODULE_ORDER** — a default order for modules without numbered prefix.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What values can be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained

pkg/module_manager/module_loader.go Outdated Show resolved Hide resolved
}

if name != "values.yaml" {
log.Warnf("Ignore '%s' while searching for modules", absPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is going to return empty string, denoting this is not a directory. So this entry will be ignored. Why would we want this warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those warnings and errors are cheap substitutions for dry-run/lint mode and ignore file :(

}
log.Errorf("Possible bug!!! GetModule: no module '%s' in ModuleManager indexes", name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a bug, just no such module. It is fine, CALM DOWN AND DON'T PANIC!!!

deckhouse-controller module values my-inexisting-module

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, yeah. The caller should check for nil.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's more about the exclamation ""Possible bug!!!" :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

pkg/module_manager/module_loader.go Outdated Show resolved Hide resolved
pkg/module_manager/module_loader.go Outdated Show resolved Hide resolved
pkg/module_manager/module.go Show resolved Hide resolved
diafour and others added 2 commits February 8, 2023 11:53
Co-authored-by: Eugene Shevchenko <[email protected]>
…explain data type for UNNUMBERED_MODULE_ORDER

Signed-off-by: Ivan Mikheykin <[email protected]>
@diafour diafour merged commit e823034 into main Feb 8, 2023
@yalosev yalosev deleted the feat_module_multi_dir_and_module_dir_symlink branch February 8, 2023 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants