-
Notifications
You must be signed in to change notification settings - Fork 20
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,7 @@ func cmdListImages(cmd *cobra.Command, args []string) error { | |
| if err != nil { | ||
| return err | ||
| } | ||
| dataDir, err := cmd.Flags().GetString("force-data-dir") | ||
| repoDir, err := cmd.Flags().GetString("force-repo-dir") | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -75,7 +75,7 @@ func cmdListImages(cmd *cobra.Command, args []string) error { | |
| return err | ||
| } | ||
|
|
||
| return listImages(dataDir, extraRepos, format, filter) | ||
| return listImages(repoDir, extraRepos, format, filter) | ||
| } | ||
|
|
||
| func ostreeImageOptions(cmd *cobra.Command) (*ostree.ImageOptions, error) { | ||
|
|
@@ -142,7 +142,7 @@ func cmdManifestWrapper(pbar progress.ProgressBar, cmd *cobra.Command, args []st | |
| if wrapperOpts == nil { | ||
| wrapperOpts = &cmdManifestWrapperOptions{} | ||
| } | ||
| dataDir, err := cmd.Flags().GetString("force-data-dir") | ||
| repoDir, err := cmd.Flags().GetString("force-repo-dir") | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
@@ -290,7 +290,7 @@ func cmdManifestWrapper(pbar progress.ProgressBar, cmd *cobra.Command, args []st | |
| forceRepos = []string{"https://example.com/not-used"} | ||
| } else { | ||
| repoOpts := &repoOptions{ | ||
| DataDir: dataDir, | ||
| RepoDir: repoDir, | ||
| ExtraRepos: extraRepos, | ||
| ForceRepos: forceRepos, | ||
| } | ||
|
|
@@ -324,7 +324,7 @@ func cmdManifestWrapper(pbar progress.ProgressBar, cmd *cobra.Command, args []st | |
| fmt.Fprintf(os.Stderr, "WARNING: using experimental cross-architecture building to build %q\n", img.ImgType.Arch().Name()) | ||
| } | ||
|
|
||
| err = generateManifest(dataDir, extraRepos, img, w, wd, opts) | ||
| err = generateManifest(repoDir, extraRepos, img, w, wd, opts) | ||
| return img, err | ||
| } | ||
|
|
||
|
|
@@ -459,7 +459,7 @@ func cmdBuild(cmd *cobra.Command, args []string) error { | |
|
|
||
| func cmdDescribeImg(cmd *cobra.Command, args []string) error { | ||
| // XXX: boilderplate identical to cmdManifest() above | ||
| dataDir, err := cmd.Flags().GetString("force-data-dir") | ||
| repoDir, err := cmd.Flags().GetString("force-repo-dir") | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -481,7 +481,7 @@ func cmdDescribeImg(cmd *cobra.Command, args []string) error { | |
| } | ||
|
|
||
| imgTypeStr := args[0] | ||
| res, err := getOneImage(distroStr, imgTypeStr, archStr, &repoOptions{DataDir: dataDir}) | ||
| res, err := getOneImage(distroStr, imgTypeStr, archStr, &repoOptions{RepoDir: repoDir}) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -492,7 +492,7 @@ func cmdDescribeImg(cmd *cobra.Command, args []string) error { | |
| func normalizeRootArgs(_ *pflag.FlagSet, name string) pflag.NormalizedName { | ||
| switch name { | ||
| case "data-dir": | ||
| name = "force-data-dir" | ||
| name = "force-repo-dir" | ||
| break | ||
| } | ||
|
|
||
|
|
@@ -528,9 +528,11 @@ operating systems like Fedora, CentOS and RHEL with easy customizations support. | |
| } | ||
|
|
||
| rootCmd.Flags().Bool("version", false, "Print version information and exit") | ||
| var forceDataDir string | ||
| rootCmd.PersistentFlags().StringVar(&forceDataDir, "force-data-dir", "", `Override the default data directory for e.g. custom repositories/*.json data`) | ||
| rootCmd.PersistentFlags().StringVar(&forceDataDir, "data-dir", "", `Override the default data directory for e.g. custom repositories/*.json data`) | ||
| var forceRepoDir string | ||
| rootCmd.PersistentFlags().StringVar(&forceRepoDir, "force-repo-dir", "", "Override the default repository search path for custom repository files") | ||
| 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`) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may want to fix the deprecation message here to suggest |
||
| rootCmd.PersistentFlags().StringArray("extra-repo", nil, `Add an extra repository during build (will *not* be gpg checked and not be part of the final image)`) | ||
| rootCmd.PersistentFlags().StringArray("force-repo", nil, `Override the base repositories during build (these will not be part of the final image)`) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import ( | |
| "fmt" | ||
| "io/fs" | ||
| "net/url" | ||
| "os" | ||
| "path/filepath" | ||
|
|
||
| "github.com/osbuild/images/data/repositories" | ||
|
|
@@ -53,12 +54,18 @@ func parseRepoURLs(repoURLs []string, what string) ([]rpmmd.RepoConfig, error) { | |
| return repoConf, nil | ||
| } | ||
|
|
||
| func newRepoRegistryImpl(dataDir string, extraRepos []string) (*reporegistry.RepoRegistry, error) { | ||
| func newRepoRegistryImpl(repoDir string, extraRepos []string) (*reporegistry.RepoRegistry, error) { | ||
| var repoDirs []string | ||
| var builtins []fs.FS | ||
|
|
||
| if dataDir != "" { | ||
| repoDirs = []string{filepath.Join(dataDir, "repositories")} | ||
| if repoDir != "" { | ||
| withRepoSubdir := filepath.Join(repoDir, "repositories") | ||
| 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) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mentioning the |
||
| } | ||
| repoDirs = []string{withRepoSubdir, repoDir} | ||
| } else { | ||
| repoDirs = defaultRepoDirs | ||
| builtins = []fs.FS{repos.FS} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,8 +71,8 @@ func TestNewRepoRegistryImplDatadir(t *testing.T) { | |
|
|
||
| // create a custom datadir with testdistro-1.json, the basefilename | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: the comment should be amended, since it still mentions |
||
| // must match a distro nameVer | ||
| dataDir := t.TempDir() | ||
| repoFile := filepath.Join(dataDir, "repositories", "testdistro-1.json") | ||
| repoDir := t.TempDir() | ||
| repoFile := filepath.Join(repoDir, "repositories", "testdistro-1.json") | ||
|
Comment on lines
+74
to
+75
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be beneficial to test this also without the |
||
| err = os.Mkdir(filepath.Dir(repoFile), 0755) | ||
| require.NoError(t, err) | ||
| repoContents := `{ | ||
|
|
@@ -88,7 +88,7 @@ func TestNewRepoRegistryImplDatadir(t *testing.T) { | |
| require.NoError(t, err) | ||
|
|
||
| // and ensure we have testdistro-1 now | ||
| registry, err = newRepoRegistryImpl(dataDir, nil) | ||
| registry, err = newRepoRegistryImpl(repoDir, nil) | ||
| require.NoError(t, err) | ||
| repos, err := registry.DistroHasRepos("testdistro-1", "x86_64") | ||
| require.NoError(t, err) | ||
|
|
||
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-diroption be normalized as well?