-
Notifications
You must be signed in to change notification settings - Fork 136
Centralize base path variable #992
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
base: main
Are you sure you want to change the base?
Conversation
Set the default base path at runtime with a shared logic. - Add a new package to keep the shared configuration. - Define the base path in the shared configuration. - Use the shared base path logic across the project.
fitzthum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. We definitely have a problem with the tests only working as root.
I am on the fence about creating a new module for this. curiuos what @Xynnn007 @mkulke @mythi think about it.
I think you may be able to use the concat! macro to keep the logic in the const at the top of the files. That might be a little more clear than joining the paths deeper in the code (although arguably that is more robust).
Xynnn007
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the core idea of the PR is this part - to have a configurable parent config path.
TBO I don't think we need to introduce a new package for this. Let's re-visit the design:
If the configuration file doesn't specify a configuration directory, we move it to the ~/.trustee directory to ensure permissions are fit, and retain the existing subdirectory structure (we may need to reorganize the code that defines the configuration file path).
If config path(s) are specified, use the new one(s).
|
@Xynnn007 You say to change the default const to use The only issue I see with this design - backwards compatibility. Current deployments may misbehave if they don't have paths configured explicitly. |
|
Another way to avoid the new package. Put the logic in the same file as the KbsConfig (kbs/config), and either:
|
Oh sorry. I did not find that you havd used
Agreed. |
|
While we're re-working this, I thought I'll ask if a unified base is still a good fit or should we look into separating things out into data/config/state functions. Similar to what XDG Base Spec is aiming to define. |
Now we have configs of path for
and the things are relative simple, so put them under one common parent dir can be easy. Maybe we can consider split data and state thing in future? |
|
Recap of the options:
I'll be pushing option 5 shortly. |
Sure. On the PR itself, I feel |
|
@mythi do you advise to have a backwards compatibility mechanism? That is, if |
Just saying that the assumption that |
During #776 I found the hardcoded
/opt/confidential-containerspaths to come in the way for running Trustee as a non-root user. Changing all the paths at runtime means traversing the whole KbsConfig struct, not optimal.Here I propose a possible alternative, to set the default base path at runtime with a shared logic.
This approach can look heavy, in that it introduces a new package just to share a function. Over time the shared package can become more useful to share more project-wide config. For example if we decide to split the api server from the kbs package. I'd be willing to populate the shared config package a bit more but right now I don't know what else could be moved.
Please propose alternative approaches.
If we like this, I'll have to fix the tests, and possibly make the tests run in both the root and non-root scenario.