Skip to content

Commit

Permalink
bib: rename --config to --iso-config
Browse files Browse the repository at this point in the history
Rename the --config option to --iso-config and error if it is
used for anything other than the ISO image.
  • Loading branch information
mvo5 committed Mar 26, 2024
1 parent 61cf497 commit 13b7143
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bib/cmd/bootc-image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func manifestFromCobra(cmd *cobra.Command, args []string) ([]byte, error) {
}

imgref := args[0]
configFile, _ := cmd.Flags().GetString("config")
isoConfigFile, _ := cmd.Flags().GetString("iso-config")
imgTypes, _ := cmd.Flags().GetStringArray("type")
rpmCacheRoot, _ := cmd.Flags().GetString("rpmmd")
targetArch, _ := cmd.Flags().GetString("target-arch")
Expand All @@ -262,9 +262,14 @@ func manifestFromCobra(cmd *cobra.Command, args []string) ([]byte, error) {
return nil, err
}

// bootc does not yet support arbitray blueprint customizations
if buildType != BuildTypeISO && isoConfigFile != "" {
return nil, fmt.Errorf("the --iso-config switch is only supported for ISO images")
}

var config *BuildConfig
if configFile != "" {
config, err = loadConfig(configFile)
if isoConfigFile != "" {
config, err = loadConfig(isoConfigFile)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -468,7 +473,7 @@ func run() error {
}
rootCmd.AddCommand(manifestCmd)
manifestCmd.Flags().Bool("tls-verify", true, "require HTTPS and verify certificates when contacting registries")
manifestCmd.Flags().String("config", "", "build config file")
manifestCmd.Flags().String("iso-config", "", "build config file for the iso")
manifestCmd.Flags().String("rpmmd", "/rpmmd", "rpm metadata cache directory")
manifestCmd.Flags().String("target-arch", "", "build for the given target architecture (experimental)")
manifestCmd.Flags().StringArray("type", []string{"qcow2"}, fmt.Sprintf("image types to build [%s]", allImageTypesString()))
Expand All @@ -492,7 +497,7 @@ func run() error {
return err
}
}
if err := buildCmd.MarkFlagFilename("config"); err != nil {
if err := buildCmd.MarkFlagFilename("iso-config"); err != nil {
return err
}
buildCmd.MarkFlagsRequiredTogether("aws-region", "aws-bucket", "aws-ami-name")
Expand Down
35 changes: 35 additions & 0 deletions test/test_opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,38 @@ def test_bib_chown_opts(tmp_path, build_fake_container, chown_opt, expected_uid_
assert p.exists()
assert p.stat().st_uid == expected_uid_gid[0]
assert p.stat().st_gid == expected_uid_gid[1]


def test_bib_config_errors_for_default(tmp_path, build_fake_container):
output_path = tmp_path / "output"
output_path.mkdir(exist_ok=True)

ret = subprocess.run([
"podman", "run", "--rm",
"--privileged",
"--security-opt", "label=type:unconfined_t",
"-v", f"{output_path}:/output",
build_fake_container,
"--iso-config", "/some/random/config",
"quay.io/centos-bootc/centos-bootc:stream9",
], check=False, encoding="utf8", stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert ret.returncode != 0
assert "the --iso-config switch is only supported for ISO images" in ret.stderr


def test_bib_config_happy_for_iso(tmp_path, build_fake_container):
output_path = tmp_path / "output"
output_path.mkdir(exist_ok=True)

ret = subprocess.run([
"podman", "run", "--rm",
"--privileged",
"--security-opt", "label=type:unconfined_t",
"-v", f"{output_path}:/output",
build_fake_container,
"--iso-config", "/some/random/config",
"--type", "anaconda-iso",
"quay.io/centos-bootc/centos-bootc:stream9",
], check=False, encoding="utf8", stdout=subprocess.PIPE)
assert ret.returncode == 0

0 comments on commit 13b7143

Please sign in to comment.