-
Notifications
You must be signed in to change notification settings - Fork 22
many: force-repo-dir instead of force-data-dir
#408
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
|
Since we had some previous discussion about not growing too many arguments; this will (eventually, we need to decide a timeline) be the only argument left over. This also more importantly unifies the naming of arguments to be This also reintroduces the ability to load repositories directly from the root of the passed We'll need to establish a timeframe for this. |
After a chat in our community Matrix channel I realized that we have not documented the various ways of managing repositories in `image-builder`. Let's start that off with a small initial page that I will build on in the following commits. This relies on the implementation of the new `force-repo-dir` behavior as that's the behavior documented [1]. [1]: osbuild#408 Signed-off-by: Simon de Vlieger <[email protected]>
After a chat in our community Matrix channel I realized that we have not documented the various ways of managing repositories in `image-builder`. Let's start that off with a small initial page that I will build on in the following commits. This relies on the implementation of the new `force-repo-dir` behavior as that's the behavior documented [1]. [1]: osbuild#408 Signed-off-by: Simon de Vlieger <[email protected]>
After a chat in our community Matrix channel I realized that we have not documented the various ways of managing repositories in `image-builder`. Let's start that off with a small initial page that I will build on in the following commits. This relies on the implementation of the new `force-repo-dir` behavior as that's the behavior documented [1]. [1]: osbuild#408 Signed-off-by: Simon de Vlieger <[email protected]>
cmd/image-builder/repos_test.go
Outdated
| @@ -71,8 +71,8 @@ func TestNewRepoRegistryImplDatadir(t *testing.T) { | |||
|
|
|||
| // create a custom datadir with testdistro-1.json, the basefilename | |||
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.
Nitpick: the comment should be amended, since it still mentions datadir.
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.
Done.
| repoDir := t.TempDir() | ||
| repoFile := filepath.Join(repoDir, "repositories", "testdistro-1.json") |
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.
It may be beneficial to test this also without the repositories sub-directory.
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've added a second test that tests without the repositories sub directory but is otherwise the same.
cmd/image-builder/main.go
Outdated
| rootCmd.PersistentFlags().StringVar(&forceRepoDir, "force-data-dir", "", `Override the default data directory for e.g. custom repositories/*.json data`) | ||
| rootCmd.PersistentFlags().MarkDeprecated("force-data-dir", `Use --force-repo-dir instead`) | ||
| rootCmd.PersistentFlags().StringVar(&forceRepoDir, "data-dir", "", `Override the default data directory for e.g. custom repositories/*.json data`) | ||
| rootCmd.PersistentFlags().MarkDeprecated("data-dir", `Use --force-data-dir instead`) |
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.
You may want to fix the deprecation message here to suggest --force-repo-dir instead.
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.
Done.
| switch name { | ||
| case "data-dir": | ||
| name = "force-data-dir" | ||
| name = "force-repo-dir" |
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.
Should the force-data-dir option be normalized as well?
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.
Good catch yes, I've added normalization for that one too.
cmd/image-builder/repos.go
Outdated
| if _, err := os.Stat(withRepoSubdir); err == nil { | ||
| // we don't care about the error case here, we just want to know | ||
| // if it exists; not if we can't read it or other errors | ||
| fmt.Fprintf(os.Stderr, "WARNING: `force-repo-dir` found a `repositories` subdirectory at '%s', in the future `image-builder` will not descend into this subdirectory to look for repository files. Please move any repository files directly into the directory '%s' and remove the `repositories` subdirectory to silence this warning.\n", withRepoSubdir, repoDir) |
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.
Mentioning the force-repo-dir option here may be misleading, since one could specify --data-dir and get the warning about an option that they didn't use.
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.
Done, now doesn't mention an option name at all; that isn't perfect since the user has to extrapolate but it's also less confusing (and I don't want to mention all options).
|
I accidentally approved the PR, while there are still comments that I wanted to be addressed. Although I can't remove the approval, also don't want to formally request changes. Since the branch has conflicts, it can't be merged as is anyway, so this is all good from my PoV. Sorry for the noise. |
After a chat in our community Matrix channel I realized that we have not documented the various ways of managing repositories in `image-builder`. Let's start that off with a small initial page that I will build on in the following commits. This relies on the implementation of the new `force-repo-dir` behavior as that's the behavior documented [1]. [1]: osbuild#408 Signed-off-by: Simon de Vlieger <[email protected]>
Previously I deprecated `data-dir` and renamed it to `force-data-dir` to have consistent naming for options that overwrite internal state instead of appending to it (arguments that start with `force-` are overwrites, arguments that start with `extra-` are merges). With `force-data-dir` we require a `repositories` sub directory. After some discussion we came to the idea to instead of enforcing a directory layout on the user we want to be able to point directly at a directory of repositories. This commit deprecates `force-data-dir` and introduces `force-repo-dir`. Both write to the same internal variable. We also allow repository files to live *either* in a `repositories` subdirectory to keep backwards compatibility for any of the arguments or to live directly at the top level of the passed directory. We show a deprecation warning if a `repositories` sub directory exists and inform users that the `repositories` subdirectory will not be wanted in the future and how to resolve the emitted warning. This option will be used together with the future introduction of `force-defs-dir` to handle definitions (and its `extra-defs-dir` counter part) unifying all options into a consistent naming scheme. Signed-off-by: Simon de Vlieger <[email protected]>
lzap
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.
Very long warning, three lines on 80x25 terminal, this will be quite effective. :D
I am wondering why you used backtics and single quotes is that some kind of standard or convention in CLI? I would probably use %q for both to save keystrokes.
I think it's partial markdown and partial representation of strings (in Python). |
|
Throwing a tiny spanner in the works here after all this time but: The description of every |
I don't know, |
Previously I deprecated
data-dirand renamed it toforce-data-dirto have consistent naming for options that overwrite internal state instead of appending to it (arguments that start withforce-are overwrites, arguments that start withextra-are merges).With
force-data-dirwe require arepositoriessub directory. After some discussion we came to the idea to instead of enforcing a directory layout on the user we want to be able to point directly at a directory of repositories.This commit deprecates
force-data-dirand introducesforce-repo-dir. Both write to the same internal variable.We also allow repository files to live either in a
repositoriessubdirectory to keep backwards compatibility for any of the arguments or to live directly at the top level of the passed directory.We show a deprecation warning if a
repositoriessub directory exists and inform users that therepositoriessubdirectory will not be wanted in the future and how to resolve the emitted warning.This option will be used together with the future introduction of
force-defs-dirto handle definitions (and itsextra-defs-dircounter part) unifying all options into a consistent naming scheme.