Skip to content

Conversation

@supakeen
Copy link
Member

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.

@supakeen supakeen requested a review from a team as a code owner December 15, 2025 10:04
@supakeen supakeen requested review from bcl, mvo5 and thozza and removed request for a team December 15, 2025 10:04
@supakeen
Copy link
Member Author

supakeen commented Dec 15, 2025

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. data-dir and force-data-dir are deprecated.

This also more importantly unifies the naming of arguments to be force-* for anything fully overriding builtins, and extra- for anything merging with builtins.

This also reintroduces the ability to load repositories directly from the root of the passed force-repo-dir; in the future the only option as enforcing this subdirectory layout on users is something we probably don't want to do.

We'll need to establish a timeframe for this.

supakeen added a commit to supakeen/image-builder-cli that referenced this pull request Dec 15, 2025
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 <supakeen@redhat.com>
supakeen added a commit to supakeen/image-builder-cli that referenced this pull request Dec 15, 2025
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 <supakeen@redhat.com>
supakeen added a commit to supakeen/image-builder-cli that referenced this pull request Dec 15, 2025
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 <supakeen@redhat.com>
@supakeen supakeen requested a review from achilleas-k December 15, 2025 10:55
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 <supakeen@redhat.com>
_, err = registry.DistroHasRepos("testdistro-1", "x86_64")
require.EqualError(t, err, `requested repository not found: for distribution "testdistro-1"`)

// create a custom datadir with testdistro-1.json, the basefilename
Copy link
Member

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.

Comment on lines +74 to +75
repoDir := t.TempDir()
repoFile := filepath.Join(repoDir, "repositories", "testdistro-1.json")
Copy link
Member

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.

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`)
Copy link
Member

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.

switch name {
case "data-dir":
name = "force-data-dir"
name = "force-repo-dir"
Copy link
Member

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?

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)
Copy link
Member

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.

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.

3 participants