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

Load configuration lazily #110

Closed
wants to merge 12 commits into from

Conversation

ahangarha
Copy link
Contributor

@ahangarha ahangarha commented Nov 19, 2023

This PR enables us to specify commands that don't need complete configuration from config files. With this, not only can we run commands like cpl version, cpl --version, and cpl --help, we can add new commands like cpl generate to create basic file structure and config templates in a project where no Control Plane configurations exist.

The implementation is not ideal, but it is good enough to be shared and discussed.

This PR prevents loading configurations from files unless a command requests an extended configuration. Commands with WITH_MINIMAL_CONFIG won't make such a request, which makes it possible to define commands that can run without configuration files. For example:

  • cpl --version
  • cpl --help
  • cpl generate (in future)

Closes #93

@ahangarha ahangarha mentioned this pull request Nov 22, 2023
13 tasks
lib/core/minimal_config.rb Outdated Show resolved Hide resolved
lib/core/minimal_config.rb Outdated Show resolved Hide resolved
Copy link
Member

@justin808 justin808 left a comment

Choose a reason for hiding this comment

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

Could we solve this by loading the app config lazily and eliminate all the other crap?

@justin808 justin808 marked this pull request as draft November 25, 2023 03:37
@ahangarha
Copy link
Contributor Author

Could we solve this by loading the app config lazily

I have worked on something like this (as side work). I work on it more to see if that implementation can fix the issue.

@ahangarha ahangarha force-pushed the dont-read-config-files-for-some-commands branch from 7086b18 to e9dde02 Compare November 25, 2023 14:33
@ahangarha ahangarha marked this pull request as ready for review November 25, 2023 14:46
lib/cpl.rb Outdated Show resolved Hide resolved
@ahangarha ahangarha changed the title Don't read config files for some commands Load configuration lazily Nov 28, 2023
@ahangarha ahangarha force-pushed the dont-read-config-files-for-some-commands branch 2 times, most recently from 1127448 to efa2865 Compare November 29, 2023 11:52
@justin808
Copy link
Member

will be merged in #109

@justin808 justin808 closed this Dec 1, 2023
@ahangarha
Copy link
Contributor Author

@justin808
If this PR can get merged, let's do it because #116 is dependent on this branch and it is ready to be merged (if approved).

We can update the #109 based on this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot run cpl --version in a project without controlplane config
3 participants