From 0e4a9e586f5b694c2d9257ed8accd97b3b408dfb Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Wed, 14 Jun 2023 16:34:41 +0200 Subject: [PATCH] split: replace internal packages with images library Remove all the internal package that are now in the github.com/osbuild/images package and vendor it. A new function in internal/blueprint/ converts from an osbuild-composer blueprint to an images blueprint. This is necessary for keeping the blueprint implementation in both packages. In the future, the images package will change the blueprint (and most likely rename it) and it will only be part of the osbuild-composer internals and interface. The Convert() function will be responsible for converting the blueprint into the new configuration object. --- cmd/gen-manifests/main.go | 16 +- .../main.go | 2 +- .../main_test.go | 4 +- cmd/osbuild-composer/composer.go | 2 +- cmd/osbuild-dnf-json-tests/main_test.go | 10 +- cmd/osbuild-koji-tests/main_test.go | 2 +- cmd/osbuild-koji/main.go | 2 +- cmd/osbuild-package-sets/main.go | 9 +- cmd/osbuild-pipeline/main.go | 13 +- cmd/osbuild-playground/main.go | 8 +- cmd/osbuild-playground/my-container.go | 10 +- cmd/osbuild-playground/my-image.go | 12 +- cmd/osbuild-playground/partitiontables.go | 2 +- cmd/osbuild-playground/playground.go | 10 +- cmd/osbuild-store-dump/main.go | 13 +- cmd/osbuild-upload-container/main.go | 2 +- .../jobimpl-container-resolve.go | 2 +- cmd/osbuild-worker/jobimpl-depsolve.go | 2 +- cmd/osbuild-worker/jobimpl-koji-finalize.go | 4 +- cmd/osbuild-worker/jobimpl-osbuild.go | 4 +- cmd/osbuild-worker/jobimpl-ostree-resolve.go | 2 +- go.mod | 11 +- go.sum | 2 + internal/blueprint/blueprint.go | 150 ++- .../blueprint/repository_customizations.go | 2 +- .../repository_customizations_test.go | 2 +- internal/client/modules.go | 2 +- internal/client/projects.go | 2 +- internal/client/unit_test.go | 6 +- internal/cloudapi/server.go | 2 +- internal/cloudapi/v2/handler.go | 14 +- internal/cloudapi/v2/server.go | 16 +- internal/cloudapi/v2/server.go.orig | 564 +++++++++ internal/cloudapi/v2/v2_internal_test.go | 2 +- internal/cloudapi/v2/v2_koji_test.go | 4 +- internal/cloudapi/v2/v2_multi_tenancy_test.go | 2 +- internal/cloudapi/v2/v2_test.go | 8 +- internal/container/client_test.go | 103 -- internal/container/container_test.go | 385 ------ internal/container/resolver_test.go | 85 -- internal/crypt/crypt_test.go | 64 - internal/disk/disk_test.go | 1088 ----------------- internal/disk/lvm_test.go | 40 - internal/distro/distro_test.go | 566 --------- internal/distro/fedora/distro_test.go | 815 ------------ internal/distro/image_config_test.go | 218 ---- internal/distro/rhel7/distro_test.go | 452 ------- internal/distro/rhel8/distro_internal_test.go | 73 -- internal/distro/rhel8/distro_test.go | 907 -------------- internal/distro/rhel9/distro_test.go | 848 ------------- .../distroregistry/distroregistry_test.go | 122 -- internal/dnfjson/cache.go | 2 +- internal/dnfjson/cache_test.go | 2 +- internal/dnfjson/dnfjson.go | 4 +- internal/dnfjson/dnfjson_test.go | 2 +- internal/environment/environment.go | 2 +- internal/manifest/os_test.go | 154 --- internal/mocks/distro/distro_mock.go | 4 +- internal/mocks/dnfjson/dnfjson.go | 2 +- internal/mocks/rpmrepo/rpmrepo.go | 2 +- internal/osbuild/authconfig_stage_test.go | 16 - internal/osbuild/authselect_stage_test.go | 16 - internal/osbuild/chown_stage_test.go | 244 ---- internal/osbuild/chrony_stage_test.go | 16 - internal/osbuild/cloud_init_stage_test.go | 216 ---- internal/osbuild/common_test.go | 342 ------ .../containers_storage_conf_stage_test.go | 31 - internal/osbuild/copy_stage_test.go | 71 -- internal/osbuild/device_test.go | 141 --- internal/osbuild/disk_test.go | 40 - .../dnf_automatic_config_stage_test.go | 80 -- internal/osbuild/dnf_config_stage_test.go | 133 -- internal/osbuild/dracut_conf_stage_test.go | 42 - internal/osbuild/dracut_stage_test.go | 16 - internal/osbuild/fdo_stage_test.go | 32 - internal/osbuild/files_input_test.go | 93 -- internal/osbuild/firewall_stage_test.go | 27 - internal/osbuild/first_boot_stage_test.go | 16 - internal/osbuild/fix_bls_stage_test.go | 16 - internal/osbuild/fsnode_test.go | 272 ----- internal/osbuild/fstab_stage_test.go | 52 - .../gcp_guest_agent_conf_stage_test.go | 84 -- internal/osbuild/groups_stage_test.go | 16 - internal/osbuild/grub2_inst_stage_test.go | 113 -- internal/osbuild/grub2_legacy_stage_test.go | 34 - internal/osbuild/grub2_stage_test.go | 16 - internal/osbuild/hostname_stage_test.go | 16 - internal/osbuild/inline_source_test.go | 32 - internal/osbuild/kernel_cmdline_stage_test.go | 16 - internal/osbuild/keymap_stage_test.go | 37 - internal/osbuild/locale_stage_test.go | 16 - internal/osbuild/lvm2_create_stage_test.go | 60 - internal/osbuild/lvm2_lv_device_test.go | 1 - internal/osbuild/lvm2_metadata_stage_test.go | 55 - internal/osbuild/mkfs_stages_test.go | 73 -- internal/osbuild/modprobe_stage_test.go | 147 --- internal/osbuild/mount_test.go | 55 - internal/osbuild/oci_archive_stage_test.go | 105 -- internal/osbuild/osbuild_test.go | 28 - .../osbuild/oscap_remediation_stage_test.go | 85 -- .../osbuild/pam_limits_conf_stage_test.go | 52 - internal/osbuild/pwquality_conf_stage_test.go | 55 - internal/osbuild/qemu_stage_test.go | 224 ---- internal/osbuild/result_test.go | 378 ------ internal/osbuild/rhsm_facts_stage_test.go | 46 - internal/osbuild/rhsm_stage_test.go | 72 -- internal/osbuild/rpm_stage_test.go | 182 --- internal/osbuild/script_stage_test.go | 24 - internal/osbuild/selinux_config_stage_test.go | 16 - internal/osbuild/selinux_stage_test.go | 24 - internal/osbuild/sfdisk_stage_test.go | 37 - internal/osbuild/sgdisk_stage_test.go | 38 - internal/osbuild/shell_init_stage_test.go | 184 --- internal/osbuild/skopeo_source_test.go | 59 - internal/osbuild/source_test.go | 115 -- internal/osbuild/sshd_config_stage_test.go | 109 -- internal/osbuild/sysconfig_stage_test.go | 16 - internal/osbuild/sysctld_stage_test.go | 70 -- .../osbuild/systemd_journald_stage_test.go | 70 -- internal/osbuild/systemd_logind_stage_test.go | 44 - internal/osbuild/systemd_stage_test.go | 16 - internal/osbuild/systemd_unit_stage_test.go | 16 - internal/osbuild/tar_stage_test.go | 78 -- internal/osbuild/timezone_stage_test.go | 16 - internal/osbuild/tmpfilesd_stage_test.go | 50 - internal/osbuild/truncate_stage_test.go | 20 - internal/osbuild/tuned_stage_test.go | 59 - internal/osbuild/udev_rules_stage_test.go | 184 --- internal/osbuild/users_stage_test.go | 59 - internal/osbuild/xz_stage_test.go | 47 - internal/osbuild/yum_config_stage_test.go | 113 -- internal/osbuild/yum_repos_stage_test.go | 188 --- internal/osbuild/zipl_stage_test.go | 24 - internal/ostree/ostree_test.go | 120 -- internal/ostree/test_mtls_server/ca.crt | 20 - internal/ostree/test_mtls_server/client.crt | 85 -- internal/ostree/test_mtls_server/client.key | 28 - .../test_mtls_server/http_mtls_server.go | 76 -- internal/ostree/test_mtls_server/server.crt | 88 -- internal/ostree/test_mtls_server/server.key | 28 - internal/reporegistry/reporegistry.go | 4 +- internal/reporegistry/reporegistry_test.go | 6 +- internal/rhsm/secrets_test.go | 49 - internal/rpmmd/metadata_test.go | 140 --- internal/rpmmd/repository_test.go | 53 - .../priority1/repositories/test-distro.json | 56 - .../priority2/repositories/test-distro-2.json | 38 - .../priority2/repositories/test-distro.json | 56 - internal/rpmmd/test/repository_test.go | 296 ----- internal/store/compose.go | 6 +- internal/store/fixtures.go | 6 +- internal/store/json.go | 8 +- internal/store/json_test.go | 10 +- internal/store/store.go | 8 +- internal/store/store_test.go | 13 +- internal/test/helpers.go | 2 +- internal/upload/koji/koji.go | 2 +- internal/weldr/api.go | 17 +- internal/weldr/api_test.go | 12 +- internal/weldr/compose_test.go | 4 +- internal/weldr/json.go | 2 +- internal/weldr/upload.go | 2 +- internal/worker/json.go | 8 +- internal/worker/json_test.go | 2 +- internal/worker/server_test.go | 10 +- internal/workload/workload.go | 2 +- vendor/github.com/osbuild/images/LICENSE | 201 +++ .../images/internal/common/constants.go | 38 + .../osbuild/images/internal/common/distro.go | 83 ++ .../images/internal/common/echo_logrus.go | 175 +++ .../osbuild/images/internal/common/helpers.go | 103 ++ .../images/internal/common/operation_id.go | 22 + .../images/internal/common/pointers.go | 5 + .../osbuild/images/internal/common/states.go | 71 ++ .../osbuild/images/internal/dnfjson/cache.go | 325 +++++ .../images/internal/dnfjson/dnfjson.go | 651 ++++++++++ .../images/internal/environment/azure.go | 13 + .../images/internal/environment/ec2.go | 13 + .../internal/environment/environment.go | 25 + .../images/internal/environment/gcp.go | 6 + .../images/internal/environment/openstack.go | 6 + .../images/internal/environment/vsphere.go | 6 + .../osbuild/images/internal/fdo/fdo.go | 15 + .../osbuild/images/internal/fsnode/dir.go | 34 + .../osbuild/images/internal/fsnode/file.go | 36 + .../osbuild/images/internal/fsnode/fsnode.go | 133 ++ .../images/internal/ignition/ignition.go | 31 + .../images/internal/mocks/dnfjson/dnfjson.go | 225 ++++ .../osbuild/images/internal/oscap/oscap.go | 72 ++ .../images/internal/pathpolicy/path_policy.go | 54 + .../images/internal/pathpolicy/path_trie.go | 123 ++ .../images/internal/pathpolicy/policies.go | 31 + .../osbuild/images/internal/shell/shell.go | 11 + .../osbuild/images/internal/users/users.go | 40 + .../images/internal/workload/anaconda.go | 7 + .../images/internal/workload/custom.go | 22 + .../osbuild/images/internal/workload/sap.go | 6 + .../internal/workload/static_webserver.go | 7 + .../images/internal/workload/workload.go | 30 + .../osbuild/images/pkg}/artifact/artifact.go | 0 .../osbuild/images/pkg/blueprint/blueprint.go | 184 +++ .../images/pkg/blueprint/customizations.go | 351 ++++++ .../blueprint/filesystem_customizations.go | 89 ++ .../pkg/blueprint/fsnode_customizations.go | 471 +++++++ .../blueprint/repository_customizations.go | 137 +++ .../osbuild/images/pkg}/container/client.go | 2 +- .../osbuild/images/pkg}/container/resolver.go | 0 .../osbuild/images/pkg}/container/spec.go | 0 .../osbuild/images/pkg}/crypt/crypt.go | 0 .../osbuild/images/pkg}/crypt/crypt_impl.go | 4 +- .../images/pkg}/crypt/crypt_impl_macos.go | 0 .../osbuild/images/pkg}/disk/btrfs.go | 0 .../osbuild/images/pkg}/disk/disk.go | 0 .../osbuild/images/pkg}/disk/filesystem.go | 0 .../osbuild/images/pkg}/disk/luks.go | 0 .../osbuild/images/pkg}/disk/lvm.go | 2 +- .../osbuild/images/pkg}/disk/partition.go | 0 .../images/pkg}/disk/partition_table.go | 2 +- .../osbuild/images/pkg}/distro/distro.go | 14 +- .../distro_test_common/distro_test_common.go | 20 +- .../images/pkg}/distro/fedora/distro.go | 14 +- .../images/pkg}/distro/fedora/images.go | 24 +- .../images/pkg}/distro/fedora/imagetype.go | 28 +- .../images/pkg}/distro/fedora/package_sets.go | 6 +- .../pkg}/distro/fedora/partition_tables.go | 8 +- .../images/pkg}/distro/image_config.go | 6 +- .../osbuild/images/pkg}/distro/rhel7/azure.go | 14 +- .../images/pkg}/distro/rhel7/distro.go | 10 +- .../images/pkg}/distro/rhel7/images.go | 22 +- .../images/pkg}/distro/rhel7/imagetype.go | 22 +- .../images/pkg}/distro/rhel7/package_sets.go | 2 +- .../pkg}/distro/rhel7/partition_tables.go | 8 +- .../osbuild/images/pkg}/distro/rhel7/qcow2.go | 10 +- .../osbuild/images/pkg}/distro/rhel8/ami.go | 10 +- .../osbuild/images/pkg}/distro/rhel8/arch.go | 4 +- .../osbuild/images/pkg}/distro/rhel8/azure.go | 16 +- .../images/pkg}/distro/rhel8/bare_metal.go | 4 +- .../images/pkg}/distro/rhel8/distro.go | 12 +- .../osbuild/images/pkg}/distro/rhel8/edge.go | 8 +- .../osbuild/images/pkg}/distro/rhel8/gce.go | 10 +- .../images/pkg}/distro/rhel8/images.go | 28 +- .../images/pkg}/distro/rhel8/imagetype.go | 28 +- .../images/pkg}/distro/rhel8/package_sets.go | 4 +- .../pkg}/distro/rhel8/partition_tables.go | 8 +- .../osbuild/images/pkg}/distro/rhel8/qcow2.go | 10 +- .../osbuild/images/pkg}/distro/rhel8/sap.go | 8 +- .../osbuild/images/pkg}/distro/rhel8/vmdk.go | 4 +- .../images/pkg}/distro/rhel8/workloads.go | 2 +- .../osbuild/images/pkg}/distro/rhel9/ami.go | 10 +- .../osbuild/images/pkg}/distro/rhel9/arch.go | 4 +- .../osbuild/images/pkg}/distro/rhel9/azure.go | 14 +- .../images/pkg}/distro/rhel9/bare_metal.go | 4 +- .../images/pkg}/distro/rhel9/distro.go | 12 +- .../osbuild/images/pkg}/distro/rhel9/edge.go | 12 +- .../osbuild/images/pkg}/distro/rhel9/gce.go | 10 +- .../images/pkg}/distro/rhel9/images.go | 28 +- .../images/pkg}/distro/rhel9/imagetype.go | 28 +- .../images/pkg}/distro/rhel9/package_sets.go | 4 +- .../pkg}/distro/rhel9/partition_tables.go | 8 +- .../osbuild/images/pkg}/distro/rhel9/qcow2.go | 12 +- .../osbuild/images/pkg}/distro/rhel9/sap.go | 6 +- .../osbuild/images/pkg}/distro/rhel9/vmdk.go | 8 +- .../images/pkg}/distro/test_distro/distro.go | 16 +- .../pkg}/distroregistry/distroregistry.go | 12 +- .../pkg}/image/anaconda_live_installer.go | 18 +- .../pkg}/image/anaconda_ostree_installer.go | 18 +- .../pkg}/image/anaconda_tar_installer.go | 20 +- .../osbuild/images/pkg}/image/archive.go | 14 +- .../osbuild/images/pkg}/image/container.go | 14 +- .../osbuild/images/pkg}/image/image.go | 8 +- .../osbuild/images/pkg}/image/live.go | 20 +- .../images/pkg}/image/ostree_archive.go | 16 +- .../images/pkg}/image/ostree_container.go | 16 +- .../osbuild/images/pkg}/image/ostree_raw.go | 20 +- .../pkg}/image/ostree_simplified_installer.go | 22 +- .../pkg}/manifest/anaconda_installer.go | 14 +- .../manifest/anaconda_installer_iso_tree.go | 12 +- .../osbuild/images/pkg}/manifest/build.go | 10 +- .../images/pkg}/manifest/coi_iso_tree.go | 6 +- .../osbuild/images/pkg}/manifest/commit.go | 2 +- .../pkg}/manifest/commit_server_tree.go | 12 +- .../images/pkg}/manifest/coreos_installer.go | 14 +- .../images/pkg}/manifest/efi_boot_tree.go | 4 +- .../osbuild/images/pkg}/manifest/empty.go | 8 +- .../osbuild/images/pkg}/manifest/iso.go | 4 +- .../images/pkg}/manifest/iso_rootfs.go | 2 +- .../osbuild/images/pkg}/manifest/manifest.go | 8 +- .../images/pkg}/manifest/oci_container.go | 4 +- .../osbuild/images/pkg}/manifest/os.go | 28 +- .../images/pkg}/manifest/ostree_deployment.go | 18 +- .../osbuild/images/pkg}/manifest/ovf.go | 2 +- .../osbuild/images/pkg}/manifest/pipeline.go | 12 +- .../osbuild/images/pkg}/manifest/qcow2.go | 4 +- .../osbuild/images/pkg}/manifest/raw.go | 6 +- .../images/pkg}/manifest/raw_ostree.go | 6 +- .../osbuild/images/pkg}/manifest/tar.go | 4 +- .../osbuild/images/pkg}/manifest/vmdk.go | 4 +- .../osbuild/images/pkg}/manifest/vpc.go | 4 +- .../osbuild/images/pkg}/manifest/xz.go | 4 +- .../images/pkg}/osbuild/anaconda_stage.go | 0 .../images/pkg}/osbuild/authconfig_stage.go | 0 .../images/pkg}/osbuild/authselect_stage.go | 0 .../images/pkg}/osbuild/bootiso_stage.go | 0 .../images/pkg}/osbuild/btrfs_mount.go | 0 .../images/pkg}/osbuild/buildstamp_stage.go | 0 .../images/pkg}/osbuild/chmod_stage.go | 0 .../images/pkg}/osbuild/chown_stage.go | 0 .../images/pkg}/osbuild/chrony_stage.go | 0 .../pkg}/osbuild/clevis_luks_bind_stage.go | 0 .../images/pkg}/osbuild/cloud_init_stage.go | 0 .../images/pkg}/osbuild/containers_input.go | 2 +- .../osbuild/containers_storage_conf_stage.go | 0 .../osbuild/images/pkg}/osbuild/copy_stage.go | 2 +- .../images/pkg}/osbuild/curl_source.go | 0 .../osbuild/images/pkg}/osbuild/device.go | 2 +- .../images/pkg}/osbuild/discinfo_stage.go | 0 .../osbuild/images/pkg}/osbuild/disk.go | 2 +- .../osbuild/dnf_automatic_config_stage.go | 0 .../images/pkg}/osbuild/dnf_config_stage.go | 0 .../images/pkg}/osbuild/dracut_conf_stage.go | 0 .../images/pkg}/osbuild/dracut_stage.go | 0 .../osbuild/images/pkg}/osbuild/ext4_mount.go | 0 .../osbuild/images/pkg}/osbuild/fat_mount.go | 0 .../osbuild/images/pkg}/osbuild/fdo_stage.go | 0 .../images/pkg}/osbuild/files_input.go | 2 +- .../images/pkg}/osbuild/firewall_stage.go | 0 .../images/pkg}/osbuild/first_boot_stage.go | 0 .../images/pkg}/osbuild/fix_bls_stage.go | 0 .../osbuild/images/pkg}/osbuild/fsnode.go | 2 +- .../images/pkg}/osbuild/fstab_stage.go | 2 +- .../osbuild/gcp_guest_agent_conf_stage.go | 0 .../images/pkg}/osbuild/groups_stage.go | 2 +- .../images/pkg}/osbuild/grub2_inst_stage.go | 2 +- .../images/pkg}/osbuild/grub2_legacy_stage.go | 4 +- .../images/pkg}/osbuild/grub2_stage.go | 6 +- .../images/pkg}/osbuild/grub_iso_stage.go | 0 .../images/pkg}/osbuild/hostname_stage.go | 0 .../images/pkg}/osbuild/ignition_stage.go | 0 .../pkg}/osbuild/implantisomd5_stage.go | 0 .../images/pkg}/osbuild/inline_source.go | 0 .../osbuild/images/pkg}/osbuild/input.go | 0 .../images/pkg}/osbuild/isolinux_stage.go | 0 .../pkg}/osbuild/kernel_cmdline_stage.go | 0 .../images/pkg}/osbuild/keymap_stage.go | 0 .../images/pkg}/osbuild/kickstart_stage.go | 2 +- .../images/pkg}/osbuild/locale_stage.go | 0 .../images/pkg}/osbuild/loopback_device.go | 0 .../images/pkg}/osbuild/lorax_script_stage.go | 0 .../images/pkg}/osbuild/luks2_device.go | 0 .../images/pkg}/osbuild/luks2_format_stage.go | 0 .../pkg}/osbuild/luks2_remove_key_stage.go | 0 .../images/pkg}/osbuild/lvm2_create_stage.go | 0 .../images/pkg}/osbuild/lvm2_lv_device.go | 0 .../pkg}/osbuild/lvm2_metadata_stage.go | 0 .../images/pkg}/osbuild/mkdir_stage.go | 0 .../images/pkg}/osbuild/mkfs_btrfs_stage.go | 0 .../images/pkg}/osbuild/mkfs_ext4_stage.go | 0 .../images/pkg}/osbuild/mkfs_fat_stage.go | 0 .../osbuild/images/pkg}/osbuild/mkfs_stage.go | 2 +- .../images/pkg}/osbuild/mkfs_xfs_stage.go | 0 .../images/pkg}/osbuild/modprobe_stage.go | 0 .../osbuild/images/pkg}/osbuild/mount.go | 0 .../images/pkg}/osbuild/nginxconf_stage.go | 0 .../images/pkg}/osbuild/oci_archive_stage.go | 0 .../images/pkg}/osbuild/osbuild-exec.go | 0 .../osbuild/images/pkg}/osbuild/osbuild.go | 0 .../pkg}/osbuild/oscap_remediation_stage.go | 0 .../pkg}/osbuild/ostree_commit_stage.go | 0 .../pkg}/osbuild/ostree_config_stage.go | 0 .../pkg}/osbuild/ostree_deploy_stage.go | 0 .../pkg}/osbuild/ostree_deployment_mount.go | 0 .../pkg}/osbuild/ostree_fillvar_stage.go | 0 .../pkg}/osbuild/ostree_init_fs_stage.go | 0 .../images/pkg}/osbuild/ostree_init_stage.go | 0 .../images/pkg}/osbuild/ostree_input.go | 0 .../pkg}/osbuild/ostree_os_init_stage.go | 0 .../pkg}/osbuild/ostree_passwd_stage.go | 0 .../pkg}/osbuild/ostree_preptree_stage.go | 0 .../images/pkg}/osbuild/ostree_pull_stage.go | 0 .../pkg}/osbuild/ostree_remotes_stage.go | 0 .../pkg}/osbuild/ostree_selinux_stage.go | 0 .../images/pkg}/osbuild/ostree_source.go | 0 .../osbuild/images/pkg}/osbuild/ovf_stage.go | 0 .../pkg}/osbuild/pam_limits_conf_stage.go | 0 .../pkg}/osbuild/pwquality_conf_stage.go | 0 .../osbuild/images/pkg}/osbuild/qemu_stage.go | 0 .../osbuild/images/pkg}/osbuild/result.go | 0 .../images/pkg}/osbuild/result_test_data.go | 0 .../images/pkg}/osbuild/rhsm_facts_stage.go | 0 .../osbuild/images/pkg}/osbuild/rhsm_stage.go | 0 .../osbuild/images/pkg}/osbuild/rpm_stage.go | 2 +- .../images/pkg}/osbuild/script_stage.go | 0 .../pkg}/osbuild/selinux_config_stage.go | 0 .../images/pkg}/osbuild/selinux_stage.go | 0 .../images/pkg}/osbuild/sfdisk_stage.go | 0 .../images/pkg}/osbuild/sgdisk_stage.go | 0 .../images/pkg}/osbuild/shell_init_stage.go | 2 +- .../pkg}/osbuild/skopeo_index_source.go | 0 .../images/pkg}/osbuild/skopeo_source.go | 0 .../images/pkg}/osbuild/skopeo_stage.go | 0 .../osbuild/images/pkg}/osbuild/source.go | 6 +- .../images/pkg}/osbuild/squashfs_stage.go | 0 .../images/pkg}/osbuild/sshd_config_stage.go | 0 .../osbuild/images/pkg}/osbuild/stage.go | 0 .../images/pkg}/osbuild/sysconfig_stage.go | 0 .../images/pkg}/osbuild/sysctld_stage.go | 0 .../pkg}/osbuild/systemd_journald_stage.go | 0 .../pkg}/osbuild/systemd_logind_stage.go | 0 .../images/pkg}/osbuild/systemd_stage.go | 0 .../images/pkg}/osbuild/systemd_unit_stage.go | 0 .../osbuild/images/pkg}/osbuild/tar_stage.go | 0 .../images/pkg}/osbuild/timezone_stage.go | 0 .../images/pkg}/osbuild/tmpfilesd_stage.go | 0 .../osbuild/images/pkg}/osbuild/tree_input.go | 0 .../images/pkg}/osbuild/truncate_stage.go | 0 .../images/pkg}/osbuild/tuned_stage.go | 0 .../images/pkg}/osbuild/udev_rules_stage.go | 8 +- .../images/pkg}/osbuild/users_stage.go | 4 +- .../osbuild/images/pkg}/osbuild/v1result.go | 0 .../images/pkg}/osbuild/waagent_conf.go | 0 .../osbuild/images/pkg}/osbuild/xfs_mount.go | 0 .../images/pkg}/osbuild/xorrisofs_stage.go | 0 .../osbuild/images/pkg}/osbuild/xz_stage.go | 0 .../images/pkg}/osbuild/yum_config_stage.go | 0 .../images/pkg}/osbuild/yum_repos_stage.go | 4 +- .../images/pkg}/osbuild/zipl_inst_stage.go | 2 +- .../osbuild/images/pkg}/osbuild/zipl_stage.go | 0 .../osbuild/images/pkg}/ostree/errors.go | 0 .../pkg}/ostree/mock_ostree_repo/mock_repo.go | 0 .../osbuild/images/pkg}/ostree/ostree.go | 2 +- .../osbuild/images/pkg/platform/aarch64.go | 62 + .../osbuild/images/pkg/platform/platform.go | 108 ++ .../osbuild/images/pkg/platform/ppc64le.go | 33 + .../osbuild/images/pkg/platform/s390x.go | 32 + .../osbuild/images/pkg/platform/x86_64.go | 52 + .../osbuild/images/pkg}/rhsm/facts/facts.go | 0 .../osbuild/images/pkg}/rhsm/secrets.go | 0 .../osbuild/images/pkg}/rpmmd/metadata.go | 0 .../osbuild/images/pkg}/rpmmd/repository.go | 0 .../osbuild/images/pkg/runner/centos.go | 39 + .../osbuild/images/pkg/runner/fedora.go | 19 + .../osbuild/images/pkg/runner/linux.go | 16 + .../osbuild/images/pkg/runner/rhel.go | 40 + .../osbuild/images/pkg/runner/runner.go | 6 + .../images/pkg}/subscription/subscription.go | 0 vendor/modules.txt | 38 + 446 files changed, 5690 insertions(+), 13312 deletions(-) create mode 100644 internal/cloudapi/v2/server.go.orig delete mode 100644 internal/container/client_test.go delete mode 100644 internal/container/container_test.go delete mode 100644 internal/container/resolver_test.go delete mode 100644 internal/crypt/crypt_test.go delete mode 100644 internal/disk/disk_test.go delete mode 100644 internal/disk/lvm_test.go delete mode 100644 internal/distro/distro_test.go delete mode 100644 internal/distro/fedora/distro_test.go delete mode 100644 internal/distro/image_config_test.go delete mode 100644 internal/distro/rhel7/distro_test.go delete mode 100644 internal/distro/rhel8/distro_internal_test.go delete mode 100644 internal/distro/rhel8/distro_test.go delete mode 100644 internal/distro/rhel9/distro_test.go delete mode 100644 internal/distroregistry/distroregistry_test.go delete mode 100644 internal/manifest/os_test.go delete mode 100644 internal/osbuild/authconfig_stage_test.go delete mode 100644 internal/osbuild/authselect_stage_test.go delete mode 100644 internal/osbuild/chown_stage_test.go delete mode 100644 internal/osbuild/chrony_stage_test.go delete mode 100644 internal/osbuild/cloud_init_stage_test.go delete mode 100644 internal/osbuild/common_test.go delete mode 100644 internal/osbuild/containers_storage_conf_stage_test.go delete mode 100644 internal/osbuild/copy_stage_test.go delete mode 100644 internal/osbuild/device_test.go delete mode 100644 internal/osbuild/disk_test.go delete mode 100644 internal/osbuild/dnf_automatic_config_stage_test.go delete mode 100644 internal/osbuild/dnf_config_stage_test.go delete mode 100644 internal/osbuild/dracut_conf_stage_test.go delete mode 100644 internal/osbuild/dracut_stage_test.go delete mode 100644 internal/osbuild/fdo_stage_test.go delete mode 100644 internal/osbuild/files_input_test.go delete mode 100644 internal/osbuild/firewall_stage_test.go delete mode 100644 internal/osbuild/first_boot_stage_test.go delete mode 100644 internal/osbuild/fix_bls_stage_test.go delete mode 100644 internal/osbuild/fsnode_test.go delete mode 100644 internal/osbuild/fstab_stage_test.go delete mode 100644 internal/osbuild/gcp_guest_agent_conf_stage_test.go delete mode 100644 internal/osbuild/groups_stage_test.go delete mode 100644 internal/osbuild/grub2_inst_stage_test.go delete mode 100644 internal/osbuild/grub2_legacy_stage_test.go delete mode 100644 internal/osbuild/grub2_stage_test.go delete mode 100644 internal/osbuild/hostname_stage_test.go delete mode 100644 internal/osbuild/inline_source_test.go delete mode 100644 internal/osbuild/kernel_cmdline_stage_test.go delete mode 100644 internal/osbuild/keymap_stage_test.go delete mode 100644 internal/osbuild/locale_stage_test.go delete mode 100644 internal/osbuild/lvm2_create_stage_test.go delete mode 100644 internal/osbuild/lvm2_lv_device_test.go delete mode 100644 internal/osbuild/lvm2_metadata_stage_test.go delete mode 100644 internal/osbuild/mkfs_stages_test.go delete mode 100644 internal/osbuild/modprobe_stage_test.go delete mode 100644 internal/osbuild/mount_test.go delete mode 100644 internal/osbuild/oci_archive_stage_test.go delete mode 100644 internal/osbuild/osbuild_test.go delete mode 100644 internal/osbuild/oscap_remediation_stage_test.go delete mode 100644 internal/osbuild/pam_limits_conf_stage_test.go delete mode 100644 internal/osbuild/pwquality_conf_stage_test.go delete mode 100644 internal/osbuild/qemu_stage_test.go delete mode 100644 internal/osbuild/result_test.go delete mode 100644 internal/osbuild/rhsm_facts_stage_test.go delete mode 100644 internal/osbuild/rhsm_stage_test.go delete mode 100644 internal/osbuild/rpm_stage_test.go delete mode 100644 internal/osbuild/script_stage_test.go delete mode 100644 internal/osbuild/selinux_config_stage_test.go delete mode 100644 internal/osbuild/selinux_stage_test.go delete mode 100644 internal/osbuild/sfdisk_stage_test.go delete mode 100644 internal/osbuild/sgdisk_stage_test.go delete mode 100644 internal/osbuild/shell_init_stage_test.go delete mode 100644 internal/osbuild/skopeo_source_test.go delete mode 100644 internal/osbuild/source_test.go delete mode 100644 internal/osbuild/sshd_config_stage_test.go delete mode 100644 internal/osbuild/sysconfig_stage_test.go delete mode 100644 internal/osbuild/sysctld_stage_test.go delete mode 100644 internal/osbuild/systemd_journald_stage_test.go delete mode 100644 internal/osbuild/systemd_logind_stage_test.go delete mode 100644 internal/osbuild/systemd_stage_test.go delete mode 100644 internal/osbuild/systemd_unit_stage_test.go delete mode 100644 internal/osbuild/tar_stage_test.go delete mode 100644 internal/osbuild/timezone_stage_test.go delete mode 100644 internal/osbuild/tmpfilesd_stage_test.go delete mode 100644 internal/osbuild/truncate_stage_test.go delete mode 100644 internal/osbuild/tuned_stage_test.go delete mode 100644 internal/osbuild/udev_rules_stage_test.go delete mode 100644 internal/osbuild/users_stage_test.go delete mode 100644 internal/osbuild/xz_stage_test.go delete mode 100644 internal/osbuild/yum_config_stage_test.go delete mode 100644 internal/osbuild/yum_repos_stage_test.go delete mode 100644 internal/osbuild/zipl_stage_test.go delete mode 100644 internal/ostree/ostree_test.go delete mode 100644 internal/ostree/test_mtls_server/ca.crt delete mode 100644 internal/ostree/test_mtls_server/client.crt delete mode 100644 internal/ostree/test_mtls_server/client.key delete mode 100644 internal/ostree/test_mtls_server/http_mtls_server.go delete mode 100644 internal/ostree/test_mtls_server/server.crt delete mode 100644 internal/ostree/test_mtls_server/server.key delete mode 100644 internal/rhsm/secrets_test.go delete mode 100644 internal/rpmmd/metadata_test.go delete mode 100644 internal/rpmmd/repository_test.go delete mode 100644 internal/rpmmd/test/confpaths/priority1/repositories/test-distro.json delete mode 100644 internal/rpmmd/test/confpaths/priority2/repositories/test-distro-2.json delete mode 100644 internal/rpmmd/test/confpaths/priority2/repositories/test-distro.json delete mode 100644 internal/rpmmd/test/repository_test.go create mode 100644 vendor/github.com/osbuild/images/LICENSE create mode 100644 vendor/github.com/osbuild/images/internal/common/constants.go create mode 100644 vendor/github.com/osbuild/images/internal/common/distro.go create mode 100644 vendor/github.com/osbuild/images/internal/common/echo_logrus.go create mode 100644 vendor/github.com/osbuild/images/internal/common/helpers.go create mode 100644 vendor/github.com/osbuild/images/internal/common/operation_id.go create mode 100644 vendor/github.com/osbuild/images/internal/common/pointers.go create mode 100644 vendor/github.com/osbuild/images/internal/common/states.go create mode 100644 vendor/github.com/osbuild/images/internal/dnfjson/cache.go create mode 100644 vendor/github.com/osbuild/images/internal/dnfjson/dnfjson.go create mode 100644 vendor/github.com/osbuild/images/internal/environment/azure.go create mode 100644 vendor/github.com/osbuild/images/internal/environment/ec2.go create mode 100644 vendor/github.com/osbuild/images/internal/environment/environment.go create mode 100644 vendor/github.com/osbuild/images/internal/environment/gcp.go create mode 100644 vendor/github.com/osbuild/images/internal/environment/openstack.go create mode 100644 vendor/github.com/osbuild/images/internal/environment/vsphere.go create mode 100644 vendor/github.com/osbuild/images/internal/fdo/fdo.go create mode 100644 vendor/github.com/osbuild/images/internal/fsnode/dir.go create mode 100644 vendor/github.com/osbuild/images/internal/fsnode/file.go create mode 100644 vendor/github.com/osbuild/images/internal/fsnode/fsnode.go create mode 100644 vendor/github.com/osbuild/images/internal/ignition/ignition.go create mode 100644 vendor/github.com/osbuild/images/internal/mocks/dnfjson/dnfjson.go create mode 100644 vendor/github.com/osbuild/images/internal/oscap/oscap.go create mode 100644 vendor/github.com/osbuild/images/internal/pathpolicy/path_policy.go create mode 100644 vendor/github.com/osbuild/images/internal/pathpolicy/path_trie.go create mode 100644 vendor/github.com/osbuild/images/internal/pathpolicy/policies.go create mode 100644 vendor/github.com/osbuild/images/internal/shell/shell.go create mode 100644 vendor/github.com/osbuild/images/internal/users/users.go create mode 100644 vendor/github.com/osbuild/images/internal/workload/anaconda.go create mode 100644 vendor/github.com/osbuild/images/internal/workload/custom.go create mode 100644 vendor/github.com/osbuild/images/internal/workload/sap.go create mode 100644 vendor/github.com/osbuild/images/internal/workload/static_webserver.go create mode 100644 vendor/github.com/osbuild/images/internal/workload/workload.go rename {internal => vendor/github.com/osbuild/images/pkg}/artifact/artifact.go (100%) create mode 100644 vendor/github.com/osbuild/images/pkg/blueprint/blueprint.go create mode 100644 vendor/github.com/osbuild/images/pkg/blueprint/customizations.go create mode 100644 vendor/github.com/osbuild/images/pkg/blueprint/filesystem_customizations.go create mode 100644 vendor/github.com/osbuild/images/pkg/blueprint/fsnode_customizations.go create mode 100644 vendor/github.com/osbuild/images/pkg/blueprint/repository_customizations.go rename {internal => vendor/github.com/osbuild/images/pkg}/container/client.go (99%) rename {internal => vendor/github.com/osbuild/images/pkg}/container/resolver.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/container/spec.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/crypt/crypt.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/crypt/crypt_impl.go (95%) rename {internal => vendor/github.com/osbuild/images/pkg}/crypt/crypt_impl_macos.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/disk/btrfs.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/disk/disk.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/disk/filesystem.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/disk/luks.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/disk/lvm.go (98%) rename {internal => vendor/github.com/osbuild/images/pkg}/disk/partition.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/disk/partition_table.go (99%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/distro.go (91%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/distro_test_common/distro_test_common.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/fedora/distro.go (98%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/fedora/images.go (95%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/fedora/imagetype.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/fedora/package_sets.go (98%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/fedora/partition_tables.go (95%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/image_config.go (95%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel7/azure.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel7/distro.go (94%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel7/images.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel7/imagetype.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel7/package_sets.go (83%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel7/partition_tables.go (87%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel7/qcow2.go (91%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/ami.go (98%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/arch.go (94%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/azure.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/bare_metal.go (98%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/distro.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/edge.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/gce.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/images.go (95%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/imagetype.go (94%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/package_sets.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/partition_tables.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/qcow2.go (93%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/sap.go (94%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/vmdk.go (93%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel8/workloads.go (88%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/ami.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/arch.go (93%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/azure.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/bare_metal.go (98%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/distro.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/edge.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/gce.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/images.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/imagetype.go (94%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/package_sets.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/partition_tables.go (94%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/qcow2.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/sap.go (95%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/rhel9/vmdk.go (90%) rename {internal => vendor/github.com/osbuild/images/pkg}/distro/test_distro/distro.go (95%) rename {internal => vendor/github.com/osbuild/images/pkg}/distroregistry/distroregistry.go (90%) rename {internal => vendor/github.com/osbuild/images/pkg}/image/anaconda_live_installer.go (85%) rename {internal => vendor/github.com/osbuild/images/pkg}/image/anaconda_ostree_installer.go (88%) rename {internal => vendor/github.com/osbuild/images/pkg}/image/anaconda_tar_installer.go (89%) rename {internal => vendor/github.com/osbuild/images/pkg}/image/archive.go (70%) rename {internal => vendor/github.com/osbuild/images/pkg}/image/container.go (71%) rename {internal => vendor/github.com/osbuild/images/pkg}/image/image.go (62%) rename {internal => vendor/github.com/osbuild/images/pkg}/image/live.go (87%) rename {internal => vendor/github.com/osbuild/images/pkg}/image/ostree_archive.go (76%) rename {internal => vendor/github.com/osbuild/images/pkg}/image/ostree_container.go (81%) rename {internal => vendor/github.com/osbuild/images/pkg}/image/ostree_raw.go (82%) rename {internal => vendor/github.com/osbuild/images/pkg}/image/ostree_simplified_installer.go (87%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/anaconda_installer.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/anaconda_installer_iso_tree.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/build.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/coi_iso_tree.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/commit.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/commit_server_tree.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/coreos_installer.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/efi_boot_tree.go (91%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/empty.go (90%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/iso.go (93%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/iso_rootfs.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/manifest.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/oci_container.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/os.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/ostree_deployment.go (94%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/ovf.go (95%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/pipeline.go (94%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/qcow2.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/raw.go (93%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/raw_ostree.go (95%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/tar.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/vmdk.go (91%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/vpc.go (92%) rename {internal => vendor/github.com/osbuild/images/pkg}/manifest/xz.go (90%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/anaconda_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/authconfig_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/authselect_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/bootiso_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/btrfs_mount.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/buildstamp_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/chmod_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/chown_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/chrony_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/clevis_luks_bind_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/cloud_init_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/containers_input.go (94%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/containers_storage_conf_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/copy_stage.go (98%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/curl_source.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/device.go (99%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/discinfo_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/disk.go (98%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/dnf_automatic_config_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/dnf_config_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/dracut_conf_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/dracut_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ext4_mount.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/fat_mount.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/fdo_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/files_input.go (99%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/firewall_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/first_boot_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/fix_bls_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/fsnode.go (98%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/fstab_stage.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/gcp_guest_agent_conf_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/groups_stage.go (94%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/grub2_inst_stage.go (98%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/grub2_legacy_stage.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/grub2_stage.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/grub_iso_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/hostname_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ignition_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/implantisomd5_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/inline_source.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/input.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/isolinux_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/kernel_cmdline_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/keymap_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/kickstart_stage.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/locale_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/loopback_device.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/lorax_script_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/luks2_device.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/luks2_format_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/luks2_remove_key_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/lvm2_create_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/lvm2_lv_device.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/lvm2_metadata_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/mkdir_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/mkfs_btrfs_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/mkfs_ext4_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/mkfs_fat_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/mkfs_stage.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/mkfs_xfs_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/modprobe_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/mount.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/nginxconf_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/oci_archive_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/osbuild-exec.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/osbuild.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/oscap_remediation_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_commit_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_config_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_deploy_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_deployment_mount.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_fillvar_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_init_fs_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_init_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_input.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_os_init_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_passwd_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_preptree_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_pull_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_remotes_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_selinux_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ostree_source.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/ovf_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/pam_limits_conf_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/pwquality_conf_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/qemu_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/result.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/result_test_data.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/rhsm_facts_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/rhsm_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/rpm_stage.go (98%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/script_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/selinux_config_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/selinux_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/sfdisk_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/sgdisk_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/shell_init_stage.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/skopeo_index_source.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/skopeo_source.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/skopeo_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/source.go (94%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/squashfs_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/sshd_config_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/sysconfig_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/sysctld_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/systemd_journald_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/systemd_logind_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/systemd_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/systemd_unit_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/tar_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/timezone_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/tmpfilesd_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/tree_input.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/truncate_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/tuned_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/udev_rules_stage.go (95%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/users_stage.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/v1result.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/waagent_conf.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/xfs_mount.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/xorrisofs_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/xz_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/yum_config_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/yum_repos_stage.go (97%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/zipl_inst_stage.go (96%) rename {internal => vendor/github.com/osbuild/images/pkg}/osbuild/zipl_stage.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/ostree/errors.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/ostree/mock_ostree_repo/mock_repo.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/ostree/ostree.go (99%) create mode 100644 vendor/github.com/osbuild/images/pkg/platform/aarch64.go create mode 100644 vendor/github.com/osbuild/images/pkg/platform/platform.go create mode 100644 vendor/github.com/osbuild/images/pkg/platform/ppc64le.go create mode 100644 vendor/github.com/osbuild/images/pkg/platform/s390x.go create mode 100644 vendor/github.com/osbuild/images/pkg/platform/x86_64.go rename {internal => vendor/github.com/osbuild/images/pkg}/rhsm/facts/facts.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/rhsm/secrets.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/rpmmd/metadata.go (100%) rename {internal => vendor/github.com/osbuild/images/pkg}/rpmmd/repository.go (100%) create mode 100644 vendor/github.com/osbuild/images/pkg/runner/centos.go create mode 100644 vendor/github.com/osbuild/images/pkg/runner/fedora.go create mode 100644 vendor/github.com/osbuild/images/pkg/runner/linux.go create mode 100644 vendor/github.com/osbuild/images/pkg/runner/rhel.go create mode 100644 vendor/github.com/osbuild/images/pkg/runner/runner.go rename {internal => vendor/github.com/osbuild/images/pkg}/subscription/subscription.go (100%) diff --git a/cmd/gen-manifests/main.go b/cmd/gen-manifests/main.go index ee1804aec..c8b5248e0 100644 --- a/cmd/gen-manifests/main.go +++ b/cmd/gen-manifests/main.go @@ -17,15 +17,15 @@ import ( "path/filepath" "strings" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rhsm/facts" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/dnfjson" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rhsm/facts" - "github.com/osbuild/osbuild-composer/internal/rpmmd" ) type multiValue []string diff --git a/cmd/osbuild-composer-image-definitions/main.go b/cmd/osbuild-composer-image-definitions/main.go index d695464a5..6e8022bf3 100644 --- a/cmd/osbuild-composer-image-definitions/main.go +++ b/cmd/osbuild-composer-image-definitions/main.go @@ -5,7 +5,7 @@ import ( "fmt" "os" - "github.com/osbuild/osbuild-composer/internal/distroregistry" + "github.com/osbuild/images/pkg/distroregistry" ) func main() { diff --git a/cmd/osbuild-composer-manifest-tests/main_test.go b/cmd/osbuild-composer-manifest-tests/main_test.go index 9ebe0d6b6..8e88d0aa8 100644 --- a/cmd/osbuild-composer-manifest-tests/main_test.go +++ b/cmd/osbuild-composer-manifest-tests/main_test.go @@ -10,8 +10,8 @@ import ( "strings" "testing" - "github.com/osbuild/osbuild-composer/internal/distro/distro_test_common" - "github.com/osbuild/osbuild-composer/internal/distroregistry" + "github.com/osbuild/images/pkg/distro/distro_test_common" + "github.com/osbuild/images/pkg/distroregistry" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/cmd/osbuild-composer/composer.go b/cmd/osbuild-composer/composer.go index af4dae521..79b6f75dd 100644 --- a/cmd/osbuild-composer/composer.go +++ b/cmd/osbuild-composer/composer.go @@ -21,10 +21,10 @@ import ( "github.com/osbuild/osbuild-composer/pkg/jobqueue" "github.com/osbuild/osbuild-composer/pkg/jobqueue/dbjobqueue" + "github.com/osbuild/images/pkg/distroregistry" "github.com/osbuild/osbuild-composer/internal/auth" "github.com/osbuild/osbuild-composer/internal/cloudapi" v2 "github.com/osbuild/osbuild-composer/internal/cloudapi/v2" - "github.com/osbuild/osbuild-composer/internal/distroregistry" "github.com/osbuild/osbuild-composer/internal/dnfjson" "github.com/osbuild/osbuild-composer/internal/jobqueue/fsjobqueue" "github.com/osbuild/osbuild-composer/internal/weldr" diff --git a/cmd/osbuild-dnf-json-tests/main_test.go b/cmd/osbuild-dnf-json-tests/main_test.go index ff2922b09..e1a9c2bab 100644 --- a/cmd/osbuild-dnf-json-tests/main_test.go +++ b/cmd/osbuild-dnf-json-tests/main_test.go @@ -10,13 +10,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/distro" - rhel "github.com/osbuild/osbuild-composer/internal/distro/rhel8" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/distro" + rhel "github.com/osbuild/images/pkg/distro/rhel8" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/dnfjson" - "github.com/osbuild/osbuild-composer/internal/ostree" "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" ) // This test loads all the repositories available in /repositories directory diff --git a/cmd/osbuild-koji-tests/main_test.go b/cmd/osbuild-koji-tests/main_test.go index b871b10f0..b11a82e54 100644 --- a/cmd/osbuild-koji-tests/main_test.go +++ b/cmd/osbuild-koji-tests/main_test.go @@ -23,7 +23,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/upload/koji" ) diff --git a/cmd/osbuild-koji/main.go b/cmd/osbuild-koji/main.go index 42da02c5d..e22dfc3fb 100644 --- a/cmd/osbuild-koji/main.go +++ b/cmd/osbuild-koji/main.go @@ -8,7 +8,7 @@ import ( "time" "github.com/google/uuid" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/upload/koji" "github.com/sirupsen/logrus" ) diff --git a/cmd/osbuild-package-sets/main.go b/cmd/osbuild-package-sets/main.go index 1da8c1711..27a742d2d 100644 --- a/cmd/osbuild-package-sets/main.go +++ b/cmd/osbuild-package-sets/main.go @@ -8,10 +8,9 @@ import ( "fmt" "os" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" - "github.com/osbuild/osbuild-composer/internal/ostree" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/ostree" ) func main() { @@ -53,7 +52,7 @@ func main() { URL: "https://example.com", // required by some image types }, } - manifest, _, err := image.Manifest(&blueprint.Blueprint{}, options, nil, 0) + manifest, _, err := image.Manifest(nil, options, nil, 0) if err != nil { panic(err) } diff --git a/cmd/osbuild-pipeline/main.go b/cmd/osbuild-pipeline/main.go index e9a2b8c26..be231721a 100644 --- a/cmd/osbuild-pipeline/main.go +++ b/cmd/osbuild-pipeline/main.go @@ -8,15 +8,15 @@ import ( "os" "path" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/ostree" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" "github.com/osbuild/osbuild-composer/internal/dnfjson" - "github.com/osbuild/osbuild-composer/internal/ostree" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/rpmmd" ) type repository struct { @@ -195,7 +195,8 @@ func main() { // let the cache grow to fit much more repository metadata than we usually allow solver.SetMaxCacheSize(3 * 1024 * 1024 * 1024) - manifest, _, err := imageType.Manifest(&composeRequest.Blueprint, options, repos, seedArg) + ibp := blueprint.Convert(composeRequest.Blueprint) + manifest, _, err := imageType.Manifest(&ibp, options, repos, seedArg) if err != nil { panic(err.Error()) } diff --git a/cmd/osbuild-playground/main.go b/cmd/osbuild-playground/main.go index 94897af8f..8f6a6ab6c 100644 --- a/cmd/osbuild-playground/main.go +++ b/cmd/osbuild-playground/main.go @@ -8,11 +8,11 @@ import ( "os" "path" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/image" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" - "github.com/osbuild/osbuild-composer/internal/image" - "github.com/osbuild/osbuild-composer/internal/rpmmd" ) var ImageTypes = make(map[string]image.ImageKind) diff --git a/cmd/osbuild-playground/my-container.go b/cmd/osbuild-playground/my-container.go index 6f4ea4ded..c297ecb31 100644 --- a/cmd/osbuild-playground/my-container.go +++ b/cmd/osbuild-playground/my-container.go @@ -3,11 +3,11 @@ package main import ( "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) // MyContainer contains the arguments passed in as a JSON blob. diff --git a/cmd/osbuild-playground/my-image.go b/cmd/osbuild-playground/my-image.go index 189bd7cfd..96414e70c 100644 --- a/cmd/osbuild-playground/my-image.go +++ b/cmd/osbuild-playground/my-image.go @@ -3,12 +3,12 @@ package main import ( "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) type MyImage struct { diff --git a/cmd/osbuild-playground/partitiontables.go b/cmd/osbuild-playground/partitiontables.go index b55a85626..652459107 100644 --- a/cmd/osbuild-playground/partitiontables.go +++ b/cmd/osbuild-playground/partitiontables.go @@ -1,6 +1,6 @@ package main -import "github.com/osbuild/osbuild-composer/internal/disk" +import "github.com/osbuild/images/pkg/disk" var basePT = disk.PartitionTable{ UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", diff --git a/cmd/osbuild-playground/playground.go b/cmd/osbuild-playground/playground.go index ffae7093b..594021edc 100644 --- a/cmd/osbuild-playground/playground.go +++ b/cmd/osbuild-playground/playground.go @@ -6,12 +6,12 @@ import ( "os" "path" - "github.com/osbuild/osbuild-composer/internal/distro" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/image" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/dnfjson" - "github.com/osbuild/osbuild-composer/internal/image" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/runner" ) diff --git a/cmd/osbuild-store-dump/main.go b/cmd/osbuild-store-dump/main.go index 1b766f9a3..fc20b6bf6 100644 --- a/cmd/osbuild-store-dump/main.go +++ b/cmd/osbuild-store-dump/main.go @@ -9,20 +9,21 @@ import ( "github.com/google/uuid" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/fedora" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/fedora" - "github.com/osbuild/osbuild-composer/internal/distroregistry" "github.com/osbuild/osbuild-composer/internal/dnfjson" - "github.com/osbuild/osbuild-composer/internal/manifest" "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/store" "github.com/osbuild/osbuild-composer/internal/target" ) func getManifest(bp blueprint.Blueprint, t distro.ImageType, a distro.Arch, d distro.Distro, cacheDir string, repos []rpmmd.RepoConfig) (manifest.OSBuildManifest, []rpmmd.PackageSpec) { - manifest, _, err := t.Manifest(&bp, distro.ImageOptions{}, repos, 0) + ibp := blueprint.Convert(bp) + manifest, _, err := t.Manifest(&ibp, distro.ImageOptions{}, repos, 0) if err != nil { panic(err) } diff --git a/cmd/osbuild-upload-container/main.go b/cmd/osbuild-upload-container/main.go index 61a329cd5..482be14f2 100644 --- a/cmd/osbuild-upload-container/main.go +++ b/cmd/osbuild-upload-container/main.go @@ -8,7 +8,7 @@ import ( "os/user" "path/filepath" - "github.com/osbuild/osbuild-composer/internal/container" + "github.com/osbuild/images/pkg/container" ) func main() { diff --git a/cmd/osbuild-worker/jobimpl-container-resolve.go b/cmd/osbuild-worker/jobimpl-container-resolve.go index 318db0798..002648b48 100644 --- a/cmd/osbuild-worker/jobimpl-container-resolve.go +++ b/cmd/osbuild-worker/jobimpl-container-resolve.go @@ -5,7 +5,7 @@ import ( "github.com/sirupsen/logrus" - "github.com/osbuild/osbuild-composer/internal/container" + "github.com/osbuild/images/pkg/container" "github.com/osbuild/osbuild-composer/internal/worker" "github.com/osbuild/osbuild-composer/internal/worker/clienterrors" ) diff --git a/cmd/osbuild-worker/jobimpl-depsolve.go b/cmd/osbuild-worker/jobimpl-depsolve.go index b5288f8f4..b316d6039 100644 --- a/cmd/osbuild-worker/jobimpl-depsolve.go +++ b/cmd/osbuild-worker/jobimpl-depsolve.go @@ -5,8 +5,8 @@ import ( "github.com/sirupsen/logrus" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/dnfjson" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/worker" "github.com/osbuild/osbuild-composer/internal/worker/clienterrors" ) diff --git a/cmd/osbuild-worker/jobimpl-koji-finalize.go b/cmd/osbuild-worker/jobimpl-koji-finalize.go index fc3a7b221..c7e8d2c7a 100644 --- a/cmd/osbuild-worker/jobimpl-koji-finalize.go +++ b/cmd/osbuild-worker/jobimpl-koji-finalize.go @@ -7,8 +7,8 @@ import ( "github.com/sirupsen/logrus" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/upload/koji" "github.com/osbuild/osbuild-composer/internal/worker" diff --git a/cmd/osbuild-worker/jobimpl-osbuild.go b/cmd/osbuild-worker/jobimpl-osbuild.go index 44fc06416..d06b89edd 100644 --- a/cmd/osbuild-worker/jobimpl-osbuild.go +++ b/cmd/osbuild-worker/jobimpl-osbuild.go @@ -12,8 +12,8 @@ import ( "path" "strings" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/osbuild" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/osbuild" "github.com/osbuild/osbuild-composer/internal/upload/oci" "github.com/google/uuid" diff --git a/cmd/osbuild-worker/jobimpl-ostree-resolve.go b/cmd/osbuild-worker/jobimpl-ostree-resolve.go index 93216d4c8..f23f1d3fd 100644 --- a/cmd/osbuild-worker/jobimpl-ostree-resolve.go +++ b/cmd/osbuild-worker/jobimpl-ostree-resolve.go @@ -5,7 +5,7 @@ import ( "github.com/sirupsen/logrus" - "github.com/osbuild/osbuild-composer/internal/ostree" + "github.com/osbuild/images/pkg/ostree" "github.com/osbuild/osbuild-composer/internal/worker" "github.com/osbuild/osbuild-composer/internal/worker/clienterrors" ) diff --git a/go.mod b/go.mod index d65fb1b15..b6ab9e298 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,6 @@ require ( github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 github.com/BurntSushi/toml v1.2.1 github.com/aws/aws-sdk-go v1.44.230 - github.com/containers/common v0.49.1 - github.com/containers/image/v5 v5.22.0 github.com/coreos/go-semver v0.3.1 github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f github.com/deepmap/oapi-codegen v1.8.2 @@ -31,10 +29,9 @@ require ( github.com/kolo/xmlrpc v0.0.0-20201022064351-38db28db192b github.com/labstack/echo/v4 v4.10.2 github.com/labstack/gommon v0.4.0 - github.com/opencontainers/go-digest v1.0.0 - github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 github.com/openshift-online/ocm-sdk-go v0.1.315 github.com/oracle/oci-go-sdk/v54 v54.0.0 + github.com/osbuild/images v0.0.0-20230710155525-7045e8251769 github.com/prometheus/client_golang v1.13.0 github.com/segmentio/ksuid v1.0.4 github.com/sirupsen/logrus v1.9.0 @@ -47,7 +44,6 @@ require ( golang.org/x/sync v0.2.0 golang.org/x/sys v0.8.0 google.golang.org/api v0.126.0 - gopkg.in/ini.v1 v1.67.0 ) require ( @@ -71,6 +67,8 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/containers/common v0.49.1 // indirect + github.com/containers/image/v5 v5.22.0 // indirect github.com/containers/libtrust v0.0.0-20200511145503-9c3a6c22cd9a // indirect github.com/containers/ocicrypt v1.1.5 // indirect github.com/containers/storage v1.42.0 // indirect @@ -125,6 +123,8 @@ require ( github.com/moby/sys/mountinfo v0.6.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect github.com/opencontainers/runc v1.1.5 // indirect github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -163,6 +163,7 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect google.golang.org/grpc v1.55.0 // indirect google.golang.org/protobuf v1.30.0 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 093c71dcd..e6f8ccf82 100644 --- a/go.sum +++ b/go.sum @@ -1090,6 +1090,8 @@ github.com/openshift-online/ocm-sdk-go v0.1.315/go.mod h1:KYOw8kAKAHyPrJcQoVR82C github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/oracle/oci-go-sdk/v54 v54.0.0 h1:CDLjeSejv2aDpElAJrhKpi6zvT/zhZCZuXchUUZ+LS4= github.com/oracle/oci-go-sdk/v54 v54.0.0/go.mod h1:+t+yvcFGVp+3ZnztnyxqXfQDsMlq8U25faBLa+mqCMc= +github.com/osbuild/images v0.0.0-20230710155525-7045e8251769 h1:+Q98coEA32epRH7CqbU/1OlP4UeI40o/lqj7ivZd8us= +github.com/osbuild/images v0.0.0-20230710155525-7045e8251769/go.mod h1:HT4eobIaYIL7CXyyg3Ol8m0Ao7yw5CVNh3BG7q0xLtk= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= diff --git a/internal/blueprint/blueprint.go b/internal/blueprint/blueprint.go index d1078781b..cd2eef12a 100644 --- a/internal/blueprint/blueprint.go +++ b/internal/blueprint/blueprint.go @@ -5,9 +5,10 @@ import ( "encoding/json" "fmt" - "github.com/osbuild/osbuild-composer/internal/crypt" + "github.com/osbuild/images/pkg/crypt" "github.com/coreos/go-semver/semver" + iblueprint "github.com/osbuild/images/pkg/blueprint" ) // A Blueprint is a high-level description of an image. @@ -182,3 +183,150 @@ func (b *Blueprint) CryptPasswords() error { return nil } + +func Convert(bp Blueprint) iblueprint.Blueprint { + pkgs := make([]iblueprint.Package, len(bp.Packages)) + for idx := range bp.Packages { + pkgs[idx] = iblueprint.Package(bp.Packages[idx]) + } + + modules := make([]iblueprint.Package, len(bp.Modules)) + for idx := range bp.Modules { + modules[idx] = iblueprint.Package(bp.Modules[idx]) + } + + groups := make([]iblueprint.Group, len(bp.Groups)) + for idx := range bp.Groups { + groups[idx] = iblueprint.Group(bp.Groups[idx]) + } + + containers := make([]iblueprint.Container, len(bp.Containers)) + for idx := range bp.Containers { + containers[idx] = iblueprint.Container(bp.Containers[idx]) + } + + customizations := iblueprint.Customizations{} + if c := bp.Customizations; c != nil { + customizations = iblueprint.Customizations{ + Hostname: c.Hostname, + InstallationDevice: c.InstallationDevice, + } + + if fdo := c.FDO; fdo != nil { + ifdo := iblueprint.FDOCustomization(*fdo) + customizations.FDO = &ifdo + } + if oscap := c.OpenSCAP; oscap != nil { + ioscap := iblueprint.OpenSCAPCustomization(*oscap) + customizations.OpenSCAP = &ioscap + } + if ign := c.Ignition; ign != nil { + iign := iblueprint.IgnitionCustomization{} + if embed := ign.Embedded; embed != nil { + iembed := iblueprint.EmbeddedIgnitionCustomization(*embed) + iign.Embedded = &iembed + } + if fb := ign.FirstBoot; fb != nil { + ifb := iblueprint.FirstBootIgnitionCustomization(*fb) + iign.FirstBoot = &ifb + } + customizations.Ignition = &iign + } + if dirs := c.Directories; dirs != nil { + idirs := make([]iblueprint.DirectoryCustomization, len(dirs)) + for idx := range dirs { + idirs[idx] = iblueprint.DirectoryCustomization(dirs[idx]) + } + customizations.Directories = idirs + } + if files := c.Files; files != nil { + ifiles := make([]iblueprint.FileCustomization, len(files)) + for idx := range files { + ifiles[idx] = iblueprint.FileCustomization(files[idx]) + } + customizations.Files = ifiles + } + if repos := c.Repositories; repos != nil { + irepos := make([]iblueprint.RepositoryCustomization, len(repos)) + for idx := range repos { + irepos[idx] = iblueprint.RepositoryCustomization(repos[idx]) + } + customizations.Repositories = irepos + } + if kernel := c.Kernel; kernel != nil { + ikernel := iblueprint.KernelCustomization(*kernel) + customizations.Kernel = &ikernel + } + if sshkeys := c.SSHKey; sshkeys != nil { + isshkeys := make([]iblueprint.SSHKeyCustomization, len(sshkeys)) + for idx := range sshkeys { + isshkeys[idx] = iblueprint.SSHKeyCustomization(sshkeys[idx]) + } + customizations.SSHKey = isshkeys + } + if users := c.User; users != nil { + iusers := make([]iblueprint.UserCustomization, len(users)) + for idx := range users { + iusers[idx] = iblueprint.UserCustomization(users[idx]) + } + customizations.User = iusers + } + if groups := c.Group; groups != nil { + igroups := make([]iblueprint.GroupCustomization, len(groups)) + for idx := range groups { + igroups[idx] = iblueprint.GroupCustomization(groups[idx]) + } + customizations.Group = igroups + } + if fs := c.Filesystem; fs != nil { + ifs := make([]iblueprint.FilesystemCustomization, len(fs)) + for idx := range fs { + ifs[idx] = iblueprint.FilesystemCustomization(fs[idx]) + } + customizations.Filesystem = ifs + } + if tz := c.Timezone; tz != nil { + itz := iblueprint.TimezoneCustomization(*tz) + customizations.Timezone = &itz + } + if locale := c.Locale; locale != nil { + ilocale := iblueprint.LocaleCustomization(*locale) + customizations.Locale = &ilocale + } + if fw := c.Firewall; fw != nil { + ifw := iblueprint.FirewallCustomization{ + Ports: fw.Ports, + } + if services := fw.Services; services != nil { + iservices := iblueprint.FirewallServicesCustomization(*services) + ifw.Services = &iservices + } + if zones := fw.Zones; zones != nil { + izones := make([]iblueprint.FirewallZoneCustomization, len(zones)) + for idx := range zones { + izones[idx] = iblueprint.FirewallZoneCustomization(zones[idx]) + } + ifw.Zones = izones + } + customizations.Firewall = &ifw + } + if services := c.Services; services != nil { + iservices := iblueprint.ServicesCustomization(*services) + customizations.Services = &iservices + } + } + + ibp := iblueprint.Blueprint{ + Name: bp.Name, + Description: bp.Description, + Version: bp.Version, + Packages: pkgs, + Modules: modules, + Groups: groups, + Containers: containers, + Customizations: &customizations, + Distro: bp.Distro, + } + + return ibp +} diff --git a/internal/blueprint/repository_customizations.go b/internal/blueprint/repository_customizations.go index a5ebb5c5d..153798a3c 100644 --- a/internal/blueprint/repository_customizations.go +++ b/internal/blueprint/repository_customizations.go @@ -6,9 +6,9 @@ import ( "regexp" "strings" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/common" "github.com/osbuild/osbuild-composer/internal/fsnode" - "github.com/osbuild/osbuild-composer/internal/rpmmd" ) type RepositoryCustomization struct { diff --git a/internal/blueprint/repository_customizations_test.go b/internal/blueprint/repository_customizations_test.go index e76c50e95..71718b4fa 100644 --- a/internal/blueprint/repository_customizations_test.go +++ b/internal/blueprint/repository_customizations_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/common" "github.com/osbuild/osbuild-composer/internal/fsnode" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/stretchr/testify/assert" ) diff --git a/internal/client/modules.go b/internal/client/modules.go index c95f4c5c7..0e237fff7 100644 --- a/internal/client/modules.go +++ b/internal/client/modules.go @@ -8,7 +8,7 @@ import ( "net/http" // "strings" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/weldr" ) diff --git a/internal/client/projects.go b/internal/client/projects.go index 5a99343c4..88497efe8 100644 --- a/internal/client/projects.go +++ b/internal/client/projects.go @@ -8,7 +8,7 @@ import ( "net/http" // "strings" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/weldr" ) diff --git a/internal/client/unit_test.go b/internal/client/unit_test.go index 4771d7a61..3617bdd6c 100644 --- a/internal/client/unit_test.go +++ b/internal/client/unit_test.go @@ -16,13 +16,13 @@ import ( "path/filepath" "testing" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" + "github.com/osbuild/images/pkg/distro/test_distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/dnfjson" dnfjson_mock "github.com/osbuild/osbuild-composer/internal/mocks/dnfjson" rpmmd_mock "github.com/osbuild/osbuild-composer/internal/mocks/rpmmd" "github.com/osbuild/osbuild-composer/internal/reporegistry" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/weldr" ) diff --git a/internal/cloudapi/server.go b/internal/cloudapi/server.go index 4c515ea1b..a6fa0f4d3 100644 --- a/internal/cloudapi/server.go +++ b/internal/cloudapi/server.go @@ -3,7 +3,7 @@ package cloudapi import ( "net/http" - "github.com/osbuild/osbuild-composer/internal/distroregistry" + "github.com/osbuild/images/pkg/distroregistry" "github.com/osbuild/osbuild-composer/internal/worker" v2 "github.com/osbuild/osbuild-composer/internal/cloudapi/v2" diff --git a/internal/cloudapi/v2/handler.go b/internal/cloudapi/v2/handler.go index 248fe281f..82c336ab7 100644 --- a/internal/cloudapi/v2/handler.go +++ b/internal/cloudapi/v2/handler.go @@ -15,15 +15,15 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rhsm/facts" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rhsm/facts" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/subscription" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/worker" "github.com/osbuild/osbuild-composer/internal/worker/clienterrors" diff --git a/internal/cloudapi/v2/server.go b/internal/cloudapi/v2/server.go index 30ae4e542..45c12ad6b 100644 --- a/internal/cloudapi/v2/server.go +++ b/internal/cloudapi/v2/server.go @@ -19,14 +19,14 @@ import ( "github.com/osbuild/osbuild-composer/pkg/jobqueue" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" "github.com/osbuild/osbuild-composer/internal/auth" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/ostree" "github.com/osbuild/osbuild-composer/internal/prometheus" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/worker" @@ -117,7 +117,8 @@ func (s *Server) enqueueCompose(distribution distro.Distro, bp blueprint.Bluepri } ir := irs[0] - manifestSource, _, err := ir.imageType.Manifest(&bp, ir.imageOptions, ir.repositories, manifestSeed) + ibp := blueprint.Convert(bp) + manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, manifestSeed) if err != nil { return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) } @@ -237,7 +238,8 @@ func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, releas var kojiFilenames []string var buildIDs []uuid.UUID for _, ir := range irs { - manifestSource, _, err := ir.imageType.Manifest(&bp, ir.imageOptions, ir.repositories, manifestSeed) + ibp := blueprint.Convert(bp) + manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, manifestSeed) if err != nil { return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) } diff --git a/internal/cloudapi/v2/server.go.orig b/internal/cloudapi/v2/server.go.orig new file mode 100644 index 000000000..31db7a9d1 --- /dev/null +++ b/internal/cloudapi/v2/server.go.orig @@ -0,0 +1,564 @@ +package v2 + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "strings" + "sync" + "time" + + "github.com/getkin/kin-openapi/openapi3" + "github.com/getkin/kin-openapi/routers" + legacyrouter "github.com/getkin/kin-openapi/routers/legacy" + "github.com/google/uuid" + "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4/middleware" + "github.com/sirupsen/logrus" + + "github.com/osbuild/osbuild-composer/pkg/jobqueue" + +<<<<<<< HEAD + "github.com/osbuild/osbuild-composer/internal/auth" +======= + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" +>>>>>>> 294a8e564 (split: wip) + "github.com/osbuild/osbuild-composer/internal/blueprint" + "github.com/osbuild/osbuild-composer/internal/common" + "github.com/osbuild/osbuild-composer/internal/prometheus" + "github.com/osbuild/osbuild-composer/internal/target" + "github.com/osbuild/osbuild-composer/internal/worker" + "github.com/osbuild/osbuild-composer/internal/worker/clienterrors" +) + +// Server represents the state of the cloud Server +type Server struct { + workers *worker.Server + distros *distroregistry.Registry + config ServerConfig + router routers.Router + + goroutinesCtx context.Context + goroutinesCtxCancel context.CancelFunc + goroutinesGroup sync.WaitGroup +} + +type ServerConfig struct { + TenantProviderFields []string + JWTEnabled bool +} + +func NewServer(workers *worker.Server, distros *distroregistry.Registry, config ServerConfig) *Server { + ctx, cancel := context.WithCancel(context.Background()) + spec, err := GetSwagger() + if err != nil { + panic(err) + } + + loader := openapi3.NewLoader() + if err := spec.Validate(loader.Context); err != nil { + panic(err) + } + + router, err := legacyrouter.NewRouter(spec) + if err != nil { + panic(err) + } + + server := &Server{ + workers: workers, + distros: distros, + config: config, + router: router, + + goroutinesCtx: ctx, + goroutinesCtxCancel: cancel, + } + return server +} + +func (s *Server) Handler(path string) http.Handler { + e := echo.New() + e.Binder = binder{} + e.HTTPErrorHandler = s.HTTPErrorHandler + e.Pre(common.OperationIDMiddleware) + e.Use(middleware.Recover()) + e.Logger = common.Logger() + + handler := apiHandlers{ + server: s, + } + + mws := []echo.MiddlewareFunc{ + prometheus.StatusMiddleware(prometheus.ComposerSubsystem), + } + if s.config.JWTEnabled { + mws = append(mws, auth.TenantChannelMiddleware(s.config.TenantProviderFields, HTTPError(ErrorTenantNotFound))) + } + mws = append(mws, + prometheus.HTTPDurationMiddleware(prometheus.ComposerSubsystem), + prometheus.MetricsMiddleware, s.ValidateRequest) + RegisterHandlers(e.Group(path, mws...), &handler) + + return e +} + +func (s *Server) Shutdown() { + s.goroutinesCtxCancel() + s.goroutinesGroup.Wait() +} + +func (s *Server) enqueueCompose(distribution distro.Distro, bp blueprint.Blueprint, manifestSeed int64, irs []imageRequest, channel string) (uuid.UUID, error) { + var id uuid.UUID + if len(irs) != 1 { + return id, HTTPError(ErrorInvalidNumberOfImageBuilds) + } + ir := irs[0] + + ibp := blueprint.Convert(bp) + manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, manifestSeed) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + + depsolveJobID, err := s.workers.EnqueueDepsolve(&worker.DepsolveJob{ + PackageSets: manifestSource.GetPackageSetChains(), + ModulePlatformID: distribution.ModulePlatformID(), + Arch: ir.arch.Name(), + Releasever: distribution.Releasever(), + }, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + dependencies := []uuid.UUID{depsolveJobID} + + var containerResolveJobID uuid.UUID + containerSources := manifestSource.GetContainerSourceSpecs() + if len(containerSources) > 1 { + // only one pipeline can embed containers + pipelines := make([]string, 0, len(containerSources)) + for name := range containerSources { + pipelines = append(pipelines, name) + } + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, fmt.Errorf("manifest returned %d pipelines with containers (at most 1 is supported): %s", len(containerSources), strings.Join(pipelines, ", "))) + } + + for _, sources := range containerSources { + workerResolveSpecs := make([]worker.ContainerSpec, len(sources)) + for idx, source := range sources { + workerResolveSpecs[idx] = worker.ContainerSpec{ + Source: source.Source, + Name: source.Name, + TLSVerify: source.TLSVerify, + } + } + + job := worker.ContainerResolveJob{ + Arch: ir.arch.Name(), + Specs: workerResolveSpecs, + } + + jobId, err := s.workers.EnqueueContainerResolveJob(&job, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + + containerResolveJobID = jobId + dependencies = append(dependencies, containerResolveJobID) + break // there can be only one + } + + var ostreeResolveJobID uuid.UUID + commitSources := manifestSource.GetOSTreeSourceSpecs() + if len(commitSources) > 1 { + // only one pipeline can specify an ostree commit for content + pipelines := make([]string, 0, len(commitSources)) + for name := range commitSources { + pipelines = append(pipelines, name) + } + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, fmt.Errorf("manifest returned %d pipelines with ostree commits (at most 1 is supported): %s", len(commitSources), strings.Join(pipelines, ", "))) + } + for _, sources := range commitSources { + workerResolveSpecs := make([]worker.OSTreeResolveSpec, len(sources)) + for idx, source := range sources { + // ostree.SourceSpec is directly convertible to worker.OSTreeResolveSpec + workerResolveSpecs[idx] = worker.OSTreeResolveSpec(source) + } + jobID, err := s.workers.EnqueueOSTreeResolveJob(&worker.OSTreeResolveJob{Specs: workerResolveSpecs}, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + + ostreeResolveJobID = jobID + dependencies = append(dependencies, ostreeResolveJobID) + break // there can be only one + } + + manifestJobID, err := s.workers.EnqueueManifestJobByID(&worker.ManifestJobByID{}, dependencies, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + + id, err = s.workers.EnqueueOSBuildAsDependency(ir.arch.Name(), &worker.OSBuildJob{ + Targets: []*target.Target{ir.target}, + PipelineNames: &worker.PipelineNames{ + Build: ir.imageType.BuildPipelines(), + Payload: ir.imageType.PayloadPipelines(), + }, + }, []uuid.UUID{manifestJobID}, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + + s.goroutinesGroup.Add(1) + go func() { + serializeManifest(s.goroutinesCtx, manifestSource, s.workers, depsolveJobID, containerResolveJobID, ostreeResolveJobID, manifestJobID, manifestSeed) + defer s.goroutinesGroup.Done() + }() + + return id, nil +} + +func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, release string, distribution distro.Distro, bp blueprint.Blueprint, manifestSeed int64, irs []imageRequest, channel string) (uuid.UUID, error) { + var id uuid.UUID + kojiDirectory := "osbuild-cg/osbuild-composer-koji-" + uuid.New().String() + + initID, err := s.workers.EnqueueKojiInit(&worker.KojiInitJob{ + Server: server, + Name: name, + Version: version, + Release: release, + }, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + + var kojiFilenames []string + var buildIDs []uuid.UUID + for _, ir := range irs { + ibp := blueprint.Convert(bp) + manifestSource, _, err := ir.imageType.Manifest(&ibp, ir.imageOptions, ir.repositories, manifestSeed) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + + depsolveJobID, err := s.workers.EnqueueDepsolve(&worker.DepsolveJob{ + PackageSets: manifestSource.GetPackageSetChains(), + ModulePlatformID: distribution.ModulePlatformID(), + Arch: ir.arch.Name(), + Releasever: distribution.Releasever(), + }, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + dependencies := []uuid.UUID{depsolveJobID} + + var containerResolveJobID uuid.UUID + containerSources := manifestSource.GetContainerSourceSpecs() + if len(containerSources) > 1 { + // only one pipeline can embed containers + pipelines := make([]string, 0, len(containerSources)) + for name := range containerSources { + pipelines = append(pipelines, name) + } + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, fmt.Errorf("manifest returned %d pipelines with containers (at most 1 is supported): %s", len(containerSources), strings.Join(pipelines, ", "))) + } + + for _, sources := range containerSources { + workerResolveSpecs := make([]worker.ContainerSpec, len(sources)) + for idx, source := range sources { + workerResolveSpecs[idx] = worker.ContainerSpec{ + Source: source.Source, + Name: source.Name, + TLSVerify: source.TLSVerify, + } + } + + job := worker.ContainerResolveJob{ + Arch: ir.arch.Name(), + Specs: make([]worker.ContainerSpec, len(bp.Containers)), + } + + jobId, err := s.workers.EnqueueContainerResolveJob(&job, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + + containerResolveJobID = jobId + dependencies = append(dependencies, containerResolveJobID) + break // there can be only one + } + + var ostreeResolveJobID uuid.UUID + commitSources := manifestSource.GetOSTreeSourceSpecs() + if len(commitSources) > 1 { + // only one pipeline can specify an ostree commit for content + pipelines := make([]string, 0, len(commitSources)) + for name := range commitSources { + pipelines = append(pipelines, name) + } + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, fmt.Errorf("manifest returned %d pipelines with ostree commits (at most 1 is supported): %s", len(commitSources), strings.Join(pipelines, ", "))) + } + for _, sources := range commitSources { + workerResolveSpecs := make([]worker.OSTreeResolveSpec, len(sources)) + for idx, source := range sources { + // ostree.SourceSpec is directly convertible to worker.OSTreeResolveSpec + workerResolveSpecs[idx] = worker.OSTreeResolveSpec(source) + } + jobID, err := s.workers.EnqueueOSTreeResolveJob(&worker.OSTreeResolveJob{Specs: workerResolveSpecs}, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + + ostreeResolveJobID = jobID + dependencies = append(dependencies, ostreeResolveJobID) + break // there can be only one + } + + manifestJobID, err := s.workers.EnqueueManifestJobByID(&worker.ManifestJobByID{}, dependencies, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + kojiFilename := fmt.Sprintf( + "%s-%s-%s.%s%s", + name, + version, + release, + ir.arch.Name(), + splitExtension(ir.imageType.Filename()), + ) + + kojiTarget := target.NewKojiTarget(&target.KojiTargetOptions{ + Server: server, + UploadDirectory: kojiDirectory, + }) + kojiTarget.OsbuildArtifact.ExportFilename = ir.imageType.Filename() + kojiTarget.OsbuildArtifact.ExportName = ir.imageType.Exports()[0] + kojiTarget.ImageName = kojiFilename + + targets := []*target.Target{kojiTarget} + // add any cloud upload target if defined + if ir.target != nil { + targets = append(targets, ir.target) + } + + buildID, err := s.workers.EnqueueOSBuildAsDependency(ir.arch.Name(), &worker.OSBuildJob{ + PipelineNames: &worker.PipelineNames{ + Build: ir.imageType.BuildPipelines(), + Payload: ir.imageType.PayloadPipelines(), + }, + Targets: targets, + ManifestDynArgsIdx: common.ToPtr(1), + }, []uuid.UUID{initID, manifestJobID}, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + kojiFilenames = append(kojiFilenames, kojiFilename) + buildIDs = append(buildIDs, buildID) + + // copy the image request while passing it into the goroutine to prevent data races + s.goroutinesGroup.Add(1) + go func(ir imageRequest) { + serializeManifest(s.goroutinesCtx, manifestSource, s.workers, depsolveJobID, containerResolveJobID, ostreeResolveJobID, manifestJobID, manifestSeed) + defer s.goroutinesGroup.Done() + }(ir) + } + id, err = s.workers.EnqueueKojiFinalize(&worker.KojiFinalizeJob{ + Server: server, + Name: name, + Version: version, + Release: release, + KojiFilenames: kojiFilenames, + KojiDirectory: kojiDirectory, + TaskID: taskID, + StartTime: uint64(time.Now().Unix()), + }, initID, buildIDs, channel) + if err != nil { + return id, HTTPErrorWithInternal(ErrorEnqueueingJob, err) + } + + return id, nil +} + +func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, workers *worker.Server, depsolveJobID, containerResolveJobID, ostreeResolveJobID, manifestJobID uuid.UUID, seed int64) { + ctx, cancel := context.WithTimeout(ctx, time.Minute*5) + defer cancel() + + // wait until job is in a pending state + var token uuid.UUID + var dynArgs []json.RawMessage + var err error + logWithId := logrus.WithField("jobId", manifestJobID) + for { + _, token, _, _, dynArgs, err = workers.RequestJobById(ctx, "", manifestJobID) + if err == jobqueue.ErrNotPending { + logWithId.Debug("Manifest job not pending, waiting for depsolve job to finish") + time.Sleep(time.Millisecond * 50) + select { + case <-ctx.Done(): + logWithId.Warning("Manifest job dependencies took longer than 5 minutes to finish, or the server is shutting down, returning to avoid dangling routines") + break + default: + continue + } + } + if err != nil { + logWithId.Errorf("Error requesting manifest job: %v", err) + return + } + break + } + + jobResult := &worker.ManifestJobByIDResult{ + Manifest: nil, + } + + defer func() { + if jobResult.JobError != nil { + logWithId.Errorf("Error in manifest job %v: %v", jobResult.JobError.Reason, err) + } + + result, err := json.Marshal(jobResult) + if err != nil { + logWithId.Errorf("Error marshalling manifest job results: %v", err) + } + + err = workers.FinishJob(token, result) + if err != nil { + logWithId.Errorf("Error finishing manifest job: %v", err) + } + }() + + if len(dynArgs) == 0 { + reason := "No dynamic arguments" + jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorNoDynamicArgs, reason, nil) + return + } + + var depsolveResults worker.DepsolveJobResult + err = json.Unmarshal(dynArgs[0], &depsolveResults) + if err != nil { + reason := "Error parsing dynamic arguments" + jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, reason, nil) + return + } + + _, err = workers.DepsolveJobInfo(depsolveJobID, &depsolveResults) + if err != nil { + reason := "Error reading depsolve status" + jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorReadingJobStatus, reason, nil) + return + } + + if jobErr := depsolveResults.JobError; jobErr != nil { + if jobErr.ID == clienterrors.ErrorDNFDepsolveError || jobErr.ID == clienterrors.ErrorDNFMarkingErrors { + jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency input, bad package set requested", nil) + return + } + jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency", nil) + return + } + + if len(depsolveResults.PackageSpecs) == 0 { + jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyPackageSpecs, "Received empty package specs", nil) + return + } + + var containerSpecs map[string][]container.Spec + if containerResolveJobID != uuid.Nil { + // Container resolve job + var result worker.ContainerResolveJobResult + _, err := workers.ContainerResolveJobInfo(containerResolveJobID, &result) + + if err != nil { + reason := "Error reading container resolve job status" + jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorReadingJobStatus, reason, nil) + return + } + + if jobErr := result.JobError; jobErr != nil { + jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorContainerDependency, "Error in container resolve job dependency", nil) + return + } + + // NOTE: The container resolve job doesn't hold the pipeline name for + // the container embedding, so we need to get it from the manifest + // content field. There should be only one. + var containerEmbedPipeline string + for name := range manifestSource.GetContainerSourceSpecs() { + containerEmbedPipeline = name + break + } + + pipelineSpecs := make([]container.Spec, len(result.Specs)) + for idx, resultSpec := range result.Specs { + pipelineSpecs[idx] = container.Spec{ + Source: resultSpec.Source, + Digest: resultSpec.Digest, + LocalName: resultSpec.Name, + TLSVerify: resultSpec.TLSVerify, + ImageID: resultSpec.ImageID, + ListDigest: resultSpec.ListDigest, + } + + } + containerSpecs = map[string][]container.Spec{ + containerEmbedPipeline: pipelineSpecs, + } + } + + var ostreeCommitSpecs map[string][]ostree.CommitSpec + if ostreeResolveJobID != uuid.Nil { + var result worker.OSTreeResolveJobResult + _, err := workers.OSTreeResolveJobInfo(ostreeResolveJobID, &result) + + if err != nil { + reason := "Error reading ostree resolve job status" + logrus.Errorf("%s: %v", reason, err) + jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorReadingJobStatus, reason, nil) + return + } + + if jobErr := result.JobError; jobErr != nil { + jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorOSTreeDependency, "Error in ostree resolve job dependency", nil) + return + } + + // NOTE: The ostree resolve job doesn't hold the pipeline name for the + // ostree commits, so we need to get it from the manifest content + // field. There should be only one. + var ostreeCommitPipeline string + for name := range manifestSource.GetOSTreeSourceSpecs() { + ostreeCommitPipeline = name + break + } + + commitSpecs := make([]ostree.CommitSpec, len(result.Specs)) + for idx, resultSpec := range result.Specs { + commitSpecs[idx] = ostree.CommitSpec{ + Ref: resultSpec.Ref, + URL: resultSpec.URL, + Checksum: resultSpec.Checksum, + } + if resultSpec.RHSM { + // NOTE: Older workers don't set the Secrets string in the result + // spec so let's add it here for backwards compatibility. This + // should be removed after a few versions when all workers have + // been updated. + resultSpec.Secrets = "org.osbuild.rhsm.consumer" + } + } + ostreeCommitSpecs = map[string][]ostree.CommitSpec{ + ostreeCommitPipeline: commitSpecs, + } + } + + ms, err := manifestSource.Serialize(depsolveResults.PackageSpecs, containerSpecs, ostreeCommitSpecs) + + jobResult.Manifest = ms +} diff --git a/internal/cloudapi/v2/v2_internal_test.go b/internal/cloudapi/v2/v2_internal_test.go index 8c004faf9..9bde9d10a 100644 --- a/internal/cloudapi/v2/v2_internal_test.go +++ b/internal/cloudapi/v2/v2_internal_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/rpmmd" ) func TestSplitExtension(t *testing.T) { diff --git a/internal/cloudapi/v2/v2_koji_test.go b/internal/cloudapi/v2/v2_koji_test.go index 44661e51a..27d638190 100644 --- a/internal/cloudapi/v2/v2_koji_test.go +++ b/internal/cloudapi/v2/v2_koji_test.go @@ -11,9 +11,9 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/require" + "github.com/osbuild/images/pkg/distro/test_distro" + "github.com/osbuild/images/pkg/osbuild" v2 "github.com/osbuild/osbuild-composer/internal/cloudapi/v2" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/test" "github.com/osbuild/osbuild-composer/internal/worker" diff --git a/internal/cloudapi/v2/v2_multi_tenancy_test.go b/internal/cloudapi/v2/v2_multi_tenancy_test.go index 452970cfc..22e79de83 100644 --- a/internal/cloudapi/v2/v2_multi_tenancy_test.go +++ b/internal/cloudapi/v2/v2_multi_tenancy_test.go @@ -15,8 +15,8 @@ import ( "github.com/osbuild/osbuild-composer/pkg/jobqueue" + "github.com/osbuild/images/pkg/distro/test_distro" "github.com/osbuild/osbuild-composer/internal/cloudapi/v2" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" "github.com/osbuild/osbuild-composer/internal/test" "github.com/osbuild/osbuild-composer/internal/worker" ) diff --git a/internal/cloudapi/v2/v2_test.go b/internal/cloudapi/v2/v2_test.go index ad2496a62..e8412eaa0 100644 --- a/internal/cloudapi/v2/v2_test.go +++ b/internal/cloudapi/v2/v2_test.go @@ -12,13 +12,13 @@ import ( "github.com/osbuild/osbuild-composer/pkg/jobqueue" + "github.com/osbuild/images/pkg/distro/test_distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree/mock_ostree_repo" + "github.com/osbuild/images/pkg/rpmmd" v2 "github.com/osbuild/osbuild-composer/internal/cloudapi/v2" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" "github.com/osbuild/osbuild-composer/internal/jobqueue/fsjobqueue" distro_mock "github.com/osbuild/osbuild-composer/internal/mocks/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree/mock_ostree_repo" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/test" "github.com/osbuild/osbuild-composer/internal/worker" diff --git a/internal/container/client_test.go b/internal/container/client_test.go deleted file mode 100644 index 69d76ab0d..000000000 --- a/internal/container/client_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package container_test - -import ( - "context" - "os" - "testing" - "time" - - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/stretchr/testify/assert" -) - -// - -func TestClientResolve(t *testing.T) { - - registry := NewTestRegistry() - defer registry.Close() - - repo := registry.AddRepo("library/osbuild") - listDigest := repo.AddImage( - []Blob{NewDataBlobFromBase64(rootLayer)}, - []string{"amd64", "ppc64le"}, - "cool container", - time.Time{}) - - ref := registry.GetRef("library/osbuild") - client, err := container.NewClient(ref) - - assert.NoError(t, err) - assert.NotNil(t, client) - - client.SkipTLSVerify() - - ctx := context.Background() - - client.SetArchitectureChoice("amd64") - spec, err := client.Resolve(ctx, "") - - assert.NoError(t, err) - assert.Equal(t, container.Spec{ - Source: ref, - Digest: "sha256:f29b6cd42a94a574583439addcd6694e6224f0e4b32044c9e3aee4c4856c2a50", - ImageID: "sha256:c2ecf25cf190e76b12b07436ad5140d4ba53d8a136d498705e57a006837a720f", - TLSVerify: client.GetTLSVerify(), - LocalName: client.Target.String(), - ListDigest: listDigest, - }, spec) - - client.SetArchitectureChoice("ppc64le") - spec, err = client.Resolve(ctx, "") - - assert.NoError(t, err) - assert.Equal(t, container.Spec{ - Source: ref, - Digest: "sha256:d49eebefb6c7ce5505594bef652bd4adc36f413861bd44209d9b9486310b1264", - ImageID: "sha256:d2ab8fea7f08a22f03b30c13c6ea443121f25e87202a7496e93736efa6fe345a", - TLSVerify: client.GetTLSVerify(), - LocalName: client.Target.String(), - ListDigest: listDigest, - }, spec) - - // don't have that architecture - client.SetArchitectureChoice("s390x") - _, err = client.Resolve(ctx, "") - - assert.Error(t, err) -} - -func TestClientAuthFilePath(t *testing.T) { - - client, err := container.NewClient("quay.io/osbuild/osbuild") - assert.NoError(t, err) - - authFilePath := client.GetAuthFilePath() - assert.NotEmpty(t, authFilePath) - assert.Equal(t, authFilePath, container.GetDefaultAuthFile()) - - // make sure the file is accessible - _, err = os.ReadFile(authFilePath) - assert.True(t, err == nil || os.IsNotExist(err)) - - t.Run("XDG_RUNTIME_DIR", func(t *testing.T) { - runtimeDir := os.Getenv("XDG_RUNTIME_DIR") - - if runtimeDir == "" { - t.Skip("XDG_RUNTIME_DIR not set, skipping test") - return - } - - t.Cleanup(func() { - os.Setenv("XDG_RUNTIME_DIR", runtimeDir) - }) - - os.Unsetenv("XDG_RUNTIME_DIR") - - authFilePath := container.GetDefaultAuthFile() - assert.NotEmpty(t, authFilePath) - _, err = os.ReadFile(authFilePath) - assert.True(t, err == nil || os.IsNotExist(err)) - }) - -} diff --git a/internal/container/container_test.go b/internal/container/container_test.go deleted file mode 100644 index 52ce86504..000000000 --- a/internal/container/container_test.go +++ /dev/null @@ -1,385 +0,0 @@ -package container_test - -import ( - "bytes" - "encoding/base64" - "encoding/json" - "fmt" - "io" - "net/http" - "net/http/httptest" - "os" - "strings" - "time" - - "github.com/opencontainers/go-digest" - - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - - "github.com/containers/image/v5/docker/reference" - "github.com/containers/image/v5/manifest" -) - -const rootLayer = `H4sIAAAJbogA/+SWUYqDMBCG53lP4V5g9x8dzRX2Bvtc0VIhEIhKe/wSKxgU6ktjC/O9hMzAQDL8 -/8yltdb9DLeB0gEGKhHCg/UJsBAL54zKFBAC54ZzyrCUSMfYDydPgHfu6R/s5VePilOfzF/of/bv -vG2+lqhyFNGPddP53yjyegCBKcuNROZ77AmBoP+CmbIyqpEM5fqf+3/ubJtsCuz7P1b+L1Du/4f5 -v+vrsVPu/Vq9P3ANk//d+x/MZv8TKNf/Qfqf9v9v5fLXK3/lKEc5ypm4AwAA//8DAE6E6nIAEgAA -` - -// The following code implements a toy container registry to test with - -// Blob interface -type Blob interface { - GetSize() int64 - GetMediaType() string - GetDigest() digest.Digest - - Reader() io.Reader -} - -// dataBlob // -type dataBlob struct { - Data []byte - MediaType string -} - -func NewDataBlobFromBase64(text string) dataBlob { - data, err := base64.StdEncoding.DecodeString(text) - - if err != nil { - panic("decoding of text failed") - } - - return dataBlob{ - Data: data, - } -} - -// Blob interface implementation -func (b dataBlob) GetSize() int64 { - return int64(len(b.Data)) -} - -func (b dataBlob) GetMediaType() string { - if b.MediaType != "" { - return b.MediaType - } - - return manifest.DockerV2Schema2LayerMediaType -} - -func (b dataBlob) GetDigest() digest.Digest { - return digest.FromBytes(b.Data) -} - -func (b dataBlob) Reader() io.Reader { - return bytes.NewReader(b.Data) -} - -func MakeDescriptorForBlob(b Blob) manifest.Schema2Descriptor { - return manifest.Schema2Descriptor{ - MediaType: b.GetMediaType(), - Size: b.GetSize(), - Digest: b.GetDigest(), - } -} - -// Repo // -type Repo struct { - blobs map[string]Blob - manifests map[string]*manifest.Schema2 - images map[string]*manifest.Schema2List - tags map[string]string -} - -func NewRepo() *Repo { - return &Repo{ - blobs: make(map[string]Blob), - manifests: make(map[string]*manifest.Schema2), - tags: make(map[string]string), - images: make(map[string]*manifest.Schema2List), - } -} - -func (r *Repo) AddBlob(b Blob) manifest.Schema2Descriptor { - desc := MakeDescriptorForBlob(b) - r.blobs[desc.Digest.String()] = b - return desc -} - -func (r *Repo) AddObject(v interface{}, mediaType string) manifest.Schema2Descriptor { - data, err := json.MarshalIndent(v, "", " ") - if err != nil { - panic("could not marshal image object") - } - - blob := dataBlob{ - Data: data, - MediaType: mediaType, - } - - return r.AddBlob(blob) -} - -func (r *Repo) AddManifest(mf *manifest.Schema2) manifest.Schema2Descriptor { - desc := r.AddObject(mf, mf.MediaType) - - r.manifests[desc.Digest.String()] = mf - - return desc -} - -func (r *Repo) AddImage(layers []Blob, arches []string, comment string, ctime time.Time) string { - - blobs := make([]manifest.Schema2Descriptor, len(layers)) - - for i, layer := range layers { - blobs[i] = r.AddBlob(layer) - } - - manifests := make([]manifest.Schema2ManifestDescriptor, len(arches)) - - for i, arch := range arches { - img := manifest.Schema2V1Image{ - Architecture: arch, - OS: "linux", - Author: "osbuild", - Comment: comment, - Created: ctime, - } - - // Add the config object - config := r.AddObject(img, manifest.DockerV2Schema2ConfigMediaType) - - // make and add the manifest object - schema := manifest.Schema2FromComponents(config, blobs) - mf := r.AddManifest(schema) - - desc := manifest.Schema2ManifestDescriptor{ - Schema2Descriptor: mf, - Platform: manifest.Schema2PlatformSpec{ - Architecture: arch, - OS: "linux", - }, - } - - manifests[i] = desc - } - - list := manifest.Schema2ListFromComponents(manifests) - desc := r.AddObject(list, list.MediaType) - checksum := desc.Digest.String() - - r.images[checksum] = list - r.tags["latest"] = checksum - - return checksum -} - -func (r *Repo) AddTag(checksum, tag string) { - - if _, ok := r.images[checksum]; !ok { - panic("cannot tag: image not found: " + checksum) - } - - r.tags[tag] = checksum -} - -func WriteBlob(blob Blob, w http.ResponseWriter) { - w.Header().Add("Content-Type", blob.GetMediaType()) - w.Header().Add("Content-Length", fmt.Sprintf("%d", blob.GetSize())) - w.Header().Add("Docker-Content-Digest", blob.GetDigest().String()) - w.WriteHeader(http.StatusOK) - - reader := blob.Reader() - - _, err := io.Copy(w, reader) - if err != nil { - fmt.Fprintf(os.Stderr, "error writing blob: %v", err) - } -} - -func BlobIsManifest(blob Blob) bool { - mt := blob.GetMediaType() - return mt == manifest.DockerV2Schema2MediaType || mt == manifest.DockerV2ListMediaType -} - -func (r *Repo) ServeManifest(ref string, w http.ResponseWriter, req *http.Request) { - if checksum, ok := r.tags[ref]; ok { - ref = checksum - } - - blob, ok := r.blobs[ref] - if !ok || !BlobIsManifest(blob) { - fmt.Fprintf(os.Stderr, "manifest %s not found", ref) - http.NotFound(w, req) - return - } - - WriteBlob(blob, w) -} - -func (r *Repo) ServeBlob(ref string, w http.ResponseWriter, req *http.Request) { - - blob, ok := r.blobs[ref] - - if !ok { - fmt.Fprintf(os.Stderr, "blob %s not found", ref) - http.NotFound(w, req) - return - } - - WriteBlob(blob, w) -} - -// Registry // - -type Registry struct { - server *httptest.Server - repos map[string]*Repo -} - -func (reg *Registry) ServeHTTP(w http.ResponseWriter, req *http.Request) { - - parts := strings.SplitN(req.URL.Path, "?", 1) - paths := strings.Split(strings.Trim(parts[0], "/"), "/") - - // Possbile routes - // [1] version-check: /v2/ - // [2] blobs: /v2//blobs/ - // [3] manifest: /v2//manifests/ - // - // we need at least 4 path components and path has to start with "/v2" - - if len(paths) < 1 || paths[0] != "v2" { - http.NotFound(w, req) - return - } - - // [1] version check - if len(paths) == 1 { - w.WriteHeader(200) - return - } else if len(paths) < 4 { - http.NotFound(w, req) - return - } - - // we asserted that we have at least 4 path components - ref := paths[len(paths)-1] - cmd := paths[len(paths)-2] - - repoName := strings.Join(paths[1:len(paths)-2], "/") - - repo, ok := reg.repos[repoName] - if !ok { - fmt.Fprintf(os.Stderr, "repo %s not found", repoName) - http.NotFound(w, req) - return - } - - if cmd == "manifests" { - repo.ServeManifest(ref, w, req) - } else if cmd == "blobs" { - repo.ServeBlob(ref, w, req) - } else { - http.NotFound(w, req) - } -} - -func NewTestRegistry() *Registry { - - reg := &Registry{ - repos: make(map[string]*Repo), - } - reg.server = httptest.NewTLSServer(reg) - - return reg -} - -func (reg *Registry) AddRepo(name string) *Repo { - repo := NewRepo() - reg.repos[name] = repo - return repo -} - -func (reg *Registry) GetRef(repo string) string { - return fmt.Sprintf("%s/%s", reg.server.Listener.Addr().String(), repo) -} - -func (reg *Registry) Resolve(target, arch string) (container.Spec, error) { - - ref, err := reference.ParseNormalizedNamed(target) - if err != nil { - return container.Spec{}, fmt.Errorf("failed to parse '%s': %w", target, err) - } - - domain := reference.Domain(ref) - - tag := "latest" - var checksum string - - if tagged, ok := ref.(reference.NamedTagged); ok { - tag = tagged.Tag() - } - - if digested, ok := ref.(reference.Digested); ok { - checksum = string(digested.Digest()) - } - - if domain != reg.server.Listener.Addr().String() { - return container.Spec{}, fmt.Errorf("unknown domain") - } - - ref = reference.TrimNamed(ref) - path := reference.Path(ref) - - repo, ok := reg.repos[path] - if !ok { - return container.Spec{}, fmt.Errorf("unknown repo") - } - - if checksum == "" { - checksum, ok = repo.tags[tag] - if !ok { - return container.Spec{}, fmt.Errorf("unknown tag") - } - } - - lst, ok := repo.images[checksum] - listDigest := checksum - - if ok { - checksum = "" - - for _, m := range lst.Manifests { - if m.Platform.Architecture == arch { - checksum = m.Digest.String() - break - } - } - - if checksum == "" { - return container.Spec{}, fmt.Errorf("unsupported architecture") - } - } - - mf, ok := repo.manifests[checksum] - if !ok { - return container.Spec{}, fmt.Errorf("unknown digest") - } - - return container.Spec{ - Source: ref.String(), - Digest: checksum, - ImageID: mf.ConfigDescriptor.Digest.String(), - LocalName: target, - TLSVerify: common.ToPtr(false), - ListDigest: listDigest, - }, nil -} - -func (reg *Registry) Close() { - reg.server.Close() -} diff --git a/internal/container/resolver_test.go b/internal/container/resolver_test.go deleted file mode 100644 index b6e40d37c..000000000 --- a/internal/container/resolver_test.go +++ /dev/null @@ -1,85 +0,0 @@ -package container_test - -import ( - "fmt" - "sort" - "testing" - "time" - - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" -) - -type lessCompare func(i, j int) bool - -func makeSpecSorter(specs []container.Spec) lessCompare { - return func(i, j int) bool { - return specs[i].Digest < specs[j].Digest - } -} - -func TestResolver(t *testing.T) { - - registry := NewTestRegistry() - defer registry.Close() - - repo := registry.AddRepo("library/osbuild") - ref := registry.GetRef("library/osbuild") - - refs := make([]string, 10) - for i := 0; i < len(refs); i++ { - checksum := repo.AddImage( - []Blob{NewDataBlobFromBase64(rootLayer)}, - []string{"amd64", "ppc64le"}, - fmt.Sprintf("image %d", i), - time.Time{}) - - tag := fmt.Sprintf("%d", i) - repo.AddTag(checksum, tag) - refs[i] = fmt.Sprintf("%s:%s", ref, tag) - } - - resolver := container.NewResolver("amd64") - - for _, r := range refs { - resolver.Add(container.SourceSpec{r, "", common.ToPtr(false)}) - } - - have, err := resolver.Finish() - assert.NoError(t, err) - assert.NotNil(t, have) - - assert.Len(t, have, len(refs)) - - want := make([]container.Spec, len(refs)) - for i, r := range refs { - spec, err := registry.Resolve(r, "amd64") - assert.NoError(t, err) - want[i] = spec - } - - sort.Slice(have, makeSpecSorter(have)) - sort.Slice(want, makeSpecSorter(want)) - - assert.ElementsMatch(t, have, want) -} - -func TestResolverFail(t *testing.T) { - resolver := container.NewResolver("amd64") - - resolver.Add(container.SourceSpec{"invalid-reference@${IMAGE_DIGEST}", "", common.ToPtr(false)}) - - specs, err := resolver.Finish() - assert.Error(t, err) - assert.Len(t, specs, 0) - - registry := NewTestRegistry() - defer registry.Close() - - resolver.Add(container.SourceSpec{registry.GetRef("repo"), "", common.ToPtr(false)}) - specs, err = resolver.Finish() - assert.Error(t, err) - assert.Len(t, specs, 0) -} diff --git a/internal/crypt/crypt_test.go b/internal/crypt/crypt_test.go deleted file mode 100644 index 4665b008c..000000000 --- a/internal/crypt/crypt_test.go +++ /dev/null @@ -1,64 +0,0 @@ -//go:build !darwin - -package crypt - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func Test_crypt_PasswordIsCrypted(t *testing.T) { - - tests := []struct { - name string - password string - want bool - }{ - { - name: "bcrypt", - password: "$2b$04$123465789012345678901uac5A8egfBuZVHMrDZsQzR96IqNBivCy", - want: true, - }, { - name: "sha256", - password: "$5$1234567890123456$v.2bOKKLlpmUSKn0rxJmgnh.e3wOKivAVNZmNrOsoA3", - want: true, - }, { - name: "sha512", - password: "$6$1234567890123456$d.pgKQFaiD8bRiExg5NesbGR/3u51YvxeYaQXPzx4C6oSYREw8VoReiuYZjx0V9OhGVTZFqhc6emAxT1RC5BV.", - want: true, - }, { - name: "scrypt", - password: "$7$123456789012345", //not actual hash output from scrypt - want: false, - }, { - name: "plain", - password: "password", - want: false, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - if got := PasswordIsCrypted(test.password); got != test.want { - t.Errorf("PasswordIsCrypted() =%v, want %v", got, test.want) - } - }) - } -} - -func TestCryptSHA512(t *testing.T) { - retPassFirst, err := CryptSHA512("testPass") - assert.NoError(t, err) - retPassSecond, _ := CryptSHA512("testPass") - expectedPassStart := "$6$" - assert.Equal(t, expectedPassStart, retPassFirst[0:3]) - assert.NotEqual(t, retPassFirst, retPassSecond) -} - -func TestGenSalt(t *testing.T) { - length := 10 - retSaltFirst, err := genSalt(length) - assert.NoError(t, err) - retSaltSecond, _ := genSalt(length) - assert.NotEqual(t, retSaltFirst, retSaltSecond) -} diff --git a/internal/disk/disk_test.go b/internal/disk/disk_test.go deleted file mode 100644 index 77410ab84..000000000 --- a/internal/disk/disk_test.go +++ /dev/null @@ -1,1088 +0,0 @@ -package disk - -import ( - "fmt" - "math/rand" - "strings" - "testing" - - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/stretchr/testify/assert" -) - -const ( - KiB = 1024 - MiB = 1024 * KiB - GiB = 1024 * MiB -) - -func TestDisk_AlignUp(t *testing.T) { - - pt := PartitionTable{} - firstAligned := DefaultGrainBytes - - tests := []struct { - size uint64 - want uint64 - }{ - {0, 0}, - {1, firstAligned}, - {firstAligned - 1, firstAligned}, - {firstAligned, firstAligned}, // grain is already aligned => no change - {firstAligned / 2, firstAligned}, - {firstAligned + 1, firstAligned * 2}, - } - - for _, tt := range tests { - got := pt.AlignUp(tt.size) - assert.Equal(t, tt.want, got, "Expected %d, got %d", tt.want, got) - } -} - -func TestDisk_DynamicallyResizePartitionTable(t *testing.T) { - mountpoints := []blueprint.FilesystemCustomization{ - { - MinSize: 2 * GiB, - Mountpoint: "/usr", - }, - } - pt := PartitionTable{ - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Type: "gpt", - Partitions: []Partition{ - { - Size: 2048, - Bootable: true, - Type: BIOSBootPartitionGUID, - UUID: BIOSBootPartitionUUID, - }, - { - Type: FilesystemDataGUID, - UUID: RootPartitionUUID, - Payload: &Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - }, - } - var expectedSize uint64 = 2 * GiB - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(rand.NewSource(0)) - newpt, err := NewPartitionTable(&pt, mountpoints, 1024, false, nil, rng) - assert.NoError(t, err) - assert.GreaterOrEqual(t, newpt.Size, expectedSize) -} - -var testPartitionTables = map[string]PartitionTable{ - "plain": { - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Type: "gpt", - Partitions: []Partition{ - { - Size: 1 * MiB, - Bootable: true, - Type: BIOSBootPartitionGUID, - UUID: BIOSBootPartitionUUID, - }, - { - Size: 200 * MiB, - Type: EFISystemPartitionGUID, - UUID: EFISystemPartitionUUID, - Payload: &Filesystem{ - Type: "vfat", - UUID: EFIFilesystemUUID, - Mountpoint: "/boot/efi", - Label: "EFI-SYSTEM", - FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", - FSTabFreq: 0, - FSTabPassNo: 2, - }, - }, - { - Size: 500 * MiB, - Type: FilesystemDataGUID, - UUID: FilesystemDataUUID, - Payload: &Filesystem{ - Type: "xfs", - Mountpoint: "/boot", - Label: "boot", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - { - Type: FilesystemDataGUID, - UUID: RootPartitionUUID, - Payload: &Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - }, - }, - - "plain-noboot": { - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Type: "gpt", - Partitions: []Partition{ - { - Size: 1 * MiB, - Bootable: true, - Type: BIOSBootPartitionGUID, - UUID: BIOSBootPartitionUUID, - }, - { - Size: 200 * MiB, - Type: EFISystemPartitionGUID, - UUID: EFISystemPartitionUUID, - Payload: &Filesystem{ - Type: "vfat", - UUID: EFIFilesystemUUID, - Mountpoint: "/boot/efi", - Label: "EFI-SYSTEM", - FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", - FSTabFreq: 0, - FSTabPassNo: 2, - }, - }, - { - Type: FilesystemDataGUID, - UUID: RootPartitionUUID, - Payload: &Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - }, - }, - - "luks": { - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Type: "gpt", - Partitions: []Partition{ - { - Size: 1 * MiB, - Bootable: true, - Type: BIOSBootPartitionGUID, - UUID: BIOSBootPartitionUUID, - }, - { - Size: 200 * MiB, - Type: EFISystemPartitionGUID, - UUID: EFISystemPartitionUUID, - Payload: &Filesystem{ - Type: "vfat", - UUID: EFIFilesystemUUID, - Mountpoint: "/boot/efi", - Label: "EFI-SYSTEM", - FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", - FSTabFreq: 0, - FSTabPassNo: 2, - }, - }, - { - Size: 500 * MiB, - Type: FilesystemDataGUID, - UUID: FilesystemDataUUID, - Payload: &Filesystem{ - Type: "xfs", - Mountpoint: "/boot", - Label: "boot", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - { - Type: FilesystemDataGUID, - UUID: RootPartitionUUID, - Payload: &LUKSContainer{ - UUID: "", - Label: "crypt_root", - Payload: &Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - }, - }, - }, - "luks+lvm": { - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Type: "gpt", - Partitions: []Partition{ - { - Size: 1 * MiB, - Bootable: true, - Type: BIOSBootPartitionGUID, - UUID: BIOSBootPartitionUUID, - }, - { - Size: 200 * MiB, - Type: EFISystemPartitionGUID, - UUID: EFISystemPartitionUUID, - Payload: &Filesystem{ - Type: "vfat", - UUID: EFIFilesystemUUID, - Mountpoint: "/boot/efi", - Label: "EFI-SYSTEM", - FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", - FSTabFreq: 0, - FSTabPassNo: 2, - }, - }, - { - Size: 500 * MiB, - Type: FilesystemDataGUID, - UUID: FilesystemDataUUID, - Payload: &Filesystem{ - Type: "xfs", - Mountpoint: "/boot", - Label: "boot", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - { - Type: FilesystemDataGUID, - UUID: RootPartitionUUID, - Size: 5 * GiB, - Payload: &LUKSContainer{ - UUID: "", - Payload: &LVMVolumeGroup{ - Name: "", - Description: "", - LogicalVolumes: []LVMLogicalVolume{ - { - Size: 2 * GiB, - Payload: &Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - { - Size: 2 * GiB, - Payload: &Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/home", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - }, - }, - }, - }, - }, - }, - "btrfs": { - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Type: "gpt", - Partitions: []Partition{ - { - Size: 1 * MiB, - Bootable: true, - Type: BIOSBootPartitionGUID, - UUID: BIOSBootPartitionUUID, - }, - { - Size: 200 * MiB, - Type: EFISystemPartitionGUID, - UUID: EFISystemPartitionUUID, - Payload: &Filesystem{ - Type: "vfat", - UUID: EFIFilesystemUUID, - Mountpoint: "/boot/efi", - Label: "EFI-SYSTEM", - FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", - FSTabFreq: 0, - FSTabPassNo: 2, - }, - }, - { - Size: 500 * MiB, - Type: FilesystemDataGUID, - UUID: FilesystemDataUUID, - Payload: &Filesystem{ - Type: "xfs", - Mountpoint: "/boot", - Label: "boot", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - { - Type: FilesystemDataGUID, - UUID: RootPartitionUUID, - Size: 10 * GiB, - Payload: &Btrfs{ - UUID: "", - Label: "", - Mountpoint: "", - Subvolumes: []BtrfsSubvolume{ - { - Size: 0, - Mountpoint: "/", - GroupID: 0, - }, - { - Size: 5 * GiB, - Mountpoint: "/var", - GroupID: 0, - }, - }, - }, - }, - }, - }, -} - -var testBlueprints = map[string][]blueprint.FilesystemCustomization{ - "bp1": { - { - Mountpoint: "/", - MinSize: 10 * GiB, - }, - { - Mountpoint: "/home", - MinSize: 20 * GiB, - }, - { - Mountpoint: "/opt", - MinSize: 7 * GiB, - }, - }, - "bp2": { - { - Mountpoint: "/opt", - MinSize: 7 * GiB, - }, - }, - "small": { - { - Mountpoint: "/opt", - MinSize: 20 * MiB, - }, - { - Mountpoint: "/home", - MinSize: 500 * MiB, - }, - }, - "empty": nil, -} - -func TestDisk_ForEachEntity(t *testing.T) { - - count := 0 - - plain := testPartitionTables["plain"] - err := plain.ForEachEntity(func(e Entity, path []Entity) error { - assert.NotNil(t, e) - assert.NotNil(t, path) - - count += 1 - return nil - }) - - assert.NoError(t, err) - - // PartitionTable, 4 partitions, 3 filesystems -> 8 entities - assert.Equal(t, 8, count) -} - -func TestCreatePartitionTable(t *testing.T) { - assert := assert.New(t) - - sizeCheckCB := func(mnt Mountable, path []Entity) error { - if strings.HasPrefix(mnt.GetMountpoint(), "/boot") { - // /boot and subdirectories is exempt from this rule - return nil - } - // go up the path and check every sizeable - for idx, ent := range path { - if sz, ok := ent.(Sizeable); ok { - size := sz.GetSize() - if size < 1*GiB { - return fmt.Errorf("entity %d in the path from %s is smaller than the minimum 1 GiB (%d)", idx, mnt.GetMountpoint(), size) - } - } - } - return nil - } - - sumSizes := func(bp []blueprint.FilesystemCustomization) (sum uint64) { - for _, mnt := range bp { - sum += mnt.MinSize - } - return sum - } - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(rand.NewSource(13)) - for ptName := range testPartitionTables { - pt := testPartitionTables[ptName] - for bpName, bp := range testBlueprints { - mpt, err := NewPartitionTable(&pt, bp, uint64(13*MiB), false, nil, rng) - assert.NoError(err, "Partition table generation failed: PT %q BP %q (%s)", ptName, bpName, err) - assert.NotNil(mpt, "Partition table generation failed: PT %q BP %q (nil partition table)", ptName, bpName) - assert.Greater(mpt.GetSize(), sumSizes(bp)) - - assert.NotNil(mpt.Type, "Partition table generation failed: PT %q BP %q (nil partition table type)", ptName, bpName) - - mnt := pt.FindMountable("/") - assert.NotNil(mnt, "PT %q BP %q: failed to find root mountable", ptName, bpName) - - assert.NoError(mpt.ForEachMountable(sizeCheckCB)) - } - } -} - -func TestCreatePartitionTableLVMify(t *testing.T) { - assert := assert.New(t) - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(rand.NewSource(13)) - for bpName, tbp := range testBlueprints { - for ptName := range testPartitionTables { - pt := testPartitionTables[ptName] - - if tbp != nil && (ptName == "btrfs" || ptName == "luks") { - assert.Panics(func() { - _, _ = NewPartitionTable(&pt, tbp, uint64(13*MiB), true, nil, rng) - }, fmt.Sprintf("PT %q BP %q: should panic", ptName, bpName)) - continue - } - - mpt, err := NewPartitionTable(&pt, tbp, uint64(13*MiB), true, nil, rng) - assert.NoError(err, "PT %q BP %q: Partition table generation failed: (%s)", ptName, bpName, err) - - rootPath := entityPath(mpt, "/") - if rootPath == nil { - panic(fmt.Sprintf("PT %q BP %q: no root mountpoint", ptName, bpName)) - } - - bootPath := entityPath(mpt, "/boot") - if tbp != nil && bootPath == nil { - panic(fmt.Sprintf("PT %q BP %q: no boot mountpoint", ptName, bpName)) - } - - if tbp != nil { - parent := rootPath[1] - _, ok := parent.(*LVMLogicalVolume) - assert.True(ok, "PT %q BP %q: root's parent (%q) is not an LVM logical volume", ptName, bpName, parent) - } - } - } -} - -func TestMinimumSizes(t *testing.T) { - assert := assert.New(t) - - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(rand.NewSource(13)) - pt := testPartitionTables["plain"] - - type testCase struct { - Blueprint []blueprint.FilesystemCustomization - ExpectedMinSizes map[string]uint64 - } - - testCases := []testCase{ - { // specify small /usr -> / and /usr get default size - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/usr", - MinSize: 1 * MiB, - }, - }, - ExpectedMinSizes: map[string]uint64{ - "/usr": 2 * GiB, - "/": 1 * GiB, - }, - }, - { // specify small / and /usr -> / and /usr get default size - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/", - MinSize: 1 * MiB, - }, - { - Mountpoint: "/usr", - MinSize: 1 * KiB, - }, - }, - ExpectedMinSizes: map[string]uint64{ - "/usr": 2 * GiB, - "/": 1 * GiB, - }, - }, - { // big /usr -> / gets default size - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/usr", - MinSize: 10 * GiB, - }, - }, - ExpectedMinSizes: map[string]uint64{ - "/usr": 10 * GiB, - "/": 1 * GiB, - }, - }, - { - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/", - MinSize: 10 * GiB, - }, - { - Mountpoint: "/home", - MinSize: 1 * MiB, - }, - }, - ExpectedMinSizes: map[string]uint64{ - "/": 10 * GiB, - "/home": 1 * GiB, - }, - }, - { // no separate /usr and no size for / -> / gets sum of default sizes for / and /usr - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/opt", - MinSize: 10 * GiB, - }, - }, - ExpectedMinSizes: map[string]uint64{ - "/opt": 10 * GiB, - "/": 3 * GiB, - }, - }, - } - - for idx, tc := range testCases { - { // without LVM - mpt, err := NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), false, nil, rng) - assert.NoError(err) - for mnt, minSize := range tc.ExpectedMinSizes { - path := entityPath(mpt, mnt) - assert.NotNil(path, "[%d] mountpoint %q not found", idx, mnt) - parent := path[1] - part, ok := parent.(*Partition) - assert.True(ok, "%q parent (%v) is not a partition", mnt, parent) - assert.GreaterOrEqual(part.GetSize(), minSize, - "[%d] %q size %d should be greater or equal to %d", idx, mnt, part.GetSize(), minSize) - } - } - - { // with LVM - mpt, err := NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), true, nil, rng) - assert.NoError(err) - for mnt, minSize := range tc.ExpectedMinSizes { - path := entityPath(mpt, mnt) - assert.NotNil(path, "[%d] mountpoint %q not found", idx, mnt) - parent := path[1] - part, ok := parent.(*LVMLogicalVolume) - assert.True(ok, "[%d] %q parent (%v) is not an LVM logical volume", idx, mnt, parent) - assert.GreaterOrEqual(part.GetSize(), minSize, - "[%d] %q size %d should be greater or equal to %d", idx, mnt, part.GetSize(), minSize) - } - } - } -} - -func TestLVMExtentAlignment(t *testing.T) { - assert := assert.New(t) - - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(rand.NewSource(13)) - pt := testPartitionTables["plain"] - - type testCase struct { - Blueprint []blueprint.FilesystemCustomization - ExpectedSizes map[string]uint64 - } - - testCases := []testCase{ - { - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/var", - MinSize: 1*GiB + 1, - }, - }, - ExpectedSizes: map[string]uint64{ - "/var": 1*GiB + LVMDefaultExtentSize, - }, - }, - { - // lots of mount points in /var - // https://bugzilla.redhat.com/show_bug.cgi?id=2141738 - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/", - MinSize: 32000000000, - }, - { - Mountpoint: "/var", - MinSize: 4096000000, - }, - { - Mountpoint: "/var/log", - MinSize: 4096000000, - }, - }, - ExpectedSizes: map[string]uint64{ - "/": 32002539520, - "/var": 3908 * MiB, - "/var/log": 3908 * MiB, - }, - }, - { - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/", - MinSize: 32 * GiB, - }, - { - Mountpoint: "/var", - MinSize: 4 * GiB, - }, - { - Mountpoint: "/var/log", - MinSize: 4 * GiB, - }, - }, - ExpectedSizes: map[string]uint64{ - "/": 32 * GiB, - "/var": 4 * GiB, - "/var/log": 4 * GiB, - }, - }, - } - - for idx, tc := range testCases { - mpt, err := NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), true, nil, rng) - assert.NoError(err) - for mnt, expSize := range tc.ExpectedSizes { - path := entityPath(mpt, mnt) - assert.NotNil(path, "[%d] mountpoint %q not found", idx, mnt) - parent := path[1] - part, ok := parent.(*LVMLogicalVolume) - assert.True(ok, "[%d] %q parent (%v) is not an LVM logical volume", idx, mnt, parent) - assert.Equal(part.GetSize(), expSize, - "[%d] %q size %d should be equal to %d", idx, mnt, part.GetSize(), expSize) - } - } -} - -func TestNewBootWithSizeLVMify(t *testing.T) { - pt := testPartitionTables["plain-noboot"] - assert := assert.New(t) - - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(rand.NewSource(13)) - - custom := []blueprint.FilesystemCustomization{ - { - Mountpoint: "/boot", - MinSize: 700 * MiB, - }, - } - - mpt, err := NewPartitionTable(&pt, custom, uint64(3*GiB), true, nil, rng) - assert.NoError(err) - - for idx, c := range custom { - mnt, minSize := c.Mountpoint, c.MinSize - path := entityPath(mpt, mnt) - assert.NotNil(path, "[%d] mountpoint %q not found", idx, mnt) - parent := path[1] - part, ok := parent.(*Partition) - assert.True(ok, "%q parent (%v) is not a partition", mnt, parent) - assert.GreaterOrEqual(part.GetSize(), minSize, - "[%d] %q size %d should be greater or equal to %d", idx, mnt, part.GetSize(), minSize) - } -} - -func collectEntities(pt *PartitionTable) []Entity { - entities := make([]Entity, 0) - collector := func(ent Entity, path []Entity) error { - entities = append(entities, ent) - return nil - } - _ = pt.ForEachEntity(collector) - return entities -} - -func TestClone(t *testing.T) { - for name := range testPartitionTables { - basePT := testPartitionTables[name] - baseEntities := collectEntities(&basePT) - - clonePT := basePT.Clone().(*PartitionTable) - cloneEntities := collectEntities(clonePT) - - for idx := range baseEntities { - for jdx := range cloneEntities { - if fmt.Sprintf("%p", baseEntities[idx]) == fmt.Sprintf("%p", cloneEntities[jdx]) { - t.Fatalf("found reference to same entity %#v in list of clones for partition table %q", baseEntities[idx], name) - } - } - } - } -} - -func TestFindDirectoryPartition(t *testing.T) { - assert := assert.New(t) - usr := Partition{ - Type: FilesystemDataGUID, - UUID: RootPartitionUUID, - Payload: &Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/usr", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - } - - { - pt := testPartitionTables["plain"] - assert.Equal("/", pt.findDirectoryEntityPath("/opt")[0].(Mountable).GetMountpoint()) - assert.Equal("/boot/efi", pt.findDirectoryEntityPath("/boot/efi/Linux")[0].(Mountable).GetMountpoint()) - assert.Equal("/boot", pt.findDirectoryEntityPath("/boot/loader")[0].(Mountable).GetMountpoint()) - assert.Equal("/boot", pt.findDirectoryEntityPath("/boot")[0].(Mountable).GetMountpoint()) - - ptMod := pt.Clone().(*PartitionTable) - ptMod.Partitions = append(ptMod.Partitions, usr) - assert.Equal("/", ptMod.findDirectoryEntityPath("/opt")[0].(Mountable).GetMountpoint()) - assert.Equal("/usr", ptMod.findDirectoryEntityPath("/usr")[0].(Mountable).GetMountpoint()) - assert.Equal("/usr", ptMod.findDirectoryEntityPath("/usr/bin")[0].(Mountable).GetMountpoint()) - - // invalid dir should return nil - assert.Nil(pt.findDirectoryEntityPath("invalid")) - } - - { - pt := testPartitionTables["plain-noboot"] - assert.Equal("/", pt.findDirectoryEntityPath("/opt")[0].(Mountable).GetMountpoint()) - assert.Equal("/", pt.findDirectoryEntityPath("/boot")[0].(Mountable).GetMountpoint()) - assert.Equal("/", pt.findDirectoryEntityPath("/boot/loader")[0].(Mountable).GetMountpoint()) - - ptMod := pt.Clone().(*PartitionTable) - ptMod.Partitions = append(ptMod.Partitions, usr) - assert.Equal("/", ptMod.findDirectoryEntityPath("/opt")[0].(Mountable).GetMountpoint()) - assert.Equal("/usr", ptMod.findDirectoryEntityPath("/usr")[0].(Mountable).GetMountpoint()) - assert.Equal("/usr", ptMod.findDirectoryEntityPath("/usr/bin")[0].(Mountable).GetMountpoint()) - - // invalid dir should return nil - assert.Nil(pt.findDirectoryEntityPath("invalid")) - } - - { - pt := testPartitionTables["luks"] - assert.Equal("/", pt.findDirectoryEntityPath("/opt")[0].(Mountable).GetMountpoint()) - assert.Equal("/boot", pt.findDirectoryEntityPath("/boot")[0].(Mountable).GetMountpoint()) - assert.Equal("/boot", pt.findDirectoryEntityPath("/boot/loader")[0].(Mountable).GetMountpoint()) - - ptMod := pt.Clone().(*PartitionTable) - ptMod.Partitions = append(ptMod.Partitions, usr) - assert.Equal("/", ptMod.findDirectoryEntityPath("/opt")[0].(Mountable).GetMountpoint()) - assert.Equal("/usr", ptMod.findDirectoryEntityPath("/usr")[0].(Mountable).GetMountpoint()) - assert.Equal("/usr", ptMod.findDirectoryEntityPath("/usr/bin")[0].(Mountable).GetMountpoint()) - - // invalid dir should return nil - assert.Nil(pt.findDirectoryEntityPath("invalid")) - } - - { - pt := testPartitionTables["luks+lvm"] - assert.Equal("/", pt.findDirectoryEntityPath("/opt")[0].(Mountable).GetMountpoint()) - assert.Equal("/boot", pt.findDirectoryEntityPath("/boot")[0].(Mountable).GetMountpoint()) - assert.Equal("/boot", pt.findDirectoryEntityPath("/boot/loader")[0].(Mountable).GetMountpoint()) - - ptMod := pt.Clone().(*PartitionTable) - ptMod.Partitions = append(ptMod.Partitions, usr) - assert.Equal("/", ptMod.findDirectoryEntityPath("/opt")[0].(Mountable).GetMountpoint()) - assert.Equal("/usr", ptMod.findDirectoryEntityPath("/usr")[0].(Mountable).GetMountpoint()) - assert.Equal("/usr", ptMod.findDirectoryEntityPath("/usr/bin")[0].(Mountable).GetMountpoint()) - - // invalid dir should return nil - assert.Nil(pt.findDirectoryEntityPath("invalid")) - } - - { - pt := testPartitionTables["btrfs"] - assert.Equal("/", pt.findDirectoryEntityPath("/opt")[0].(Mountable).GetMountpoint()) - assert.Equal("/boot", pt.findDirectoryEntityPath("/boot")[0].(Mountable).GetMountpoint()) - assert.Equal("/boot", pt.findDirectoryEntityPath("/boot/loader")[0].(Mountable).GetMountpoint()) - - ptMod := pt.Clone().(*PartitionTable) - ptMod.Partitions = append(ptMod.Partitions, usr) - assert.Equal("/", ptMod.findDirectoryEntityPath("/opt")[0].(Mountable).GetMountpoint()) - assert.Equal("/usr", ptMod.findDirectoryEntityPath("/usr")[0].(Mountable).GetMountpoint()) - assert.Equal("/usr", ptMod.findDirectoryEntityPath("/usr/bin")[0].(Mountable).GetMountpoint()) - - // invalid dir should return nil - assert.Nil(pt.findDirectoryEntityPath("invalid")) - } - - { - pt := PartitionTable{} // pt with no root should return nil - assert.Nil(pt.findDirectoryEntityPath("/var")) - } -} - -func TestEnsureDirectorySizes(t *testing.T) { - assert := assert.New(t) - - varSizes := map[string]uint64{ - "/var/lib": uint64(3 * GiB), - "/var/cache": uint64(2 * GiB), - "/var/log/journal": uint64(2 * GiB), - } - - varAndHomeSizes := map[string]uint64{ - "/var/lib": uint64(3 * GiB), - "/var/cache": uint64(2 * GiB), - "/var/log/journal": uint64(2 * GiB), - "/home/user/data": uint64(10 * GiB), - } - - { - pt := testPartitionTables["plain"] - pt = *pt.Clone().(*PartitionTable) // don't modify the original test data - - { - // make sure we have the correct volume - // guard against changes in the test pt - rootPart := pt.Partitions[3] - rootPayload := rootPart.Payload.(*Filesystem) - - assert.Equal("/", rootPayload.Mountpoint) - assert.Equal(uint64(0), rootPart.Size) - } - - { - // add requirements for /var subdirs that are > 5 GiB - pt.EnsureDirectorySizes(varSizes) - rootPart := pt.Partitions[3] - assert.Equal(uint64(7*GiB), rootPart.Size) - - // invalid - assert.Panics(func() { pt.EnsureDirectorySizes(map[string]uint64{"invalid": uint64(300)}) }) - } - } - - { - pt := testPartitionTables["luks+lvm"] - pt = *pt.Clone().(*PartitionTable) // don't modify the original test data - - { - // make sure we have the correct volume - // guard against changes in the test pt - rootPart := pt.Partitions[3] - rootLUKS := rootPart.Payload.(*LUKSContainer) - rootVG := rootLUKS.Payload.(*LVMVolumeGroup) - rootLV := rootVG.LogicalVolumes[0] - rootFS := rootLV.Payload.(*Filesystem) - homeLV := rootVG.LogicalVolumes[1] - homeFS := homeLV.Payload.(*Filesystem) - - assert.Equal(uint64(5*GiB), rootPart.Size) - assert.Equal("/", rootFS.Mountpoint) - assert.Equal(uint64(2*GiB), rootLV.Size) - assert.Equal("/home", homeFS.Mountpoint) - assert.Equal(uint64(2*GiB), homeLV.Size) - } - - { - // add requirements for /var subdirs that are > 5 GiB - pt.EnsureDirectorySizes(varAndHomeSizes) - rootPart := pt.Partitions[3] - rootLUKS := rootPart.Payload.(*LUKSContainer) - rootVG := rootLUKS.Payload.(*LVMVolumeGroup) - rootLV := rootVG.LogicalVolumes[0] - homeLV := rootVG.LogicalVolumes[1] - assert.Equal(uint64(17*GiB)+rootVG.MetadataSize(), rootPart.Size) - assert.Equal(uint64(7*GiB), rootLV.Size) - assert.Equal(uint64(10*GiB), homeLV.Size) - - // invalid - assert.Panics(func() { pt.EnsureDirectorySizes(map[string]uint64{"invalid": uint64(300)}) }) - } - } - - { - pt := testPartitionTables["btrfs"] - pt = *pt.Clone().(*PartitionTable) // don't modify the original test data - - { - // make sure we have the correct volume - // guard against changes in the test pt - rootPart := pt.Partitions[3] - rootPayload := rootPart.Payload.(*Btrfs) - assert.Equal("/", rootPayload.Subvolumes[0].Mountpoint) - assert.Equal(uint64(0), rootPayload.Subvolumes[0].Size) - assert.Equal("/var", rootPayload.Subvolumes[1].Mountpoint) - assert.Equal(uint64(5*GiB), rootPayload.Subvolumes[1].Size) - } - - { - // add requirements for /var subdirs that are > 5 GiB - pt.EnsureDirectorySizes(varSizes) - rootPart := pt.Partitions[3] - rootPayload := rootPart.Payload.(*Btrfs) - assert.Equal(uint64(7*GiB), rootPayload.Subvolumes[1].Size) - - // invalid - assert.Panics(func() { pt.EnsureDirectorySizes(map[string]uint64{"invalid": uint64(300)}) }) - } - } - -} - -func TestMinimumSizesWithRequiredSizes(t *testing.T) { - assert := assert.New(t) - - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(rand.NewSource(13)) - pt := testPartitionTables["plain"] - - type testCase struct { - Blueprint []blueprint.FilesystemCustomization - ExpectedMinSizes map[string]uint64 - } - - testCases := []testCase{ - { // specify small /usr -> / and /usr get default size - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/usr", - MinSize: 1 * MiB, - }, - }, - ExpectedMinSizes: map[string]uint64{ - "/usr": 3 * GiB, - "/": 1 * GiB, - }, - }, - { // specify small / and /usr -> / and /usr get default size - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/", - MinSize: 1 * MiB, - }, - { - Mountpoint: "/usr", - MinSize: 1 * KiB, - }, - }, - ExpectedMinSizes: map[string]uint64{ - "/usr": 3 * GiB, - "/": 1 * GiB, - }, - }, - { // big /usr -> / gets default size - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/usr", - MinSize: 10 * GiB, - }, - }, - ExpectedMinSizes: map[string]uint64{ - "/usr": 10 * GiB, - "/": 1 * GiB, - }, - }, - { - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/", - MinSize: 10 * GiB, - }, - { - Mountpoint: "/home", - MinSize: 1 * MiB, - }, - }, - ExpectedMinSizes: map[string]uint64{ - "/": 10 * GiB, - "/home": 1 * GiB, - }, - }, - { // no separate /usr and no size for / -> / gets sum of default sizes for / and /usr - Blueprint: []blueprint.FilesystemCustomization{ - { - Mountpoint: "/opt", - MinSize: 10 * GiB, - }, - }, - ExpectedMinSizes: map[string]uint64{ - "/opt": 10 * GiB, - "/": 4 * GiB, - }, - }, - } - - for idx, tc := range testCases { - { // without LVM - mpt, err := NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), false, map[string]uint64{"/": 1 * GiB, "/usr": 3 * GiB}, rng) - assert.NoError(err) - for mnt, minSize := range tc.ExpectedMinSizes { - path := entityPath(mpt, mnt) - assert.NotNil(path, "[%d] mountpoint %q not found", idx, mnt) - parent := path[1] - part, ok := parent.(*Partition) - assert.True(ok, "%q parent (%v) is not a partition", mnt, parent) - assert.GreaterOrEqual(part.GetSize(), minSize, - "[%d] %q size %d should be greater or equal to %d", idx, mnt, part.GetSize(), minSize) - } - } - - { // with LVM - mpt, err := NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), true, map[string]uint64{"/": 1 * GiB, "/usr": 3 * GiB}, rng) - assert.NoError(err) - for mnt, minSize := range tc.ExpectedMinSizes { - path := entityPath(mpt, mnt) - assert.NotNil(path, "[%d] mountpoint %q not found", idx, mnt) - parent := path[1] - part, ok := parent.(*LVMLogicalVolume) - assert.True(ok, "[%d] %q parent (%v) is not an LVM logical volume", idx, mnt, parent) - assert.GreaterOrEqual(part.GetSize(), minSize, - "[%d] %q size %d should be greater or equal to %d", idx, mnt, part.GetSize(), minSize) - } - } - } -} diff --git a/internal/disk/lvm_test.go b/internal/disk/lvm_test.go deleted file mode 100644 index a2437a62d..000000000 --- a/internal/disk/lvm_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package disk - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestLVMVCreateMountpoint(t *testing.T) { - - assert := assert.New(t) - - vg := &LVMVolumeGroup{ - Name: "root", - Description: "root volume group", - } - - entity, err := vg.CreateMountpoint("/", 0) - assert.NoError(err) - rootlv := entity.(*LVMLogicalVolume) - assert.Equal("rootlv", rootlv.Name) - - _, err = vg.CreateMountpoint("/home_test", 0) - assert.NoError(err) - - entity, err = vg.CreateMountpoint("/home/test", 0) - assert.NoError(err) - - dedup := entity.(*LVMLogicalVolume) - assert.Equal("home_testlv00", dedup.Name) - - // Lets collide it - for i := 0; i < 98; i++ { - _, err = vg.CreateMountpoint("/home/test", 0) - assert.NoError(err) - } - - _, err = vg.CreateMountpoint("/home/test", 0) - assert.Error(err) -} diff --git a/internal/distro/distro_test.go b/internal/distro/distro_test.go deleted file mode 100644 index 50d6f58db..000000000 --- a/internal/distro/distro_test.go +++ /dev/null @@ -1,566 +0,0 @@ -package distro_test - -import ( - "crypto/sha256" - "encoding/json" - "fmt" - "strings" - "testing" - - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/distro_test_common" - "github.com/osbuild/osbuild-composer/internal/distroregistry" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestDistro_Manifest(t *testing.T) { - - distro_test_common.TestDistro_Manifest( - t, - "../../test/data/manifests/", - "*", - distroregistry.NewDefault(), - false, // This test case does not check for changes in the imageType package sets! - "", - "", - ) -} - -// Ensure that all package sets defined in the package set chains are defined for the image type -func TestImageType_PackageSetsChains(t *testing.T) { - distros := distroregistry.NewDefault() - for _, distroName := range distros.List() { - d := distros.GetDistro(distroName) - for _, archName := range d.ListArches() { - arch, err := d.GetArch(archName) - require.Nil(t, err) - for _, imageTypeName := range arch.ListImageTypes() { - t.Run(fmt.Sprintf("%s/%s/%s", distroName, archName, imageTypeName), func(t *testing.T) { - imageType, err := arch.GetImageType(imageTypeName) - require.Nil(t, err) - - // set up bare minimum args for image type - var customizations *blueprint.Customizations - if imageType.Name() == "edge-simplified-installer" { - customizations = &blueprint.Customizations{ - InstallationDevice: "/dev/null", - } - } - bp := blueprint.Blueprint{ - Customizations: customizations, - } - options := distro.ImageOptions{ - OSTree: &ostree.ImageOptions{ - URL: "https://example.com", // required by some image types - }, - } - manifest, _, err := imageType.Manifest(&bp, options, nil, 0) - require.NoError(t, err) - imagePkgSets := manifest.GetPackageSetChains() - for packageSetName := range imageType.PackageSetsChains() { - _, ok := imagePkgSets[packageSetName] - if !ok { - // in the new pipeline generation logic the name of the package - // set chains are taken from the pipelines and do not match the - // package set names. - // TODO: redefine package set chains to make this unneccesary - switch packageSetName { - case "packages": - _, ok = imagePkgSets["os"] - if !ok { - _, ok = imagePkgSets["ostree-tree"] - } - } - } - assert.Truef(t, ok, "package set %q defined in a package set chain is not present in the image package sets", packageSetName) - } - }) - } - } - } -} - -// Ensure all image types report the correct names for their pipelines. -// Each image type contains a list of build and payload pipelines. They are -// needed for knowing the names of pipelines from the static object without -// having access to a manifest, which we need when parsing metadata from build -// results. -func TestImageTypePipelineNames(t *testing.T) { - // types for parsing the opaque manifest with just the fields we care about - type rpmStageOptions struct { - GPGKeys []string `json:"gpgkeys"` - } - type stage struct { - Type string `json:"type"` - Options rpmStageOptions `json:"options"` - } - type pipeline struct { - Name string `json:"name"` - Stages []stage `json:"stages"` - } - type manifest struct { - Pipelines []pipeline `json:"pipelines"` - } - - assert := assert.New(t) - distros := distroregistry.NewDefault() - for _, distroName := range distros.List() { - d := distros.GetDistro(distroName) - for _, archName := range d.ListArches() { - arch, err := d.GetArch(archName) - assert.Nil(err) - for _, imageTypeName := range arch.ListImageTypes() { - t.Run(fmt.Sprintf("%s/%s/%s", distroName, archName, imageTypeName), func(t *testing.T) { - imageType, err := arch.GetImageType(imageTypeName) - assert.Nil(err) - - // set up bare minimum args for image type - var customizations *blueprint.Customizations - if imageType.Name() == "edge-simplified-installer" { - customizations = &blueprint.Customizations{ - InstallationDevice: "/dev/null", - } - } - bp := blueprint.Blueprint{ - Customizations: customizations, - } - options := distro.ImageOptions{} - // this repo's gpg keys should get included in the os - // pipeline's rpm stage - repos := []rpmmd.RepoConfig{ - { - Name: "payload", - BaseURLs: []string{"http://payload.example.com"}, - PackageSets: imageType.PayloadPackageSets(), - GPGKeys: []string{"payload-gpg-key"}, - CheckGPG: common.ToPtr(true), - }, - } - seed := int64(0) - - // Add ostree options for image types that require them - options.OSTree = &ostree.ImageOptions{ - URL: "https://example.com", - } - - // Pipelines that require package sets will fail if none - // are defined. OS pipelines require a kernel. - // Add kernel and filesystem to every pipeline so that the - // manifest creation doesn't fail. - allPipelines := append(imageType.BuildPipelines(), imageType.PayloadPipelines()...) - minimalPackageSet := []rpmmd.PackageSpec{ - {Name: "kernel", Checksum: "sha256:a0c936696eb7d5ee3192bf53b9d281cecbb40ca9db520de72cb95817ad92ac72"}, - {Name: "filesystem", Checksum: "sha256:6b4bf18ba28ccbdd49f2716c9f33c9211155ff703fa6c195c78a07bd160da0eb"}, - } - - packageSets := make(map[string][]rpmmd.PackageSpec, len(allPipelines)) - for _, plName := range allPipelines { - packageSets[plName] = minimalPackageSet - } - - m, _, err := imageType.Manifest(&bp, options, repos, seed) - assert.NoError(err) - - containers := make(map[string][]container.Spec, 0) - - ostreeSources := m.GetOSTreeSourceSpecs() - commits := make(map[string][]ostree.CommitSpec, len(ostreeSources)) - for name, commitSources := range ostreeSources { - commitSpecs := make([]ostree.CommitSpec, len(commitSources)) - for idx, commitSource := range commitSources { - commitSpecs[idx] = ostree.CommitSpec{ - Ref: commitSource.Ref, - URL: commitSource.URL, - Checksum: fmt.Sprintf("%x", sha256.Sum256([]byte(commitSource.URL+commitSource.Ref))), - } - } - commits[name] = commitSpecs - } - mf, err := m.Serialize(packageSets, containers, commits) - assert.NoError(err) - pm := new(manifest) - err = json.Unmarshal(mf, pm) - assert.NoError(err) - - assert.Equal(len(allPipelines), len(pm.Pipelines)) - for idx := range pm.Pipelines { - // manifest pipeline names should be identical to the ones - // defined in the image type and in the same order - assert.Equal(allPipelines[idx], pm.Pipelines[idx].Name) - - if pm.Pipelines[idx].Name == "os" { - rpmStagePresent := false - for _, s := range pm.Pipelines[idx].Stages { - if s.Type == "org.osbuild.rpm" { - rpmStagePresent = true - if imageTypeName != "azure-eap7-rhui" { - // NOTE (akoutsou): Ideally, at some point we will - // have a good way of reading what's supported by - // each image type and we can skip or adapt tests - // based on this information. For image types with - // a preset workload, payload packages are ignored - // and dropped and so are the payload - // repo gpg keys. - assert.Equal(repos[0].GPGKeys, s.Options.GPGKeys) - } - } - } - // make sure the gpg keys check was reached - assert.True(rpmStagePresent) - } - } - - // The last pipeline should match the export pipeline. - // This might change in the future, but for now, let's make - // sure they match. - assert.Equal(imageType.Exports()[0], pm.Pipelines[len(pm.Pipelines)-1].Name) - - }) - } - } - } -} - -// Ensure repositories are assigned to package sets properly. -// -// Each package set should include all the global repositories as well as any -// pipeline/package-set specific repositories. -func TestPipelineRepositories(t *testing.T) { - require := require.New(t) - - type testCase struct { - // Repo configs for pipeline generator - repos []rpmmd.RepoConfig - - // Expected result: map of pipelines to repo names (we only check names for the test). - // Use the pipeline name * for global repos. - result map[string][]stringSet - } - - testCases := map[string]testCase{ - "globalonly": { // only global repos: most common scenario - repos: []rpmmd.RepoConfig{ - { - Name: "global-1", - BaseURLs: []string{"http://global-1.example.com"}, - }, - { - Name: "global-2", - BaseURLs: []string{"http://global-2.example.com"}, - }, - }, - result: map[string][]stringSet{ - "*": {newStringSet([]string{"global-1", "global-2"})}, - }, - }, - "global+build": { // global repos with build-specific repos: secondary common scenario - repos: []rpmmd.RepoConfig{ - { - Name: "global-11", - BaseURLs: []string{"http://global-11.example.com"}, - }, - { - Name: "global-12", - BaseURLs: []string{"http://global-12.example.com"}, - }, - { - Name: "build-1", - BaseURLs: []string{"http://build-1.example.com"}, - PackageSets: []string{"build"}, - }, - { - Name: "build-2", - BaseURLs: []string{"http://build-2.example.com"}, - PackageSets: []string{"build"}, - }, - }, - result: map[string][]stringSet{ - "*": {newStringSet([]string{"global-11", "global-12"})}, - "build": {newStringSet([]string{"build-1", "build-2"})}, - }, - }, - "global+os": { // global repos with os-specific repos - repos: []rpmmd.RepoConfig{ - { - Name: "global-21", - BaseURLs: []string{"http://global-11.example.com"}, - }, - { - Name: "global-22", - BaseURLs: []string{"http://global-12.example.com"}, - }, - { - Name: "os-1", - BaseURLs: []string{"http://os-1.example.com"}, - PackageSets: []string{"os"}, - }, - { - Name: "os-2", - BaseURLs: []string{"http://os-2.example.com"}, - PackageSets: []string{"os"}, - }, - }, - result: map[string][]stringSet{ - "*": {newStringSet([]string{"global-21", "global-22"})}, - "os": {newStringSet([]string{"os-1", "os-2"}), newStringSet([]string{"os-1", "os-2"})}, - }, - }, - "global+os+payload": { // global repos with os-specific repos and (user-defined) payload repositories - repos: []rpmmd.RepoConfig{ - { - Name: "global-21", - BaseURLs: []string{"http://global-11.example.com"}, - }, - { - Name: "global-22", - BaseURLs: []string{"http://global-12.example.com"}, - }, - { - Name: "os-1", - BaseURLs: []string{"http://os-1.example.com"}, - PackageSets: []string{"os"}, - }, - { - Name: "os-2", - BaseURLs: []string{"http://os-2.example.com"}, - PackageSets: []string{"os"}, - }, - { - Name: "payload", - BaseURLs: []string{"http://payload.example.com"}, - // User-defined payload repositories automatically get the "blueprint" key. - // This is handled by the APIs. - PackageSets: []string{"blueprint"}, - }, - }, - result: map[string][]stringSet{ - "*": {newStringSet([]string{"global-21", "global-22"})}, - "os": { - // chain with payload repo only in the second set for the blueprint package depsolve - newStringSet([]string{"os-1", "os-2"}), - newStringSet([]string{"os-1", "os-2", "payload"})}, - }, - }, - "noglobal": { // no global repositories; only pipeline restricted ones (unrealistic but technically valid) - repos: []rpmmd.RepoConfig{ - { - Name: "build-1", - BaseURLs: []string{"http://build-1.example.com"}, - PackageSets: []string{"build"}, - }, - { - Name: "build-2", - BaseURLs: []string{"http://build-2.example.com"}, - PackageSets: []string{"build"}, - }, - { - Name: "os-1", - BaseURLs: []string{"http://os-1.example.com"}, - PackageSets: []string{"os"}, - }, - { - Name: "os-2", - BaseURLs: []string{"http://os-2.example.com"}, - PackageSets: []string{"os"}, - }, - { - Name: "anaconda-1", - BaseURLs: []string{"http://anaconda-1.example.com"}, - PackageSets: []string{"anaconda-tree"}, - }, - { - Name: "container-1", - BaseURLs: []string{"http://container-1.example.com"}, - PackageSets: []string{"container-tree"}, - }, - { - Name: "coi-1", - BaseURLs: []string{"http://coi-1.example.com"}, - PackageSets: []string{"coi-tree"}, - }, - }, - result: map[string][]stringSet{ - "*": nil, - "build": {newStringSet([]string{"build-1", "build-2"})}, - "os": {newStringSet([]string{"os-1", "os-2"}), newStringSet([]string{"os-1", "os-2"})}, - "anaconda-tree": {newStringSet([]string{"anaconda-1"})}, - "container-tree": {newStringSet([]string{"container-1"})}, - "coi-tree": {newStringSet([]string{"coi-1"})}, - }, - }, - "global+unknown": { // package set names that don't match a pipeline are ignored - repos: []rpmmd.RepoConfig{ - { - Name: "global-1", - BaseURLs: []string{"http://global-1.example.com"}, - }, - { - Name: "global-2", - BaseURLs: []string{"http://global-2.example.com"}, - }, - { - Name: "custom-1", - BaseURLs: []string{"http://custom.example.com"}, - PackageSets: []string{"notapipeline"}, - }, - }, - result: map[string][]stringSet{ - "*": {newStringSet([]string{"global-1", "global-2"})}, - }, - }, - "none": { // empty - repos: []rpmmd.RepoConfig{}, - result: map[string][]stringSet{}, - }, - } - - distros := distroregistry.NewDefault() - for tName, tCase := range testCases { - t.Run(tName, func(t *testing.T) { - for _, distroName := range distros.List() { - d := distros.GetDistro(distroName) - for _, archName := range d.ListArches() { - arch, err := d.GetArch(archName) - require.Nil(err) - for _, imageTypeName := range arch.ListImageTypes() { - if imageTypeName == "azure-eap7-rhui" { - // NOTE (akoutsou): Ideally, at some point we will - // have a good way of reading what's supported by - // each image type and we can skip or adapt tests - // based on this information. For image types with - // a preset workload, payload packages are ignored - // and dropped. - continue - } - t.Run(fmt.Sprintf("%s/%s/%s", distroName, archName, imageTypeName), func(t *testing.T) { - imageType, err := arch.GetImageType(imageTypeName) - require.Nil(err) - - // set up bare minimum args for image type - var customizations *blueprint.Customizations - if imageType.Name() == "edge-simplified-installer" { - customizations = &blueprint.Customizations{ - InstallationDevice: "/dev/null", - } - } - bp := blueprint.Blueprint{ - Customizations: customizations, - Packages: []blueprint.Package{ - {Name: "filesystem"}, - }, - } - options := distro.ImageOptions{} - - // Add ostree options for image types that require them - options.OSTree = &ostree.ImageOptions{ - URL: "https://example.com", - } - - repos := tCase.repos - manifest, _, err := imageType.Manifest(&bp, options, repos, 0) - require.NoError(err) - packageSets := manifest.GetPackageSetChains() - - var globals stringSet - if len(tCase.result["*"]) > 0 { - globals = tCase.result["*"][0] - } - for psName, psChain := range packageSets { - - expChain := tCase.result[psName] - if len(expChain) > 0 { - // if we specified an expected chain it should match the returned. - if len(expChain) != len(psChain) { - t.Fatalf("expected %d package sets in the %q chain; got %d", len(expChain), psName, len(psChain)) - } - } else { - // if we didn't, initialise to empty before merging globals - expChain = make([]stringSet, len(psChain)) - } - - for idx := range expChain { - // merge the globals into each expected set - expChain[idx] = expChain[idx].Merge(globals) - } - - for setIdx, set := range psChain { - // collect repositories in the package set - repoNamesSet := newStringSet(nil) - for _, repo := range set.Repositories { - repoNamesSet.Add(repo.Name) - } - - // expected set for current package set should be merged with globals - expected := expChain[setIdx] - if !repoNamesSet.Equals(expected) { - t.Errorf("repos for package set %q [idx: %d] %s (distro %q image type %q) do not match expected %s", psName, setIdx, repoNamesSet, d.Name(), imageType.Name(), expected) - } - } - } - }) - } - } - } - }) - } -} - -// a very basic implementation of a Set of strings -type stringSet struct { - elems map[string]bool -} - -func newStringSet(init []string) stringSet { - s := stringSet{elems: make(map[string]bool)} - for _, elem := range init { - s.Add(elem) - } - return s -} - -func (s stringSet) String() string { - elemSlice := make([]string, 0, len(s.elems)) - for elem := range s.elems { - elemSlice = append(elemSlice, elem) - } - return "{" + strings.Join(elemSlice, ", ") + "}" -} - -func (s stringSet) Add(elem string) { - s.elems[elem] = true -} - -func (s stringSet) Contains(elem string) bool { - return s.elems[elem] -} - -func (s stringSet) Equals(other stringSet) bool { - if len(s.elems) != len(other.elems) { - return false - } - - for elem := range s.elems { - if !other.Contains(elem) { - return false - } - } - - return true -} - -func (s stringSet) Merge(other stringSet) stringSet { - merged := newStringSet(nil) - for elem := range s.elems { - merged.Add(elem) - } - for elem := range other.elems { - merged.Add(elem) - } - return merged -} diff --git a/internal/distro/fedora/distro_test.go b/internal/distro/fedora/distro_test.go deleted file mode 100644 index b4d84751c..000000000 --- a/internal/distro/fedora/distro_test.go +++ /dev/null @@ -1,815 +0,0 @@ -package fedora_test - -import ( - "fmt" - "strings" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/distro_test_common" - "github.com/osbuild/osbuild-composer/internal/distro/fedora" -) - -type fedoraFamilyDistro struct { - name string - distro distro.Distro -} - -var fedoraFamilyDistros = []fedoraFamilyDistro{ - { - name: "fedora", - distro: fedora.NewF37(), - }, - { - name: "fedora", - distro: fedora.NewF38(), - }, - { - name: "fedora", - distro: fedora.NewF39(), - }, -} - -func TestFilenameFromType(t *testing.T) { - type args struct { - outputFormat string - } - type wantResult struct { - filename string - mimeType string - wantErr bool - } - tests := []struct { - name string - args args - want wantResult - }{ - { - name: "ami", - args: args{"ami"}, - want: wantResult{ - filename: "image.raw", - mimeType: "application/octet-stream", - }, - }, - { - name: "qcow2", - args: args{"qcow2"}, - want: wantResult{ - filename: "disk.qcow2", - mimeType: "application/x-qemu-disk", - }, - }, - { - name: "openstack", - args: args{"openstack"}, - want: wantResult{ - filename: "disk.qcow2", - mimeType: "application/x-qemu-disk", - }, - }, - { - name: "vhd", - args: args{"vhd"}, - want: wantResult{ - filename: "disk.vhd", - mimeType: "application/x-vhd", - }, - }, - { - name: "vmdk", - args: args{"vmdk"}, - want: wantResult{ - filename: "disk.vmdk", - mimeType: "application/x-vmdk", - }, - }, - { - name: "ova", - args: args{"ova"}, - want: wantResult{ - filename: "image.ova", - mimeType: "application/ovf", - }, - }, - { - name: "container", - args: args{"container"}, - want: wantResult{ - filename: "container.tar", - mimeType: "application/x-tar", - }, - }, - { - name: "iot-commit", - args: args{"iot-commit"}, - want: wantResult{ - filename: "commit.tar", - mimeType: "application/x-tar", - }, - }, - { // Alias - name: "fedora-iot-commit", - args: args{"fedora-iot-commit"}, - want: wantResult{ - filename: "commit.tar", - mimeType: "application/x-tar", - }, - }, - { - name: "iot-container", - args: args{"iot-container"}, - want: wantResult{ - filename: "container.tar", - mimeType: "application/x-tar", - }, - }, - { // Alias - name: "fedora-iot-container", - args: args{"fedora-iot-container"}, - want: wantResult{ - filename: "container.tar", - mimeType: "application/x-tar", - }, - }, - { - name: "iot-installer", - args: args{"iot-installer"}, - want: wantResult{ - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - }, - }, - { // Alias - name: "fedora-iot-installer", - args: args{"fedora-iot-installer"}, - want: wantResult{ - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - }, - }, - { - name: "live-installer", - args: args{"live-installer"}, - want: wantResult{ - filename: "live-installer.iso", - mimeType: "application/x-iso9660-image", - }, - }, - { - name: "image-installer", - args: args{"image-installer"}, - want: wantResult{ - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - }, - }, - { // Alias - name: "fedora-image-installer", - args: args{"fedora-image-installer"}, - want: wantResult{ - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - }, - }, - { - name: "invalid-output-type", - args: args{"foobar"}, - want: wantResult{wantErr: true}, - }, - { - name: "minimal-raw", - args: args{"minimal-raw"}, - want: wantResult{ - filename: "raw.img", - mimeType: "application/disk", - }, - }, - } - for _, dist := range fedoraFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dist := dist.distro - arch, _ := dist.GetArch("x86_64") - imgType, err := arch.GetImageType(tt.args.outputFormat) - if (err != nil) != tt.want.wantErr { - t.Errorf("Arch.GetImageType() error = %v, wantErr %v", err, tt.want.wantErr) - return - } - if !tt.want.wantErr { - gotFilename := imgType.Filename() - gotMIMEType := imgType.MIMEType() - if gotFilename != tt.want.filename { - t.Errorf("ImageType.Filename() got = %v, want %v", gotFilename, tt.want.filename) - } - if gotMIMEType != tt.want.mimeType { - t.Errorf("ImageType.MIMEType() got1 = %v, want %v", gotMIMEType, tt.want.mimeType) - } - } - }) - } - }) - } -} - -func TestImageType_BuildPackages(t *testing.T) { - x8664BuildPackages := []string{ - "dnf", - "dosfstools", - "e2fsprogs", - "policycoreutils", - "qemu-img", - "selinux-policy-targeted", - "systemd", - "tar", - "xz", - "grub2-pc", - } - aarch64BuildPackages := []string{ - "dnf", - "dosfstools", - "e2fsprogs", - "policycoreutils", - "qemu-img", - "selinux-policy-targeted", - "systemd", - "tar", - "xz", - } - buildPackages := map[string][]string{ - "x86_64": x8664BuildPackages, - "aarch64": aarch64BuildPackages, - } - for _, dist := range fedoraFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - d := dist.distro - for _, archLabel := range d.ListArches() { - archStruct, err := d.GetArch(archLabel) - if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { - continue - } - for _, itLabel := range archStruct.ListImageTypes() { - itStruct, err := archStruct.GetImageType(itLabel) - if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { - continue - } - manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, 0) - assert.NoError(t, err) - buildPkgs := manifest.GetPackageSetChains()["build"] - assert.NotNil(t, buildPkgs) - assert.Len(t, buildPkgs, 1) - assert.ElementsMatch(t, buildPackages[archLabel], buildPkgs[0].Include) - } - } - }) - } -} - -func TestImageType_Name(t *testing.T) { - imgMap := []struct { - arch string - imgNames []string - }{ - { - arch: "x86_64", - imgNames: []string{ - "qcow2", - "openstack", - "vhd", - "vmdk", - "ova", - "ami", - "iot-commit", - "iot-container", - "iot-installer", - "iot-raw-image", - "oci", - "image-installer", - "live-installer", - "minimal-raw", - }, - }, - { - arch: "aarch64", - imgNames: []string{ - "qcow2", - "openstack", - "ami", - "oci", - "iot-commit", - "iot-container", - "iot-installer", - "iot-raw-image", - "image-installer", - "minimal-raw", - }, - }, - } - - for _, dist := range fedoraFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, mapping := range imgMap { - if mapping.arch == "s390x" { - continue - } - arch, err := dist.distro.GetArch(mapping.arch) - if assert.NoError(t, err) { - for _, imgName := range mapping.imgNames { - if imgName == "iot-commit" { - continue - } - imgType, err := arch.GetImageType(imgName) - if assert.NoError(t, err) { - assert.Equalf(t, imgName, imgType.Name(), "arch: %s", mapping.arch) - } - } - } - } - }) - } -} - -func TestImageTypeAliases(t *testing.T) { - type args struct { - imageTypeAliases []string - } - type wantResult struct { - imageTypeName string - } - tests := []struct { - name string - args args - want wantResult - }{ - { - name: "iot-commit aliases", - args: args{ - imageTypeAliases: []string{"fedora-iot-commit"}, - }, - want: wantResult{ - imageTypeName: "iot-commit", - }, - }, - - { - name: "iot-container aliases", - args: args{ - imageTypeAliases: []string{"fedora-iot-container"}, - }, - want: wantResult{ - imageTypeName: "iot-container", - }, - }, - - { - name: "iot-installer aliases", - args: args{ - imageTypeAliases: []string{"fedora-iot-installer"}, - }, - want: wantResult{ - imageTypeName: "iot-installer", - }, - }, - } - for _, dist := range fedoraFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dist := dist.distro - for _, archName := range dist.ListArches() { - t.Run(archName, func(t *testing.T) { - arch, err := dist.GetArch(archName) - require.Nilf(t, err, - "failed to get architecture '%s', previously listed as supported for the distro '%s'", - archName, dist.Name()) - // Test image type aliases only if the aliased image type is supported for the arch - if _, err = arch.GetImageType(tt.want.imageTypeName); err != nil { - t.Skipf("aliased image type '%s' is not supported for architecture '%s'", - tt.want.imageTypeName, archName) - } - for _, alias := range tt.args.imageTypeAliases { - t.Run(fmt.Sprintf("'%s' alias for image type '%s'", alias, tt.want.imageTypeName), - func(t *testing.T) { - gotImage, err := arch.GetImageType(alias) - require.Nilf(t, err, "arch.GetImageType() for image type alias '%s' failed: %v", - alias, err) - assert.Equalf(t, tt.want.imageTypeName, gotImage.Name(), - "got unexpected image type name for alias '%s'. got = %s, want = %s", - alias, tt.want.imageTypeName, gotImage.Name()) - }) - } - }) - } - }) - } - }) - } -} - -// Check that Manifest() function returns an error for unsupported -// configurations. -func TestDistro_ManifestError(t *testing.T) { - // Currently, the only unsupported configuration is OSTree commit types - // with Kernel boot options - fedoraDistro := fedora.NewF37() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Kernel: &blueprint.KernelCustomization{ - Append: "debug", - }, - }, - } - - for _, archName := range fedoraDistro.ListArches() { - arch, _ := fedoraDistro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - imgOpts := distro.ImageOptions{ - Size: imgType.Size(0), - } - _, _, err := imgType.Manifest(&bp, imgOpts, nil, 0) - if imgTypeName == "iot-commit" || imgTypeName == "iot-container" { - assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types") - } else if imgTypeName == "iot-installer" { - assert.EqualError(t, err, fmt.Sprintf("boot ISO image type \"%s\" requires specifying a URL from which to retrieve the OSTree commit", imgTypeName)) - } else if imgTypeName == "image-installer" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: User, Group)", imgTypeName)) - } else if imgTypeName == "live-installer" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: None)", imgTypeName)) - } else if imgTypeName == "iot-raw-image" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName)) - } else { - assert.NoError(t, err) - } - } - } -} - -func TestArchitecture_ListImageTypes(t *testing.T) { - imgMap := []struct { - arch string - imgNames []string - fedoraAdditionalImageTypes []string - }{ - { - arch: "x86_64", - imgNames: []string{ - "qcow2", - "openstack", - "vhd", - "vmdk", - "ova", - "ami", - "iot-commit", - "iot-container", - "iot-installer", - "iot-raw-image", - "oci", - "container", - "image-installer", - "live-installer", - "minimal-raw", - }, - }, - { - arch: "aarch64", - imgNames: []string{ - "qcow2", - "openstack", - "ami", - "iot-commit", - "iot-container", - "iot-installer", - "iot-raw-image", - "oci", - "container", - "image-installer", - "live-installer", - "minimal-raw", - }, - }, - } - - for _, dist := range fedoraFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, mapping := range imgMap { - arch, err := dist.distro.GetArch(mapping.arch) - require.NoError(t, err) - imageTypes := arch.ListImageTypes() - - var expectedImageTypes []string - expectedImageTypes = append(expectedImageTypes, mapping.imgNames...) - if dist.name == "fedora" { - expectedImageTypes = append(expectedImageTypes, mapping.fedoraAdditionalImageTypes...) - } - - require.ElementsMatch(t, expectedImageTypes, imageTypes) - } - }) - } -} - -func TestFedora_ListArches(t *testing.T) { - arches := fedora.NewF37().ListArches() - assert.Equal(t, []string{"aarch64", "x86_64"}, arches) -} - -func TestFedora37_GetArch(t *testing.T) { - arches := []struct { - name string - errorExpected bool - errorExpectedInCentos bool - }{ - { - name: "x86_64", - }, - { - name: "aarch64", - }, - { - name: "s390x", - errorExpected: true, - }, - { - name: "ppc64le", - errorExpected: true, - }, - { - name: "foo-arch", - errorExpected: true, - }, - } - - for _, dist := range fedoraFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, a := range arches { - actualArch, err := dist.distro.GetArch(a.name) - if a.errorExpected { - assert.Nil(t, actualArch) - assert.Error(t, err) - } else { - assert.Equal(t, a.name, actualArch.Name()) - assert.NoError(t, err) - } - } - }) - } -} - -func TestFedora37_Name(t *testing.T) { - distro := fedora.NewF37() - assert.Equal(t, "fedora-37", distro.Name()) -} - -func TestFedora37_KernelOption(t *testing.T) { - distro_test_common.TestDistro_KernelOption(t, fedora.NewF37()) -} - -func TestFedora_OSTreeOptions(t *testing.T) { - distro_test_common.TestDistro_OSTreeOptions(t, fedora.NewF37()) -} - -func TestDistro_CustomFileSystemManifestError(t *testing.T) { - fedoraDistro := fedora.NewF37() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/etc", - }, - }, - }, - } - for _, archName := range fedoraDistro.ListArches() { - arch, _ := fedoraDistro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "iot-commit" || imgTypeName == "iot-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if imgTypeName == "iot-raw-image" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName)) - } else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" { - continue - } else if imgTypeName == "live-installer" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: None)", imgTypeName)) - } else { - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/etc\"]") - } - } - } -} - -func TestDistro_TestRootMountPoint(t *testing.T) { - fedoraDistro := fedora.NewF37() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/", - }, - }, - }, - } - for _, archName := range fedoraDistro.ListArches() { - arch, _ := fedoraDistro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "iot-commit" || imgTypeName == "iot-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if imgTypeName == "iot-raw-image" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName)) - } else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" { - continue - } else if imgTypeName == "live-installer" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: None)", imgTypeName)) - } else { - assert.NoError(t, err) - } - } - } -} - -func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { - fedoraDistro := fedora.NewF37() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/var/log", - }, - { - MinSize: 1024, - Mountpoint: "/var/log/audit", - }, - }, - }, - } - for _, archName := range fedoraDistro.ListArches() { - arch, _ := fedoraDistro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if strings.HasPrefix(imgTypeName, "iot-") || strings.HasPrefix(imgTypeName, "image-") { - continue - } else if imgTypeName == "live-installer" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: None)", imgTypeName)) - } else { - assert.NoError(t, err) - } - } - } -} - -func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { - fedoraDistro := fedora.NewF37() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/var/a", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b/c", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b/c/d", - }, - }, - }, - } - for _, archName := range fedoraDistro.ListArches() { - arch, _ := fedoraDistro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if strings.HasPrefix(imgTypeName, "iot-") || strings.HasPrefix(imgTypeName, "image-") { - continue - } else if imgTypeName == "live-installer" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: None)", imgTypeName)) - } else { - assert.NoError(t, err) - } - } - } -} - -func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { - fedoraDistro := fedora.NewF37() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "//", - }, - { - MinSize: 1024, - Mountpoint: "/var//", - }, - { - MinSize: 1024, - Mountpoint: "/var//log/audit/", - }, - }, - }, - } - for _, archName := range fedoraDistro.ListArches() { - arch, _ := fedoraDistro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if strings.HasPrefix(imgTypeName, "iot-") || strings.HasPrefix(imgTypeName, "image-") { - continue - } else if imgTypeName == "live-installer" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: None)", imgTypeName)) - } else { - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"//\" \"/var//\" \"/var//log/audit/\"]") - } - } - } -} - -func TestDistro_CustomFileSystemPatternMatching(t *testing.T) { - fedoraDistro := fedora.NewF37() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/variable", - }, - { - MinSize: 1024, - Mountpoint: "/variable/log/audit", - }, - }, - }, - } - for _, archName := range fedoraDistro.ListArches() { - arch, _ := fedoraDistro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "iot-commit" || imgTypeName == "iot-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if imgTypeName == "iot-raw-image" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName)) - } else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" { - continue - } else if imgTypeName == "live-installer" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: None)", imgTypeName)) - } else { - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/variable\" \"/variable/log/audit\"]") - } - } - } -} - -func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { - fedoraDistro := fedora.NewF37() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/usr", - }, - }, - }, - } - for _, archName := range fedoraDistro.ListArches() { - arch, _ := fedoraDistro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "iot-commit" || imgTypeName == "iot-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if imgTypeName == "iot-raw-image" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName)) - } else if imgTypeName == "iot-installer" || imgTypeName == "image-installer" { - continue - } else if imgTypeName == "live-installer" { - assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: None)", imgTypeName)) - } else { - assert.NoError(t, err) - } - } - } -} diff --git a/internal/distro/image_config_test.go b/internal/distro/image_config_test.go deleted file mode 100644 index d091bcef5..000000000 --- a/internal/distro/image_config_test.go +++ /dev/null @@ -1,218 +0,0 @@ -package distro - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/osbuild" -) - -func TestImageConfigInheritFrom(t *testing.T) { - tests := []struct { - name string - distroConfig *ImageConfig - imageConfig *ImageConfig - expectedConfig *ImageConfig - }{ - { - name: "inheritance with overridden values", - distroConfig: &ImageConfig{ - Timezone: common.ToPtr("America/New_York"), - TimeSynchronization: &osbuild.ChronyStageOptions{ - Servers: []osbuild.ChronyConfigServer{{Hostname: "127.0.0.1"}}, - }, - Locale: common.ToPtr("en_US.UTF-8"), - Keyboard: &osbuild.KeymapStageOptions{ - Keymap: "us", - }, - EnabledServices: []string{"sshd"}, - DisabledServices: []string{"named"}, - DefaultTarget: common.ToPtr("multi-user.target"), - Sysconfig: []*osbuild.SysconfigStageOptions{ - { - Kernel: &osbuild.SysconfigKernelOptions{ - UpdateDefault: true, - DefaultKernel: "kernel", - }, - Network: &osbuild.SysconfigNetworkOptions{ - Networking: true, - NoZeroConf: true, - }, - NetworkScripts: &osbuild.NetworkScriptsOptions{ - IfcfgFiles: map[string]osbuild.IfcfgFile{ - "eth0": { - Device: "eth0", - Bootproto: osbuild.IfcfgBootprotoDHCP, - OnBoot: common.ToPtr(true), - Type: osbuild.IfcfgTypeEthernet, - UserCtl: common.ToPtr(true), - PeerDNS: common.ToPtr(true), - IPv6Init: common.ToPtr(false), - }, - }, - }, - }, - }, - }, - imageConfig: &ImageConfig{ - Timezone: common.ToPtr("UTC"), - TimeSynchronization: &osbuild.ChronyStageOptions{ - Servers: []osbuild.ChronyConfigServer{ - { - Hostname: "169.254.169.123", - Prefer: common.ToPtr(true), - Iburst: common.ToPtr(true), - Minpoll: common.ToPtr(4), - Maxpoll: common.ToPtr(4), - }, - }, - LeapsecTz: common.ToPtr(""), - }, - }, - expectedConfig: &ImageConfig{ - Timezone: common.ToPtr("UTC"), - TimeSynchronization: &osbuild.ChronyStageOptions{ - Servers: []osbuild.ChronyConfigServer{ - { - Hostname: "169.254.169.123", - Prefer: common.ToPtr(true), - Iburst: common.ToPtr(true), - Minpoll: common.ToPtr(4), - Maxpoll: common.ToPtr(4), - }, - }, - LeapsecTz: common.ToPtr(""), - }, - Locale: common.ToPtr("en_US.UTF-8"), - Keyboard: &osbuild.KeymapStageOptions{ - Keymap: "us", - }, - EnabledServices: []string{"sshd"}, - DisabledServices: []string{"named"}, - DefaultTarget: common.ToPtr("multi-user.target"), - Sysconfig: []*osbuild.SysconfigStageOptions{ - { - Kernel: &osbuild.SysconfigKernelOptions{ - UpdateDefault: true, - DefaultKernel: "kernel", - }, - Network: &osbuild.SysconfigNetworkOptions{ - Networking: true, - NoZeroConf: true, - }, - NetworkScripts: &osbuild.NetworkScriptsOptions{ - IfcfgFiles: map[string]osbuild.IfcfgFile{ - "eth0": { - Device: "eth0", - Bootproto: osbuild.IfcfgBootprotoDHCP, - OnBoot: common.ToPtr(true), - Type: osbuild.IfcfgTypeEthernet, - UserCtl: common.ToPtr(true), - PeerDNS: common.ToPtr(true), - IPv6Init: common.ToPtr(false), - }, - }, - }, - }, - }, - }, - }, - { - name: "empty image type configuration", - distroConfig: &ImageConfig{ - Timezone: common.ToPtr("America/New_York"), - TimeSynchronization: &osbuild.ChronyStageOptions{ - Servers: []osbuild.ChronyConfigServer{{Hostname: "127.0.0.1"}}, - }, - Locale: common.ToPtr("en_US.UTF-8"), - Keyboard: &osbuild.KeymapStageOptions{ - Keymap: "us", - }, - EnabledServices: []string{"sshd"}, - DisabledServices: []string{"named"}, - DefaultTarget: common.ToPtr("multi-user.target"), - }, - imageConfig: &ImageConfig{}, - expectedConfig: &ImageConfig{ - Timezone: common.ToPtr("America/New_York"), - TimeSynchronization: &osbuild.ChronyStageOptions{ - Servers: []osbuild.ChronyConfigServer{{Hostname: "127.0.0.1"}}, - }, - Locale: common.ToPtr("en_US.UTF-8"), - Keyboard: &osbuild.KeymapStageOptions{ - Keymap: "us", - }, - EnabledServices: []string{"sshd"}, - DisabledServices: []string{"named"}, - DefaultTarget: common.ToPtr("multi-user.target"), - }, - }, - { - name: "empty distro configuration", - distroConfig: &ImageConfig{}, - imageConfig: &ImageConfig{ - Timezone: common.ToPtr("America/New_York"), - TimeSynchronization: &osbuild.ChronyStageOptions{ - Servers: []osbuild.ChronyConfigServer{{Hostname: "127.0.0.1"}}, - }, - Locale: common.ToPtr("en_US.UTF-8"), - Keyboard: &osbuild.KeymapStageOptions{ - Keymap: "us", - }, - EnabledServices: []string{"sshd"}, - DisabledServices: []string{"named"}, - DefaultTarget: common.ToPtr("multi-user.target"), - }, - expectedConfig: &ImageConfig{ - Timezone: common.ToPtr("America/New_York"), - TimeSynchronization: &osbuild.ChronyStageOptions{ - Servers: []osbuild.ChronyConfigServer{{Hostname: "127.0.0.1"}}, - }, - Locale: common.ToPtr("en_US.UTF-8"), - Keyboard: &osbuild.KeymapStageOptions{ - Keymap: "us", - }, - EnabledServices: []string{"sshd"}, - DisabledServices: []string{"named"}, - DefaultTarget: common.ToPtr("multi-user.target"), - }, - }, - { - name: "empty distro configuration", - distroConfig: nil, - imageConfig: &ImageConfig{ - Timezone: common.ToPtr("America/New_York"), - TimeSynchronization: &osbuild.ChronyStageOptions{ - Servers: []osbuild.ChronyConfigServer{{Hostname: "127.0.0.1"}}, - }, - Locale: common.ToPtr("en_US.UTF-8"), - Keyboard: &osbuild.KeymapStageOptions{ - Keymap: "us", - }, - EnabledServices: []string{"sshd"}, - DisabledServices: []string{"named"}, - DefaultTarget: common.ToPtr("multi-user.target"), - }, - expectedConfig: &ImageConfig{ - Timezone: common.ToPtr("America/New_York"), - TimeSynchronization: &osbuild.ChronyStageOptions{ - Servers: []osbuild.ChronyConfigServer{{Hostname: "127.0.0.1"}}, - }, - Locale: common.ToPtr("en_US.UTF-8"), - Keyboard: &osbuild.KeymapStageOptions{ - Keymap: "us", - }, - EnabledServices: []string{"sshd"}, - DisabledServices: []string{"named"}, - DefaultTarget: common.ToPtr("multi-user.target"), - }, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - assert.Equalf(t, tt.expectedConfig, tt.imageConfig.InheritFrom(tt.distroConfig), "test case %q failed (idx %d)", tt.name, idx) - }) - } -} diff --git a/internal/distro/rhel7/distro_test.go b/internal/distro/rhel7/distro_test.go deleted file mode 100644 index bf98fd342..000000000 --- a/internal/distro/rhel7/distro_test.go +++ /dev/null @@ -1,452 +0,0 @@ -package rhel7_test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/distro_test_common" - "github.com/osbuild/osbuild-composer/internal/distro/rhel7" -) - -type rhelFamilyDistro struct { - name string - distro distro.Distro -} - -var rhelFamilyDistros = []rhelFamilyDistro{ - { - name: "rhel", - distro: rhel7.New(), - }, -} - -func TestFilenameFromType(t *testing.T) { - type args struct { - outputFormat string - } - type wantResult struct { - filename string - mimeType string - wantErr bool - } - tests := []struct { - name string - args args - want wantResult - }{ - { - name: "qcow2", - args: args{"qcow2"}, - want: wantResult{ - filename: "disk.qcow2", - mimeType: "application/x-qemu-disk", - }, - }, - { - name: "azure-rhui", - args: args{"azure-rhui"}, - want: wantResult{ - filename: "disk.vhd.xz", - mimeType: "application/xz", - }, - }, - { - name: "invalid-output-type", - args: args{"foobar"}, - want: wantResult{wantErr: true}, - }, - } - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dist := dist.distro - arch, _ := dist.GetArch("x86_64") - imgType, err := arch.GetImageType(tt.args.outputFormat) - if (err != nil) != tt.want.wantErr { - t.Errorf("Arch.GetImageType() error = %v, wantErr %v", err, tt.want.wantErr) - return - } - if !tt.want.wantErr { - gotFilename := imgType.Filename() - gotMIMEType := imgType.MIMEType() - if gotFilename != tt.want.filename { - t.Errorf("ImageType.Filename() got = %v, want %v", gotFilename, tt.want.filename) - } - if gotMIMEType != tt.want.mimeType { - t.Errorf("ImageType.MIMEType() got1 = %v, want %v", gotMIMEType, tt.want.mimeType) - } - } - }) - } - }) - } -} - -func TestImageType_BuildPackages(t *testing.T) { - x8664BuildPackages := []string{ - "dnf", - "dosfstools", - "e2fsprogs", - "grub2-efi-x64", - "grub2-pc", - "policycoreutils", - "shim-x64", - "systemd", - "tar", - "qemu-img", - "xz", - } - buildPackages := map[string][]string{ - "x86_64": x8664BuildPackages, - } - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - d := dist.distro - for _, archLabel := range d.ListArches() { - archStruct, err := d.GetArch(archLabel) - if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { - continue - } - for _, itLabel := range archStruct.ListImageTypes() { - itStruct, err := archStruct.GetImageType(itLabel) - if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { - continue - } - manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, 0) - assert.NoError(t, err) - buildPkgs := manifest.GetPackageSetChains()["build"] - assert.NotNil(t, buildPkgs) - assert.Len(t, buildPkgs, 1) - assert.ElementsMatch(t, buildPackages[archLabel], buildPkgs[0].Include) - } - } - }) - } -} - -func TestImageType_Name(t *testing.T) { - imgMap := []struct { - arch string - imgNames []string - }{ - { - arch: "x86_64", - imgNames: []string{ - "qcow2", - "azure-rhui", - }, - }, - } - - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, mapping := range imgMap { - arch, err := dist.distro.GetArch(mapping.arch) - if assert.NoError(t, err) { - for _, imgName := range mapping.imgNames { - imgType, err := arch.GetImageType(imgName) - if assert.NoError(t, err) { - assert.Equalf(t, imgName, imgType.Name(), "arch: %s", mapping.arch) - } - } - } - } - }) - } -} - -// Check that Manifest() function returns an error for unsupported -// configurations. -func TestDistro_ManifestError(t *testing.T) { - r7distro := rhel7.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Kernel: &blueprint.KernelCustomization{ - Append: "debug", - }, - }, - } - - for _, archName := range r7distro.ListArches() { - arch, _ := r7distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - imgOpts := distro.ImageOptions{ - Size: imgType.Size(0), - } - _, _, err := imgType.Manifest(&bp, imgOpts, nil, 0) - assert.NoError(t, err) - } - } -} - -func TestArchitecture_ListImageTypes(t *testing.T) { - imgMap := []struct { - arch string - imgNames []string - rhelAdditionalImageTypes []string - }{ - { - arch: "x86_64", - imgNames: []string{ - "qcow2", - "azure-rhui", - }, - }, - } - - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, mapping := range imgMap { - arch, err := dist.distro.GetArch(mapping.arch) - require.NoError(t, err) - imageTypes := arch.ListImageTypes() - - var expectedImageTypes []string - expectedImageTypes = append(expectedImageTypes, mapping.imgNames...) - if dist.name == "rhel" { - expectedImageTypes = append(expectedImageTypes, mapping.rhelAdditionalImageTypes...) - } - - require.ElementsMatch(t, expectedImageTypes, imageTypes) - } - }) - } -} - -func TestRhel7_ListArches(t *testing.T) { - arches := rhel7.New().ListArches() - assert.Equal(t, []string{"x86_64"}, arches) -} - -func TestRhel7_GetArch(t *testing.T) { - arches := []struct { - name string - errorExpected bool - errorExpectedInCentos bool - }{ - { - name: "x86_64", - }, - { - name: "foo-arch", - errorExpected: true, - }, - } - - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, a := range arches { - actualArch, err := dist.distro.GetArch(a.name) - if a.errorExpected || (a.errorExpectedInCentos && dist.name == "centos") { - assert.Nil(t, actualArch) - assert.Error(t, err) - } else { - assert.Equal(t, a.name, actualArch.Name()) - assert.NoError(t, err) - } - } - }) - } -} - -func TestRhel7_Name(t *testing.T) { - distro := rhel7.New() - assert.Equal(t, "rhel-7", distro.Name()) -} - -func TestRhel7_ModulePlatformID(t *testing.T) { - distro := rhel7.New() - assert.Equal(t, "platform:el7", distro.ModulePlatformID()) -} - -func TestRhel7_KernelOption(t *testing.T) { - distro_test_common.TestDistro_KernelOption(t, rhel7.New()) -} - -func TestDistro_CustomFileSystemManifestError(t *testing.T) { - r7distro := rhel7.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/etc", - }, - }, - }, - } - for _, archName := range r7distro.ListArches() { - arch, _ := r7distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/etc\"]") - } - } -} - -func TestDistro_TestRootMountPoint(t *testing.T) { - r7distro := rhel7.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/", - }, - }, - }, - } - for _, archName := range r7distro.ListArches() { - arch, _ := r7distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - assert.NoError(t, err) - } - } -} - -func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { - r7distro := rhel7.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/var/log", - }, - { - MinSize: 1024, - Mountpoint: "/var/log/audit", - }, - }, - }, - } - for _, archName := range r7distro.ListArches() { - arch, _ := r7distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - assert.NoError(t, err) - } - } -} - -func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { - r7distro := rhel7.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/var/a", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b/c", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b/c/d", - }, - }, - }, - } - for _, archName := range r7distro.ListArches() { - arch, _ := r7distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - assert.NoError(t, err) - } - } -} - -func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { - r7distro := rhel7.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "//", - }, - { - MinSize: 1024, - Mountpoint: "/var//", - }, - { - MinSize: 1024, - Mountpoint: "/var//log/audit/", - }, - }, - }, - } - for _, archName := range r7distro.ListArches() { - arch, _ := r7distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"//\" \"/var//\" \"/var//log/audit/\"]") - } - } -} - -func TestDistro_CustomFileSystemPatternMatching(t *testing.T) { - r7distro := rhel7.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/variable", - }, - { - MinSize: 1024, - Mountpoint: "/variable/log/audit", - }, - }, - }, - } - for _, archName := range r7distro.ListArches() { - arch, _ := r7distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/variable\" \"/variable/log/audit\"]") - } - } -} - -func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { - r7distro := rhel7.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/usr", - }, - }, - }, - } - for _, archName := range r7distro.ListArches() { - arch, _ := r7distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - assert.NoError(t, err) - } - } -} diff --git a/internal/distro/rhel8/distro_internal_test.go b/internal/distro/rhel8/distro_internal_test.go deleted file mode 100644 index 364402fc4..000000000 --- a/internal/distro/rhel8/distro_internal_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package rhel8 - -import ( - "fmt" - "math/rand" - "testing" - - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -var testBasicImageType = imageType{ - name: "test", - basePartitionTables: defaultBasePartitionTables, -} - -var testEc2ImageType = imageType{ - name: "test_ec2", - basePartitionTables: ec2BasePartitionTables, -} - -var mountpoints = []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/usr", - }, -} - -// math/rand is good enough in this case -/* #nosec G404 */ -var rng = rand.New(rand.NewSource(0)) - -func TestDistro_UnsupportedArch(t *testing.T) { - testBasicImageType.arch = &architecture{ - name: "unsupported_arch", - } - _, err := testBasicImageType.getPartitionTable(mountpoints, distro.ImageOptions{}, rng) - require.EqualError(t, err, fmt.Sprintf("no partition table defined for architecture %q for image type %q", testBasicImageType.arch.name, testBasicImageType.name)) -} - -func TestDistro_DefaultPartitionTables(t *testing.T) { - rhel8distro := New() - for _, archName := range rhel8distro.ListArches() { - testBasicImageType.arch = &architecture{ - name: archName, - } - pt, err := testBasicImageType.getPartitionTable(mountpoints, distro.ImageOptions{}, rng) - require.Nil(t, err) - for _, m := range mountpoints { - assert.True(t, pt.ContainsMountpoint(m.Mountpoint)) - } - } -} - -func TestDistro_Ec2PartitionTables(t *testing.T) { - rhel8distro := New() - for _, archName := range rhel8distro.ListArches() { - testEc2ImageType.arch = &architecture{ - name: archName, - } - pt, err := testEc2ImageType.getPartitionTable(mountpoints, distro.ImageOptions{}, rng) - if _, exists := testEc2ImageType.basePartitionTables[archName]; exists { - require.Nil(t, err) - for _, m := range mountpoints { - assert.True(t, pt.ContainsMountpoint(m.Mountpoint)) - } - } else { - require.EqualError(t, err, fmt.Sprintf("no partition table defined for architecture %q for image type %q", testEc2ImageType.arch.name, testEc2ImageType.name)) - } - } -} diff --git a/internal/distro/rhel8/distro_test.go b/internal/distro/rhel8/distro_test.go deleted file mode 100644 index 01a1e43b0..000000000 --- a/internal/distro/rhel8/distro_test.go +++ /dev/null @@ -1,907 +0,0 @@ -package rhel8_test - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/distro_test_common" - "github.com/osbuild/osbuild-composer/internal/distro/rhel8" - "github.com/osbuild/osbuild-composer/internal/platform" -) - -type rhelFamilyDistro struct { - name string - distro distro.Distro -} - -var rhelFamilyDistros = []rhelFamilyDistro{ - { - name: "rhel", - distro: rhel8.New(), - }, -} - -func TestFilenameFromType(t *testing.T) { - type args struct { - outputFormat string - } - type wantResult struct { - filename string - mimeType string - wantErr bool - } - tests := []struct { - name string - args args - want wantResult - }{ - { - name: "ami", - args: args{"ami"}, - want: wantResult{ - filename: "image.raw", - mimeType: "application/octet-stream", - }, - }, - { - name: "ec2", - args: args{"ec2"}, - want: wantResult{ - filename: "image.raw.xz", - mimeType: "application/xz", - }, - }, - { - name: "ec2-ha", - args: args{"ec2-ha"}, - want: wantResult{ - filename: "image.raw.xz", - mimeType: "application/xz", - }, - }, - { - name: "ec2-sap", - args: args{"ec2-sap"}, - want: wantResult{ - filename: "image.raw.xz", - mimeType: "application/xz", - }, - }, - { - name: "qcow2", - args: args{"qcow2"}, - want: wantResult{ - filename: "disk.qcow2", - mimeType: "application/x-qemu-disk", - }, - }, - { - name: "openstack", - args: args{"openstack"}, - want: wantResult{ - filename: "disk.qcow2", - mimeType: "application/x-qemu-disk", - }, - }, - { - name: "vhd", - args: args{"vhd"}, - want: wantResult{ - filename: "disk.vhd", - mimeType: "application/x-vhd", - }, - }, - { - name: "azure-rhui", - args: args{"azure-rhui"}, - want: wantResult{ - filename: "disk.vhd.xz", - mimeType: "application/xz", - }, - }, - { - name: "azure-sap-rhui", - args: args{"azure-sap-rhui"}, - want: wantResult{ - filename: "disk.vhd.xz", - mimeType: "application/xz", - }, - }, - { - name: "vmdk", - args: args{"vmdk"}, - want: wantResult{ - filename: "disk.vmdk", - mimeType: "application/x-vmdk", - }, - }, - { - name: "ova", - args: args{"ova"}, - want: wantResult{ - filename: "image.ova", - mimeType: "application/ovf", - }, - }, - { - name: "tar", - args: args{"tar"}, - want: wantResult{ - filename: "root.tar.xz", - mimeType: "application/x-tar", - }, - }, - { - name: "image-installer", - args: args{"image-installer"}, - want: wantResult{ - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - }, - }, - { - name: "edge-commit", - args: args{"edge-commit"}, - want: wantResult{ - filename: "commit.tar", - mimeType: "application/x-tar", - }, - }, - // Alias - { - name: "rhel-edge-commit", - args: args{"rhel-edge-commit"}, - want: wantResult{ - filename: "commit.tar", - mimeType: "application/x-tar", - }, - }, - { - name: "edge-container", - args: args{"edge-container"}, - want: wantResult{ - filename: "container.tar", - mimeType: "application/x-tar", - }, - }, - // Alias - { - name: "rhel-edge-container", - args: args{"rhel-edge-container"}, - want: wantResult{ - filename: "container.tar", - mimeType: "application/x-tar", - }, - }, - { - name: "edge-installer", - args: args{"edge-installer"}, - want: wantResult{ - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - }, - }, - // Alias - { - name: "rhel-edge-installer", - args: args{"rhel-edge-installer"}, - want: wantResult{ - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - }, - }, - { - name: "gce", - args: args{"gce"}, - want: wantResult{ - filename: "image.tar.gz", - mimeType: "application/gzip", - }, - }, - { - name: "gce-rhui", - args: args{"gce-rhui"}, - want: wantResult{ - filename: "image.tar.gz", - mimeType: "application/gzip", - }, - }, - { - name: "invalid-output-type", - args: args{"foobar"}, - want: wantResult{wantErr: true}, - }, - } - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dist := dist.distro - arch, _ := dist.GetArch("x86_64") - imgType, err := arch.GetImageType(tt.args.outputFormat) - if (err != nil) != tt.want.wantErr { - t.Errorf("Arch.GetImageType() error = %v, wantErr %v", err, tt.want.wantErr) - return - } - if !tt.want.wantErr { - gotFilename := imgType.Filename() - gotMIMEType := imgType.MIMEType() - if gotFilename != tt.want.filename { - t.Errorf("ImageType.Filename() got = %v, want %v", gotFilename, tt.want.filename) - } - if gotMIMEType != tt.want.mimeType { - t.Errorf("ImageType.MIMEType() got1 = %v, want %v", gotMIMEType, tt.want.mimeType) - } - } - }) - } - }) - } -} - -func TestImageType_BuildPackages(t *testing.T) { - x8664BuildPackages := []string{ - "dnf", - "dosfstools", - "e2fsprogs", - "grub2-efi-x64", - "grub2-pc", - "policycoreutils", - "shim-x64", - "systemd", - "tar", - "qemu-img", - "xz", - } - aarch64BuildPackages := []string{ - "dnf", - "dosfstools", - "e2fsprogs", - "policycoreutils", - "qemu-img", - "systemd", - "tar", - "xz", - } - buildPackages := map[string][]string{ - "x86_64": x8664BuildPackages, - "aarch64": aarch64BuildPackages, - } - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - d := dist.distro - for _, archLabel := range d.ListArches() { - archStruct, err := d.GetArch(archLabel) - if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { - continue - } - for _, itLabel := range archStruct.ListImageTypes() { - itStruct, err := archStruct.GetImageType(itLabel) - if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { - continue - } - manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, 0) - assert.NoError(t, err) - buildPkgs := manifest.GetPackageSetChains()["build"] - assert.NotNil(t, buildPkgs) - assert.Len(t, buildPkgs, 1) - assert.ElementsMatch(t, buildPackages[archLabel], buildPkgs[0].Include) - } - } - }) - } -} - -func TestImageType_Name(t *testing.T) { - imgMap := []struct { - arch string - imgNames []string - }{ - { - arch: "x86_64", - imgNames: []string{ - "qcow2", - "openstack", - "vhd", - "azure-rhui", - "azure-sap-rhui", - "azure-eap7-rhui", - "vmdk", - "ova", - "ami", - "ec2", - "ec2-ha", - "ec2-sap", - "gce", - "gce-rhui", - "edge-commit", - "edge-container", - "edge-installer", - "tar", - "image-installer", - }, - }, - { - arch: "aarch64", - imgNames: []string{ - "qcow2", - "openstack", - "vhd", - "azure-rhui", - "ami", - "ec2", - "edge-commit", - "edge-container", - "tar", - }, - }, - { - arch: "ppc64le", - imgNames: []string{ - "qcow2", - "tar", - }, - }, - { - arch: "s390x", - imgNames: []string{ - "qcow2", - "tar", - }, - }, - } - - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, mapping := range imgMap { - if mapping.arch == platform.ARCH_S390X.String() && dist.name == "centos" { - continue - } - arch, err := dist.distro.GetArch(mapping.arch) - if assert.NoError(t, err) { - for _, imgName := range mapping.imgNames { - if imgName == "edge-commit" && dist.name == "centos" { - continue - } - imgType, err := arch.GetImageType(imgName) - if assert.NoError(t, err) { - assert.Equalf(t, imgName, imgType.Name(), "arch: %s", mapping.arch) - } - } - } - } - }) - } -} - -func TestImageTypeAliases(t *testing.T) { - type args struct { - imageTypeAliases []string - } - type wantResult struct { - imageTypeName string - } - tests := []struct { - name string - args args - want wantResult - }{ - { - name: "edge-commit aliases", - args: args{ - imageTypeAliases: []string{"rhel-edge-commit"}, - }, - want: wantResult{ - imageTypeName: "edge-commit", - }, - }, - { - name: "edge-container aliases", - args: args{ - imageTypeAliases: []string{"rhel-edge-container"}, - }, - want: wantResult{ - imageTypeName: "edge-container", - }, - }, - { - name: "edge-installer aliases", - args: args{ - imageTypeAliases: []string{"rhel-edge-installer"}, - }, - want: wantResult{ - imageTypeName: "edge-installer", - }, - }, - } - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dist := dist.distro - for _, archName := range dist.ListArches() { - t.Run(archName, func(t *testing.T) { - arch, err := dist.GetArch(archName) - require.Nilf(t, err, - "failed to get architecture '%s', previously listed as supported for the distro '%s'", - archName, dist.Name()) - // Test image type aliases only if the aliased image type is supported for the arch - if _, err = arch.GetImageType(tt.want.imageTypeName); err != nil { - t.Skipf("aliased image type '%s' is not supported for architecture '%s'", - tt.want.imageTypeName, archName) - } - for _, alias := range tt.args.imageTypeAliases { - t.Run(fmt.Sprintf("'%s' alias for image type '%s'", alias, tt.want.imageTypeName), - func(t *testing.T) { - gotImage, err := arch.GetImageType(alias) - require.Nilf(t, err, "arch.GetImageType() for image type alias '%s' failed: %v", - alias, err) - assert.Equalf(t, tt.want.imageTypeName, gotImage.Name(), - "got unexpected image type name for alias '%s'. got = %s, want = %s", - alias, tt.want.imageTypeName, gotImage.Name()) - }) - } - }) - } - }) - } - }) - } -} - -// Check that Manifest() function returns an error for unsupported -// configurations. -func TestDistro_ManifestError(t *testing.T) { - // Currently, the only unsupported configuration is OSTree commit types - // with Kernel boot options - r8distro := rhel8.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Kernel: &blueprint.KernelCustomization{ - Append: "debug", - }, - }, - } - - for _, archName := range r8distro.ListArches() { - arch, _ := r8distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - imgOpts := distro.ImageOptions{ - Size: imgType.Size(0), - } - _, _, err := imgType.Manifest(&bp, imgOpts, nil, 0) - if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types") - } else if imgTypeName == "edge-raw-image" { - assert.EqualError(t, err, "edge raw images require specifying a URL from which to retrieve the OSTree commit") - } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" { - assert.EqualError(t, err, fmt.Sprintf("boot ISO image type \"%s\" requires specifying a URL from which to retrieve the OSTree commit", imgTypeName)) - } else if imgTypeName == "azure-eap7-rhui" { - assert.EqualError(t, err, fmt.Sprintf("image type \"%s\" does not support customizations", imgTypeName)) - } else { - assert.NoError(t, err) - } - } - } -} - -func TestArchitecture_ListImageTypes(t *testing.T) { - imgMap := []struct { - arch string - imgNames []string - rhelAdditionalImageTypes []string - }{ - { - arch: "x86_64", - imgNames: []string{ - "qcow2", - "openstack", - "vhd", - "azure-rhui", - "azure-sap-rhui", - "azure-eap7-rhui", - "vmdk", - "ova", - "ami", - "ec2", - "ec2-ha", - "ec2-sap", - "gce", - "gce-rhui", - "edge-commit", - "edge-container", - "edge-installer", - "edge-raw-image", - "edge-simplified-installer", - "tar", - "image-installer", - "oci", - }, - }, - { - arch: "aarch64", - imgNames: []string{ - "qcow2", - "openstack", - "vhd", - "azure-rhui", - "ami", - "ec2", - "edge-commit", - "edge-container", - "edge-installer", - "edge-simplified-installer", - "edge-raw-image", - "tar", - "image-installer", - }, - }, - { - arch: "ppc64le", - imgNames: []string{ - "qcow2", - "tar", - }, - }, - { - arch: "s390x", - imgNames: []string{ - "qcow2", - "tar", - }, - }, - } - - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, mapping := range imgMap { - arch, err := dist.distro.GetArch(mapping.arch) - require.NoError(t, err) - imageTypes := arch.ListImageTypes() - - var expectedImageTypes []string - expectedImageTypes = append(expectedImageTypes, mapping.imgNames...) - if dist.name == "rhel" { - expectedImageTypes = append(expectedImageTypes, mapping.rhelAdditionalImageTypes...) - } - - require.ElementsMatch(t, expectedImageTypes, imageTypes) - } - }) - } -} - -func TestRHEL8_ListArches(t *testing.T) { - arches := rhel8.New().ListArches() - assert.Equal(t, []string{"aarch64", "ppc64le", "s390x", "x86_64"}, arches) -} - -func TestRHEL8_GetArch(t *testing.T) { - arches := []struct { - name string - errorExpected bool - errorExpectedInCentos bool - }{ - { - name: "x86_64", - }, - { - name: "aarch64", - }, - { - name: "ppc64le", - }, - { - name: "s390x", - }, - { - name: "foo-arch", - errorExpected: true, - }, - } - - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, a := range arches { - actualArch, err := dist.distro.GetArch(a.name) - if a.errorExpected || (a.errorExpectedInCentos && dist.name == "centos") { - assert.Nil(t, actualArch) - assert.Error(t, err) - } else { - assert.Equal(t, a.name, actualArch.Name()) - assert.NoError(t, err) - } - } - }) - } -} - -func TestRhel8_Name(t *testing.T) { - distro := rhel8.New() - assert.Equal(t, "rhel-8", distro.Name()) -} - -func TestRhel8_ModulePlatformID(t *testing.T) { - distro := rhel8.New() - assert.Equal(t, "platform:el8", distro.ModulePlatformID()) -} - -func TestRhel86_KernelOption(t *testing.T) { - distro_test_common.TestDistro_KernelOption(t, rhel8.New()) -} - -func TestRhel8_OSTreeOptions(t *testing.T) { - distro_test_common.TestDistro_OSTreeOptions(t, rhel8.New()) -} - -func TestDistro_CustomFileSystemManifestError(t *testing.T) { - r8distro := rhel8.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/etc", - }, - }, - }, - } - unsupported := map[string]bool{ - "edge-installer": true, - "edge-simplified-installer": true, - "edge-raw-image": true, - "azure-eap7-rhui": true, - } - for _, archName := range r8distro.ListArches() { - arch, _ := r8distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if unsupported[imgTypeName] { - assert.Error(t, err) - } else { - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/etc\"]") - } - } - } -} - -func TestDistro_TestRootMountPoint(t *testing.T) { - r8distro := rhel8.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/", - }, - }, - }, - } - unsupported := map[string]bool{ - "edge-installer": true, - "edge-simplified-installer": true, - "edge-raw-image": true, - "azure-eap7-rhui": true, - } - for _, archName := range r8distro.ListArches() { - arch, _ := r8distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if unsupported[imgTypeName] { - assert.Error(t, err) - } else { - assert.NoError(t, err) - } - } - } -} - -func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { - r8distro := rhel8.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/var/log", - }, - { - MinSize: 1024, - Mountpoint: "/var/log/audit", - }, - }, - }, - } - unsupported := map[string]bool{ - "edge-commit": true, - "edge-container": true, - "edge-installer": true, - "edge-simplified-installer": true, - "edge-raw-image": true, - "azure-eap7-rhui": true, - } - for _, archName := range r8distro.ListArches() { - arch, _ := r8distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if unsupported[imgTypeName] { - assert.Error(t, err) - } else { - assert.NoError(t, err) - } - } - } -} - -func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { - r8distro := rhel8.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/var/a", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b/c", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b/c/d", - }, - }, - }, - } - unsupported := map[string]bool{ - "edge-commit": true, - "edge-container": true, - "edge-installer": true, - "edge-simplified-installer": true, - "edge-raw-image": true, - "azure-eap7-rhui": true, - } - for _, archName := range r8distro.ListArches() { - arch, _ := r8distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if unsupported[imgTypeName] { - assert.Error(t, err) - } else { - assert.NoError(t, err) - } - } - } -} - -func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { - r8distro := rhel8.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "//", - }, - { - MinSize: 1024, - Mountpoint: "/var//", - }, - { - MinSize: 1024, - Mountpoint: "/var//log/audit/", - }, - }, - }, - } - unsupported := map[string]bool{ - "edge-commit": true, - "edge-container": true, - "edge-installer": true, - "edge-simplified-installer": true, - "edge-raw-image": true, - "azure-eap7-rhui": true, - } - for _, archName := range r8distro.ListArches() { - arch, _ := r8distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if unsupported[imgTypeName] { - assert.Error(t, err) - } else { - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"//\" \"/var//\" \"/var//log/audit/\"]") - } - } - } -} - -func TestDistro_CustomFileSystemPatternMatching(t *testing.T) { - r8distro := rhel8.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/variable", - }, - { - MinSize: 1024, - Mountpoint: "/variable/log/audit", - }, - }, - }, - } - unsupported := map[string]bool{ - "edge-installer": true, - "edge-simplified-installer": true, - "edge-raw-image": true, - "azure-eap7-rhui": true, - } - for _, archName := range r8distro.ListArches() { - arch, _ := r8distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if unsupported[imgTypeName] { - assert.Error(t, err) - } else { - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/variable\" \"/variable/log/audit\"]") - } - } - } -} - -func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { - r8distro := rhel8.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/usr", - }, - }, - }, - } - unsupported := map[string]bool{ - "edge-installer": true, - "edge-simplified-installer": true, - "edge-raw-image": true, - "azure-eap7-rhui": true, - } - for _, archName := range r8distro.ListArches() { - arch, _ := r8distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if unsupported[imgTypeName] { - assert.Error(t, err) - } else { - assert.NoError(t, err) - } - } - } -} diff --git a/internal/distro/rhel9/distro_test.go b/internal/distro/rhel9/distro_test.go deleted file mode 100644 index bb227aa3b..000000000 --- a/internal/distro/rhel9/distro_test.go +++ /dev/null @@ -1,848 +0,0 @@ -package rhel9_test - -import ( - "fmt" - "strings" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/distro_test_common" - "github.com/osbuild/osbuild-composer/internal/distro/rhel9" - "github.com/osbuild/osbuild-composer/internal/platform" -) - -type rhelFamilyDistro struct { - name string - distro distro.Distro -} - -var rhelFamilyDistros = []rhelFamilyDistro{ - { - name: "rhel", - distro: rhel9.New(), - }, -} - -func TestFilenameFromType(t *testing.T) { - type args struct { - outputFormat string - } - type wantResult struct { - filename string - mimeType string - wantErr bool - } - tests := []struct { - name string - args args - want wantResult - }{ - { - name: "ami", - args: args{"ami"}, - want: wantResult{ - filename: "image.raw", - mimeType: "application/octet-stream", - }, - }, - { - name: "ec2", - args: args{"ec2"}, - want: wantResult{ - filename: "image.raw.xz", - mimeType: "application/xz", - }, - }, - { - name: "ec2-ha", - args: args{"ec2-ha"}, - want: wantResult{ - filename: "image.raw.xz", - mimeType: "application/xz", - }, - }, - { - name: "ec2-sap", - args: args{"ec2-sap"}, - want: wantResult{ - filename: "image.raw.xz", - mimeType: "application/xz", - }, - }, - { - name: "qcow2", - args: args{"qcow2"}, - want: wantResult{ - filename: "disk.qcow2", - mimeType: "application/x-qemu-disk", - }, - }, - { - name: "openstack", - args: args{"openstack"}, - want: wantResult{ - filename: "disk.qcow2", - mimeType: "application/x-qemu-disk", - }, - }, - { - name: "vhd", - args: args{"vhd"}, - want: wantResult{ - filename: "disk.vhd", - mimeType: "application/x-vhd", - }, - }, - { - name: "azure-rhui", - args: args{"azure-rhui"}, - want: wantResult{ - filename: "disk.vhd.xz", - mimeType: "application/xz", - }, - }, - { - name: "vmdk", - args: args{"vmdk"}, - want: wantResult{ - filename: "disk.vmdk", - mimeType: "application/x-vmdk", - }, - }, - { - name: "ova", - args: args{"ova"}, - want: wantResult{ - filename: "image.ova", - mimeType: "application/ovf", - }, - }, - { - name: "tar", - args: args{"tar"}, - want: wantResult{ - filename: "root.tar.xz", - mimeType: "application/x-tar", - }, - }, - { - name: "image-installer", - args: args{"image-installer"}, - want: wantResult{ - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - }, - }, - { - name: "edge-commit", - args: args{"edge-commit"}, - want: wantResult{ - filename: "commit.tar", - mimeType: "application/x-tar", - }, - }, - // Alias - { - name: "rhel-edge-commit", - args: args{"rhel-edge-commit"}, - want: wantResult{ - filename: "commit.tar", - mimeType: "application/x-tar", - }, - }, - { - name: "edge-container", - args: args{"edge-container"}, - want: wantResult{ - filename: "container.tar", - mimeType: "application/x-tar", - }, - }, - // Alias - { - name: "rhel-edge-container", - args: args{"rhel-edge-container"}, - want: wantResult{ - filename: "container.tar", - mimeType: "application/x-tar", - }, - }, - { - name: "edge-installer", - args: args{"edge-installer"}, - want: wantResult{ - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - }, - }, - // Alias - { - name: "rhel-edge-installer", - args: args{"rhel-edge-installer"}, - want: wantResult{ - filename: "installer.iso", - mimeType: "application/x-iso9660-image", - }, - }, - { - name: "gce", - args: args{"gce"}, - want: wantResult{ - filename: "image.tar.gz", - mimeType: "application/gzip", - }, - }, - { - name: "edge-ami", - args: args{"edge-ami"}, - want: wantResult{ - filename: "image.raw", - mimeType: "application/octet-stream", - }, - }, - { - name: "invalid-output-type", - args: args{"foobar"}, - want: wantResult{wantErr: true}, - }, - } - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dist := dist.distro - arch, _ := dist.GetArch("x86_64") - imgType, err := arch.GetImageType(tt.args.outputFormat) - if (err != nil) != tt.want.wantErr { - t.Errorf("Arch.GetImageType() error = %v, wantErr %v", err, tt.want.wantErr) - return - } - if !tt.want.wantErr { - gotFilename := imgType.Filename() - gotMIMEType := imgType.MIMEType() - if gotFilename != tt.want.filename { - t.Errorf("ImageType.Filename() got = %v, want %v", gotFilename, tt.want.filename) - } - if gotMIMEType != tt.want.mimeType { - t.Errorf("ImageType.MIMEType() got1 = %v, want %v", gotMIMEType, tt.want.mimeType) - } - } - }) - } - }) - } -} - -func TestImageType_BuildPackages(t *testing.T) { - x8664BuildPackages := []string{ - "dnf", - "dosfstools", - "e2fsprogs", - "grub2-efi-x64", - "grub2-pc", - "policycoreutils", - "shim-x64", - "systemd", - "tar", - "qemu-img", - "xz", - } - aarch64BuildPackages := []string{ - "dnf", - "dosfstools", - "e2fsprogs", - "policycoreutils", - "qemu-img", - "systemd", - "tar", - "xz", - } - buildPackages := map[string][]string{ - "x86_64": x8664BuildPackages, - "aarch64": aarch64BuildPackages, - } - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - d := dist.distro - for _, archLabel := range d.ListArches() { - archStruct, err := d.GetArch(archLabel) - if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { - continue - } - for _, itLabel := range archStruct.ListImageTypes() { - itStruct, err := archStruct.GetImageType(itLabel) - if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) { - continue - } - manifest, _, err := itStruct.Manifest(&blueprint.Blueprint{}, distro.ImageOptions{}, nil, 0) - assert.NoError(t, err) - buildPkgs := manifest.GetPackageSetChains()["build"] - assert.NotNil(t, buildPkgs) - assert.Len(t, buildPkgs, 1) - assert.ElementsMatch(t, buildPackages[archLabel], buildPkgs[0].Include) - } - } - }) - } -} - -func TestImageType_Name(t *testing.T) { - imgMap := []struct { - arch string - imgNames []string - }{ - { - arch: "x86_64", - imgNames: []string{ - "qcow2", - "openstack", - "vhd", - "azure-rhui", - "vmdk", - "ova", - "ami", - "ec2", - "ec2-ha", - "ec2-sap", - "edge-commit", - "edge-container", - "edge-installer", - "gce", - "tar", - "image-installer", - }, - }, - { - arch: "aarch64", - imgNames: []string{ - "qcow2", - "openstack", - "ami", - "ec2", - "edge-commit", - "edge-container", - "tar", - "image-installer", - "vhd", - "azure-rhui", - }, - }, - { - arch: "ppc64le", - imgNames: []string{ - "qcow2", - "tar", - }, - }, - { - arch: "s390x", - imgNames: []string{ - "qcow2", - "tar", - }, - }, - } - - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, mapping := range imgMap { - if mapping.arch == platform.ARCH_S390X.String() && dist.name == "centos" { - continue - } - arch, err := dist.distro.GetArch(mapping.arch) - if assert.NoError(t, err) { - for _, imgName := range mapping.imgNames { - if imgName == "edge-commit" && dist.name == "centos" { - continue - } - imgType, err := arch.GetImageType(imgName) - if assert.NoError(t, err) { - assert.Equalf(t, imgName, imgType.Name(), "arch: %s", mapping.arch) - } - } - } - } - }) - } -} - -func TestImageTypeAliases(t *testing.T) { - type args struct { - imageTypeAliases []string - } - type wantResult struct { - imageTypeName string - } - tests := []struct { - name string - args args - want wantResult - }{ - { - name: "edge-commit aliases", - args: args{ - imageTypeAliases: []string{"rhel-edge-commit"}, - }, - want: wantResult{ - imageTypeName: "edge-commit", - }, - }, - { - name: "edge-container aliases", - args: args{ - imageTypeAliases: []string{"rhel-edge-container"}, - }, - want: wantResult{ - imageTypeName: "edge-container", - }, - }, - { - name: "edge-installer aliases", - args: args{ - imageTypeAliases: []string{"rhel-edge-installer"}, - }, - want: wantResult{ - imageTypeName: "edge-installer", - }, - }, - } - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - dist := dist.distro - for _, archName := range dist.ListArches() { - t.Run(archName, func(t *testing.T) { - arch, err := dist.GetArch(archName) - require.Nilf(t, err, - "failed to get architecture '%s', previously listed as supported for the distro '%s'", - archName, dist.Name()) - // Test image type aliases only if the aliased image type is supported for the arch - if _, err = arch.GetImageType(tt.want.imageTypeName); err != nil { - t.Skipf("aliased image type '%s' is not supported for architecture '%s'", - tt.want.imageTypeName, archName) - } - for _, alias := range tt.args.imageTypeAliases { - t.Run(fmt.Sprintf("'%s' alias for image type '%s'", alias, tt.want.imageTypeName), - func(t *testing.T) { - gotImage, err := arch.GetImageType(alias) - require.Nilf(t, err, "arch.GetImageType() for image type alias '%s' failed: %v", - alias, err) - assert.Equalf(t, tt.want.imageTypeName, gotImage.Name(), - "got unexpected image type name for alias '%s'. got = %s, want = %s", - alias, tt.want.imageTypeName, gotImage.Name()) - }) - } - }) - } - }) - } - }) - } -} - -// Check that Manifest() function returns an error for unsupported -// configurations. -func TestDistro_ManifestError(t *testing.T) { - // Currently, the only unsupported configuration is OSTree commit types - // with Kernel boot options - r9distro := rhel9.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Kernel: &blueprint.KernelCustomization{ - Append: "debug", - }, - }, - } - - for _, archName := range r9distro.ListArches() { - arch, _ := r9distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - imgOpts := distro.ImageOptions{ - Size: imgType.Size(0), - } - _, _, err := imgType.Manifest(&bp, imgOpts, nil, 0) - if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types") - } else if imgTypeName == "edge-raw-image" || imgTypeName == "edge-ami" { - assert.EqualError(t, err, fmt.Sprintf("\"%s\" images require specifying a URL from which to retrieve the OSTree commit", imgTypeName)) - } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" { - assert.EqualError(t, err, fmt.Sprintf("boot ISO image type \"%s\" requires specifying a URL from which to retrieve the OSTree commit", imgTypeName)) - } else { - assert.NoError(t, err) - } - } - } -} - -func TestArchitecture_ListImageTypes(t *testing.T) { - imgMap := []struct { - arch string - imgNames []string - rhelAdditionalImageTypes []string - }{ - { - arch: "x86_64", - imgNames: []string{ - "qcow2", - "openstack", - "vhd", - "azure-rhui", - "vmdk", - "ova", - "ami", - "ec2", - "ec2-ha", - "ec2-sap", - "edge-commit", - "edge-container", - "edge-installer", - "edge-raw-image", - "edge-simplified-installer", - "edge-ami", - "gce", - "gce-rhui", - "tar", - "image-installer", - "oci", - }, - }, - { - arch: "aarch64", - imgNames: []string{ - "qcow2", - "openstack", - "ami", - "ec2", - "edge-commit", - "edge-container", - "edge-installer", - "edge-simplified-installer", - "edge-raw-image", - "edge-ami", - "tar", - "image-installer", - "vhd", - "azure-rhui", - }, - }, - { - arch: "ppc64le", - imgNames: []string{ - "qcow2", - "tar", - }, - }, - { - arch: "s390x", - imgNames: []string{ - "qcow2", - "tar", - }, - }, - } - - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, mapping := range imgMap { - arch, err := dist.distro.GetArch(mapping.arch) - require.NoError(t, err) - imageTypes := arch.ListImageTypes() - - var expectedImageTypes []string - expectedImageTypes = append(expectedImageTypes, mapping.imgNames...) - if dist.name == "rhel" { - expectedImageTypes = append(expectedImageTypes, mapping.rhelAdditionalImageTypes...) - } - - require.ElementsMatch(t, expectedImageTypes, imageTypes) - } - }) - } -} - -func TestRhel9_ListArches(t *testing.T) { - arches := rhel9.New().ListArches() - assert.Equal(t, []string{"aarch64", "ppc64le", "s390x", "x86_64"}, arches) -} - -func TestRhel9_GetArch(t *testing.T) { - arches := []struct { - name string - errorExpected bool - errorExpectedInCentos bool - }{ - { - name: "x86_64", - }, - { - name: "aarch64", - }, - { - name: "ppc64le", - }, - { - name: "s390x", - }, - { - name: "foo-arch", - errorExpected: true, - }, - } - - for _, dist := range rhelFamilyDistros { - t.Run(dist.name, func(t *testing.T) { - for _, a := range arches { - actualArch, err := dist.distro.GetArch(a.name) - if a.errorExpected || (a.errorExpectedInCentos && dist.name == "centos") { - assert.Nil(t, actualArch) - assert.Error(t, err) - } else { - assert.Equal(t, a.name, actualArch.Name()) - assert.NoError(t, err) - } - } - }) - } -} - -func TestRhel9_Name(t *testing.T) { - distro := rhel9.New() - assert.Equal(t, "rhel-9", distro.Name()) -} - -func TestRhel9_ModulePlatformID(t *testing.T) { - distro := rhel9.New() - assert.Equal(t, "platform:el9", distro.ModulePlatformID()) -} - -func TestRhel9_KernelOption(t *testing.T) { - distro_test_common.TestDistro_KernelOption(t, rhel9.New()) -} - -func TestRhel9_OSTreeOptions(t *testing.T) { - distro_test_common.TestDistro_OSTreeOptions(t, rhel9.New()) -} - -func TestDistro_CustomFileSystemManifestError(t *testing.T) { - r9distro := rhel9.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/etc", - }, - }, - }, - } - for _, archName := range r9distro.ListArches() { - arch, _ := r9distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" || imgTypeName == "edge-ami" { - continue - } else { - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/etc\"]") - } - } - } -} - -func TestDistro_TestRootMountPoint(t *testing.T) { - r9distro := rhel9.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/", - }, - }, - }, - } - for _, archName := range r9distro.ListArches() { - arch, _ := r9distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" || imgTypeName == "edge-ami" { - continue - } else { - assert.NoError(t, err) - } - } - } -} - -func TestDistro_CustomFileSystemSubDirectories(t *testing.T) { - r9distro := rhel9.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/var/log", - }, - { - MinSize: 1024, - Mountpoint: "/var/log/audit", - }, - }, - }, - } - for _, archName := range r9distro.ListArches() { - arch, _ := r9distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if strings.HasPrefix(imgTypeName, "edge-") { - continue - } else { - assert.NoError(t, err) - } - } - } -} - -func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) { - r9distro := rhel9.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/var/a", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b/c", - }, - { - MinSize: 1024, - Mountpoint: "/var/a/b/c/d", - }, - }, - }, - } - for _, archName := range r9distro.ListArches() { - arch, _ := r9distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if strings.HasPrefix(imgTypeName, "edge-") { - continue - } else { - assert.NoError(t, err) - } - } - } -} - -func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) { - r9distro := rhel9.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "//", - }, - { - MinSize: 1024, - Mountpoint: "/var//", - }, - { - MinSize: 1024, - Mountpoint: "/var//log/audit/", - }, - }, - }, - } - for _, archName := range r9distro.ListArches() { - arch, _ := r9distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if strings.HasPrefix(imgTypeName, "edge-") { - continue - } else { - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"//\" \"/var//\" \"/var//log/audit/\"]") - } - } - } -} - -func TestDistro_CustomFileSystemPatternMatching(t *testing.T) { - r9distro := rhel9.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/variable", - }, - { - MinSize: 1024, - Mountpoint: "/variable/log/audit", - }, - }, - }, - } - for _, archName := range r9distro.ListArches() { - arch, _ := r9distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" || imgTypeName == "edge-ami" { - continue - } else { - assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/variable\" \"/variable/log/audit\"]") - } - } - } -} - -func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) { - r9distro := rhel9.New() - bp := blueprint.Blueprint{ - Customizations: &blueprint.Customizations{ - Filesystem: []blueprint.FilesystemCustomization{ - { - MinSize: 1024, - Mountpoint: "/usr", - }, - }, - }, - } - for _, archName := range r9distro.ListArches() { - arch, _ := r9distro.GetArch(archName) - for _, imgTypeName := range arch.ListImageTypes() { - imgType, _ := arch.GetImageType(imgTypeName) - _, _, err := imgType.Manifest(&bp, distro.ImageOptions{}, nil, 0) - if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { - assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") - } else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" || imgTypeName == "edge-ami" { - continue - } else { - assert.NoError(t, err) - } - } - } -} diff --git a/internal/distroregistry/distroregistry_test.go b/internal/distroregistry/distroregistry_test.go deleted file mode 100644 index 6778194ed..000000000 --- a/internal/distroregistry/distroregistry_test.go +++ /dev/null @@ -1,122 +0,0 @@ -package distroregistry - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/rhel8" -) - -// Test that all distros are registered properly and that Registry.List() works. -func TestRegistry_List(t *testing.T) { - // build expected distros - var expected []string - for _, supportedDistro := range supportedDistros { - d := supportedDistro() - expected = append(expected, d.Name()) - } - - distros := NewDefault() - - require.ElementsMatch(t, expected, distros.List(), "unexpected list of distros") -} - -func TestRegistry_GetDistro(t *testing.T) { - distros := NewDefault() - - t.Run("distro exists", func(t *testing.T) { - expectedDistro := rhel8.New() - require.Equal(t, expectedDistro.Name(), distros.GetDistro(expectedDistro.Name()).Name()) - }) - - t.Run("distro doesn't exist", func(t *testing.T) { - require.Nil(t, distros.GetDistro("toucan-os")) - }) -} - -func TestRegistry_mangleHostDistroName(t *testing.T) { - - type args struct { - name string - isBeta bool - isStream bool - } - - tests := []struct { - name string - args args - want string - }{ - {"fedora-33", args{"fedora-33", false, false}, "fedora-33"}, - {"fedora-33 beta", args{"fedora-33", true, false}, "fedora-33-beta"}, - {"fedora-33 stream", args{"fedora-33", false, true}, "fedora-33"}, - {"fedora-33 beta stream", args{"fedora-33", true, true}, "fedora-33-beta"}, - - {"rhel-8", args{"rhel-8", false, false}, "rhel-8"}, - {"rhel-8 beta", args{"rhel-8", true, false}, "rhel-8-beta"}, - {"rhel-8 stream", args{"rhel-8", false, true}, "rhel-8"}, - {"rhel-8 beta stream", args{"rhel-8", true, true}, "rhel-8-beta"}, - - {"rhel-84", args{"rhel-84", false, false}, "rhel-8"}, - {"rhel-84 beta", args{"rhel-84", true, false}, "rhel-8-beta"}, - {"rhel-84 stream", args{"rhel-84", false, true}, "rhel-8"}, - {"rhel-84 beta stream", args{"rhel-84", true, true}, "rhel-8-beta"}, - - {"centos-8", args{"centos-8", false, false}, "centos-8"}, - {"centos-8 beta", args{"centos-8", true, false}, "centos-8-beta"}, - {"centos-8 stream", args{"centos-8", false, true}, "centos-stream-8"}, - {"centos-8 beta stream", args{"centos-8", true, true}, "centos-8-beta"}, - - {"rhel-90", args{"rhel-90", false, false}, "rhel-90"}, - {"rhel-90 beta", args{"rhel-90", true, false}, "rhel-90-beta"}, - {"rhel-90 stream", args{"rhel-90", false, true}, "rhel-90"}, - {"rhel-90 beta stream", args{"rhel-90", true, true}, "rhel-90-beta"}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - mangledName := mangleHostDistroName(tt.args.name, tt.args.isBeta, tt.args.isStream) - require.Equalf( - t, - tt.want, - mangledName, - "mangleHostDistroName() name:%s, isBeta:%s, isStream:%s =\nExpected: %s\nGot: %s\n", - tt.args.name, - tt.args.isBeta, - tt.args.isStream, - tt.want, - mangledName, - ) - }) - } -} - -func TestRegistry_FromHost(t *testing.T) { - // expected distros - var distros []distro.Distro - for _, supportedDistro := range supportedDistros { - distros = append(distros, supportedDistro()) - } - - t.Run("host distro is nil", func(t *testing.T) { - registry, err := New(nil, distros...) - require.Nil(t, err) - require.NotNil(t, registry) - require.Nil(t, registry.FromHost()) - }) - - t.Run("host distro not nil", func(t *testing.T) { - hostDistro := rhel8.New() - fmt.Println(hostDistro.Name()) - registry, err := New(hostDistro, distros...) - require.Nil(t, err) - require.NotNil(t, registry) - - gotDistro := registry.FromHost() - require.NotNil(t, gotDistro) - require.Equal(t, gotDistro.Name(), hostDistro.Name()) - }) -} diff --git a/internal/dnfjson/cache.go b/internal/dnfjson/cache.go index f55edb6ff..4deca4458 100644 --- a/internal/dnfjson/cache.go +++ b/internal/dnfjson/cache.go @@ -9,7 +9,7 @@ import ( "sync" "time" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/rpmmd" "github.com/gobwas/glob" ) diff --git a/internal/dnfjson/cache_test.go b/internal/dnfjson/cache_test.go index 7943e4d71..7cbe2558c 100644 --- a/internal/dnfjson/cache_test.go +++ b/internal/dnfjson/cache_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/rpmmd" "github.com/stretchr/testify/assert" ) diff --git a/internal/dnfjson/dnfjson.go b/internal/dnfjson/dnfjson.go index e765f372f..809cfc1f7 100644 --- a/internal/dnfjson/dnfjson.go +++ b/internal/dnfjson/dnfjson.go @@ -25,8 +25,8 @@ import ( "strings" "time" - "github.com/osbuild/osbuild-composer/internal/rhsm" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/rhsm" + "github.com/osbuild/images/pkg/rpmmd" ) // BaseSolver defines the basic solver configuration without platform diff --git a/internal/dnfjson/dnfjson_test.go b/internal/dnfjson/dnfjson_test.go index 13229f4dd..67ec0304b 100644 --- a/internal/dnfjson/dnfjson_test.go +++ b/internal/dnfjson/dnfjson_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/common" "github.com/osbuild/osbuild-composer/internal/mocks/rpmrepo" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/stretchr/testify/assert" ) diff --git a/internal/environment/environment.go b/internal/environment/environment.go index 3e6f51ebf..cb0af7a6a 100644 --- a/internal/environment/environment.go +++ b/internal/environment/environment.go @@ -1,6 +1,6 @@ package environment -import "github.com/osbuild/osbuild-composer/internal/rpmmd" +import "github.com/osbuild/images/pkg/rpmmd" type Environment interface { GetPackages() []string diff --git a/internal/manifest/os_test.go b/internal/manifest/os_test.go deleted file mode 100644 index b36dd28fb..000000000 --- a/internal/manifest/os_test.go +++ /dev/null @@ -1,154 +0,0 @@ -package manifest - -import ( - "testing" - - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" - "github.com/osbuild/osbuild-composer/internal/subscription" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -// NewTestOS returns a minimally populated OS struct for use in testing -func NewTestOS() *OS { - repos := []rpmmd.RepoConfig{} - manifest := New() - runner := &runner.Fedora{Version: 37} - build := NewBuild(&manifest, runner, repos) - build.Checkpoint() - - // create an x86_64 platform with bios boot - platform := &platform.X86{ - BIOS: true, - } - - os := NewOS(&manifest, build, platform, repos) - packages := []rpmmd.PackageSpec{ - {Name: "pkg1", Checksum: "sha1:c02524e2bd19490f2a7167958f792262754c5f46"}, - } - os.serializeStart(packages, nil, nil) - - return os -} - -// CheckFirstBootStageOptions checks the Command strings -func CheckFirstBootStageOptions(t *testing.T, stages []*osbuild.Stage, commands []string) { - // Find the FirstBootStage - for _, s := range stages { - if s.Type == "org.osbuild.first-boot" { - require.NotNil(t, s.Options) - options, ok := s.Options.(*osbuild.FirstBootStageOptions) - require.True(t, ok) - require.Equal(t, len(options.Commands), len(commands)) - - // Make sure the commands are the same - for idx, cmd := range commands { - assert.Equal(t, cmd, options.Commands[idx]) - } - } - } -} - -// CheckPkgSetInclude makes sure the packages named in pkgs are all included -func CheckPkgSetInclude(t *testing.T, pkgSetChain []rpmmd.PackageSet, pkgs []string) { - - // Gather up all the includes - var includes []string - for _, ps := range pkgSetChain { - includes = append(includes, ps.Include...) - } - - for _, p := range pkgs { - assert.Contains(t, includes, p) - } -} - -func TestSubscriptionManagerCommands(t *testing.T) { - os := NewTestOS() - os.Subscription = &subscription.ImageOptions{ - Organization: "2040324", - ActivationKey: "my-secret-key", - ServerUrl: "subscription.rhsm.redhat.com", - BaseUrl: "http://cdn.redhat.com/", - } - pipeline := os.serialize() - CheckFirstBootStageOptions(t, pipeline.Stages, []string{ - "/usr/sbin/subscription-manager register --org=2040324 --activationkey=my-secret-key --serverurl subscription.rhsm.redhat.com --baseurl http://cdn.redhat.com/", - }) -} - -func TestSubscriptionManagerInsightsCommands(t *testing.T) { - os := NewTestOS() - os.Subscription = &subscription.ImageOptions{ - Organization: "2040324", - ActivationKey: "my-secret-key", - ServerUrl: "subscription.rhsm.redhat.com", - BaseUrl: "http://cdn.redhat.com/", - Insights: true, - } - pipeline := os.serialize() - CheckFirstBootStageOptions(t, pipeline.Stages, []string{ - "/usr/sbin/subscription-manager register --org=2040324 --activationkey=my-secret-key --serverurl subscription.rhsm.redhat.com --baseurl http://cdn.redhat.com/", - "/usr/bin/insights-client --register", - "restorecon -R /root/.gnupg", - }) -} - -func TestRhcInsightsCommands(t *testing.T) { - os := NewTestOS() - os.Subscription = &subscription.ImageOptions{ - Organization: "2040324", - ActivationKey: "my-secret-key", - ServerUrl: "subscription.rhsm.redhat.com", - BaseUrl: "http://cdn.redhat.com/", - Insights: false, - Rhc: true, - } - pipeline := os.serialize() - CheckFirstBootStageOptions(t, pipeline.Stages, []string{ - "/usr/bin/rhc connect -o=2040324 -a=my-secret-key --server subscription.rhsm.redhat.com", - "restorecon -R /root/.gnupg", - "/usr/sbin/semanage permissive --add rhcd_t", - }) -} - -func TestSubscriptionManagerPackages(t *testing.T) { - os := NewTestOS() - os.Subscription = &subscription.ImageOptions{ - Organization: "2040324", - ActivationKey: "my-secret-key", - ServerUrl: "subscription.rhsm.redhat.com", - BaseUrl: "http://cdn.redhat.com/", - } - - CheckPkgSetInclude(t, os.getPackageSetChain(DISTRO_NULL), []string{"subscription-manager"}) -} - -func TestSubscriptionManagerInsightsPackages(t *testing.T) { - os := NewTestOS() - os.Subscription = &subscription.ImageOptions{ - Organization: "2040324", - ActivationKey: "my-secret-key", - ServerUrl: "subscription.rhsm.redhat.com", - BaseUrl: "http://cdn.redhat.com/", - Insights: true, - } - CheckPkgSetInclude(t, os.getPackageSetChain(DISTRO_NULL), []string{"subscription-manager", "insights-client"}) -} - -func TestRhcInsightsPackages(t *testing.T) { - os := NewTestOS() - os.Subscription = &subscription.ImageOptions{ - Organization: "2040324", - ActivationKey: "my-secret-key", - ServerUrl: "subscription.rhsm.redhat.com", - BaseUrl: "http://cdn.redhat.com/", - Insights: false, - Rhc: true, - } - CheckPkgSetInclude(t, os.getPackageSetChain(DISTRO_NULL), []string{"rhc", "subscription-manager", "insights-client"}) -} diff --git a/internal/mocks/distro/distro_mock.go b/internal/mocks/distro/distro_mock.go index 3c19ed6f6..90621e26e 100644 --- a/internal/mocks/distro/distro_mock.go +++ b/internal/mocks/distro/distro_mock.go @@ -1,8 +1,8 @@ package distro_mock import ( - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" + "github.com/osbuild/images/pkg/distro/test_distro" + "github.com/osbuild/images/pkg/distroregistry" ) func NewDefaultRegistry() (*distroregistry.Registry, error) { diff --git a/internal/mocks/dnfjson/dnfjson.go b/internal/mocks/dnfjson/dnfjson.go index 1c5064e70..b5fd3ca87 100644 --- a/internal/mocks/dnfjson/dnfjson.go +++ b/internal/mocks/dnfjson/dnfjson.go @@ -8,8 +8,8 @@ import ( "path/filepath" "time" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/dnfjson" - "github.com/osbuild/osbuild-composer/internal/rpmmd" ) func generatePackageList() rpmmd.PackageList { diff --git a/internal/mocks/rpmrepo/rpmrepo.go b/internal/mocks/rpmrepo/rpmrepo.go index 7ad3e777b..59bb4a677 100644 --- a/internal/mocks/rpmrepo/rpmrepo.go +++ b/internal/mocks/rpmrepo/rpmrepo.go @@ -6,8 +6,8 @@ import ( "net/http/httptest" "os" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/rpmmd" ) type testRepoServer struct { diff --git a/internal/osbuild/authconfig_stage_test.go b/internal/osbuild/authconfig_stage_test.go deleted file mode 100644 index 19e04ca62..000000000 --- a/internal/osbuild/authconfig_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewAuthconfigStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.authconfig", - Options: &AuthconfigStageOptions{}, - } - actualStage := NewAuthconfigStage(&AuthconfigStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/authselect_stage_test.go b/internal/osbuild/authselect_stage_test.go deleted file mode 100644 index 6ef84ad9b..000000000 --- a/internal/osbuild/authselect_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewAuthselectStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.authselect", - Options: &AuthselectStageOptions{}, - } - actualStage := NewAuthselectStage(&AuthselectStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/chown_stage_test.go b/internal/osbuild/chown_stage_test.go deleted file mode 100644 index 704df970b..000000000 --- a/internal/osbuild/chown_stage_test.go +++ /dev/null @@ -1,244 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewChownStage(t *testing.T) { - stageOptions := &ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "/etc/foobar": { - User: "root", - Group: int64(12345), - Recursive: true, - }, - }, - } - expectedStage := &Stage{ - Type: "org.osbuild.chown", - Options: stageOptions, - } - actualStage := NewChownStage(stageOptions) - assert.Equal(t, expectedStage, actualStage) -} - -func TestChownStageOptionsValidate(t *testing.T) { - validPathOptions := ChownStagePathOptions{ - User: "root", - } - - testCases := []struct { - name string - options *ChownStageOptions - err bool - }{ - { - name: "empty-options", - options: &ChownStageOptions{}, - }, - { - name: "no-items", - options: &ChownStageOptions{ - Items: map[string]ChownStagePathOptions{}, - }, - }, - { - name: "invalid-item-path-1", - options: &ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "": validPathOptions, - }, - }, - err: true, - }, - { - name: "invalid-item-path-2", - options: &ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "foobar": validPathOptions, - }, - }, - err: true, - }, - { - name: "invalid-item-path-3", - options: &ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "/../foobar": validPathOptions, - }, - }, - err: true, - }, - { - name: "invalid-item-path-4", - options: &ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "/etc/../foobar": validPathOptions, - }, - }, - err: true, - }, - { - name: "invalid-item-path-5", - options: &ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "/etc/..": validPathOptions, - }, - }, - err: true, - }, - { - name: "invalid-item-path-6", - options: &ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "../etc/foo/../bar": validPathOptions, - }, - }, - err: true, - }, - { - name: "valid-item-path-1", - options: &ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "/etc/foobar": validPathOptions, - }, - }, - }, - { - name: "valid-item-path-2", - options: &ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "/etc/foo/bar/baz": validPathOptions, - }, - }, - }, - { - name: "valid-item-path-3", - options: &ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "/etc": validPathOptions, - }, - }, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - err := tc.options.validate() - if tc.err { - assert.Error(t, err) - } else { - assert.NoError(t, err) - } - }) - } -} - -func TestChownStagePathOptionsValidate(t *testing.T) { - testCases := []struct { - name string - options ChownStagePathOptions - err bool - }{ - { - name: "empty-options", - options: ChownStagePathOptions{}, - err: true, - }, - { - name: "invalid-user-string-1", - options: ChownStagePathOptions{ - User: "", - }, - err: true, - }, - { - name: "invalid-user-string-2", - options: ChownStagePathOptions{ - User: "r@@t", - }, - err: true, - }, - { - name: "invalid-user-id", - options: ChownStagePathOptions{ - User: int64(-1), - }, - err: true, - }, - { - name: "valid-user-string", - options: ChownStagePathOptions{ - User: "root", - }, - }, - { - name: "valid-user-id", - options: ChownStagePathOptions{ - User: int64(0), - }, - }, - { - name: "invalid-group-string-1", - options: ChownStagePathOptions{ - Group: "", - }, - err: true, - }, - { - name: "invalid-group-string-2", - options: ChownStagePathOptions{ - Group: "r@@t", - }, - err: true, - }, - { - name: "invalid-group-id", - options: ChownStagePathOptions{ - Group: int64(-1), - }, - err: true, - }, - { - name: "valid-group-string", - options: ChownStagePathOptions{ - Group: "root", - }, - }, - { - name: "valid-group-id", - options: ChownStagePathOptions{ - Group: int64(0), - }, - }, - { - name: "valid-both-1", - options: ChownStagePathOptions{ - User: "root", - Group: int64(12345), - Recursive: true, - }, - }, - { - name: "valid-both-2", - options: ChownStagePathOptions{ - User: int64(12345), - Group: "root", - Recursive: true, - }, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - err := tc.options.validate() - if tc.err { - assert.Error(t, err) - } else { - assert.NoError(t, err) - } - }) - } -} diff --git a/internal/osbuild/chrony_stage_test.go b/internal/osbuild/chrony_stage_test.go deleted file mode 100644 index 0fd3aa082..000000000 --- a/internal/osbuild/chrony_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewChronyStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.chrony", - Options: &ChronyStageOptions{}, - } - actualStage := NewChronyStage(&ChronyStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/cloud_init_stage_test.go b/internal/osbuild/cloud_init_stage_test.go deleted file mode 100644 index e7b63daea..000000000 --- a/internal/osbuild/cloud_init_stage_test.go +++ /dev/null @@ -1,216 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" -) - -func TestNewCloudInitStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.cloud-init", - Options: &CloudInitStageOptions{ - Filename: "aaa", - Config: CloudInitConfigFile{ - SystemInfo: &CloudInitConfigSystemInfo{ - DefaultUser: &CloudInitConfigDefaultUser{ - Name: "foo", - }, - }, - }, - }, - } - actualStage := NewCloudInitStage(&CloudInitStageOptions{ - Filename: "aaa", - Config: CloudInitConfigFile{ - SystemInfo: &CloudInitConfigSystemInfo{ - DefaultUser: &CloudInitConfigDefaultUser{ - Name: "foo", - }, - }, - }, - }) - assert.Equal(t, expectedStage, actualStage) -} - -func TestCloudInitStage_NewStage_Invalid(t *testing.T) { - tests := []struct { - name string - options CloudInitStageOptions - }{ - { - name: "empty-options", - options: CloudInitStageOptions{}, - }, - { - name: "no-config-file-section", - options: CloudInitStageOptions{ - Filename: "00-default_user.cfg", - Config: CloudInitConfigFile{}, - }, - }, - { - name: "no-system-info-section-option", - options: CloudInitStageOptions{ - Filename: "00-default_user.cfg", - Config: CloudInitConfigFile{ - SystemInfo: &CloudInitConfigSystemInfo{}, - }, - }, - }, - { - name: "no-default-user-section-option", - options: CloudInitStageOptions{ - Filename: "00-default_user.cfg", - Config: CloudInitConfigFile{ - SystemInfo: &CloudInitConfigSystemInfo{ - DefaultUser: &CloudInitConfigDefaultUser{}, - }, - }, - }, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - assert.Panics(t, func() { NewCloudInitStage(&tt.options) }, "NewCloudInitStage didn't panic, but it should [idx: %d]", idx) - }) - } -} - -func TestCloudInitStage_MarshalJSON(t *testing.T) { - tests := []struct { - name string - options CloudInitStageOptions - json string - }{ - { - name: "simple-cloud-init-config-with-system-info", - options: CloudInitStageOptions{ - Config: CloudInitConfigFile{ - SystemInfo: &CloudInitConfigSystemInfo{ - DefaultUser: &CloudInitConfigDefaultUser{ - Name: "foo", - }, - }, - }, - }, - json: `{"filename":"","config":{"system_info":{"default_user":{"name":"foo"}}}}`, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotBytes, err := json.Marshal(tt.options) - assert.NoError(t, err) - assert.Equal(t, tt.json, string(gotBytes)) - }) - } -} - -func TestCloudInitStage_UnmarshalJSON(t *testing.T) { - tests := []struct { - name string - options CloudInitStageOptions - json string - }{ - { - name: "simple-cloud-init-config-with-system-info", - options: CloudInitStageOptions{ - Config: CloudInitConfigFile{ - SystemInfo: &CloudInitConfigSystemInfo{ - DefaultUser: &CloudInitConfigDefaultUser{ - Name: "foo", - }, - }, - }, - }, - json: `{"filename":"","config":{"system_info":{"default_user":{"name":"foo"}}}}`, - }, - { - name: "osbuild-test-suite-1", - options: CloudInitStageOptions{ - Filename: "10-azure-kfp.cfg", - Config: CloudInitConfigFile{ - Reporting: &CloudInitConfigReporting{ - Logging: &CloudInitConfigReportingHandlers{ - Type: "log", - }, - Telemetry: &CloudInitConfigReportingHandlers{ - Type: "hyperv", - }, - }, - }, - }, - json: `{ - "filename": "10-azure-kfp.cfg", - "config": { - "reporting": { - "logging": { - "type": "log" - }, - "telemetry": { - "type": "hyperv" - } - } - } - }`, - }, - { - name: "osbuild-test-suite-2", - options: CloudInitStageOptions{ - Filename: "91-azure_datasource.cfg", - Config: CloudInitConfigFile{ - DatasourceList: []string{"Azure"}, - Datasource: &CloudInitConfigDatasource{ - Azure: &CloudInitConfigDatasourceAzure{ - ApplyNetworkConfig: false, - }, - }, - }, - }, - json: `{ - "filename": "91-azure_datasource.cfg", - "config": { - "datasource_list": [ - "Azure" - ], - "datasource": { - "Azure": { - "apply_network_config": false - } - } - } - }`, - }, - { - name: "osbuild-test-suite-3", - options: CloudInitStageOptions{ - Filename: "06_logging_override.cfg", - Config: CloudInitConfigFile{ - Output: &CloudInitConfigOutput{ - All: common.ToPtr(">> /var/log/cloud-init-all.log"), - }, - }, - }, - json: `{ - "filename": "06_logging_override.cfg", - "config": { - "output": { - "all": ">> /var/log/cloud-init-all.log" - } - } - }`, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var gotOptions CloudInitStageOptions - err := json.Unmarshal([]byte(tt.json), &gotOptions) - assert.NoError(t, err) - assert.True(t, reflect.DeepEqual(tt.options, gotOptions)) - }) - } -} diff --git a/internal/osbuild/common_test.go b/internal/osbuild/common_test.go deleted file mode 100644 index 913ae53ef..000000000 --- a/internal/osbuild/common_test.go +++ /dev/null @@ -1,342 +0,0 @@ -package osbuild - -import "github.com/osbuild/osbuild-composer/internal/disk" - -// This is a copy of `internal/disk/disk_test.go` -// (but ours has one more entry: "luks+lvm+clevisBind"): -var testPartitionTables = map[string]disk.PartitionTable{ - - "plain": { - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Type: "gpt", - Partitions: []disk.Partition{ - { - Size: 1048576, // 1MB - Bootable: true, - Type: disk.BIOSBootPartitionGUID, - UUID: disk.BIOSBootPartitionUUID, - }, - { - Size: 209715200, // 200 MB - Type: disk.EFISystemPartitionGUID, - UUID: disk.EFISystemPartitionUUID, - Payload: &disk.Filesystem{ - Type: "vfat", - UUID: disk.EFIFilesystemUUID, - Mountpoint: "/boot/efi", - Label: "EFI-SYSTEM", - FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", - FSTabFreq: 0, - FSTabPassNo: 2, - }, - }, - { - Size: 1024000, // 500 MB - Type: disk.FilesystemDataGUID, - UUID: disk.FilesystemDataUUID, - Payload: &disk.Filesystem{ - Type: "xfs", - Mountpoint: "/boot", - Label: "boot", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - { - Type: disk.FilesystemDataGUID, - UUID: disk.RootPartitionUUID, - Payload: &disk.Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - }, - }, - - "luks": { - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Type: "gpt", - Partitions: []disk.Partition{ - { - Size: 1048576, // 1MB - Bootable: true, - Type: disk.BIOSBootPartitionGUID, - UUID: disk.BIOSBootPartitionUUID, - }, - { - Size: 209715200, // 200 MB - Type: disk.EFISystemPartitionGUID, - UUID: disk.EFISystemPartitionUUID, - Payload: &disk.Filesystem{ - Type: "vfat", - UUID: disk.EFIFilesystemUUID, - Mountpoint: "/boot/efi", - Label: "EFI-SYSTEM", - FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", - FSTabFreq: 0, - FSTabPassNo: 2, - }, - }, - { - Size: 1024000, // 500 MB - Type: disk.FilesystemDataGUID, - UUID: disk.FilesystemDataUUID, - Payload: &disk.Filesystem{ - Type: "xfs", - Mountpoint: "/boot", - Label: "boot", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - { - Type: disk.FilesystemDataGUID, - UUID: disk.RootPartitionUUID, - Payload: &disk.LUKSContainer{ - Label: "crypt-root", - Passphrase: "osbuild", - PBKDF: disk.Argon2id{ - Memory: 32, - Iterations: 4, - Parallelism: 1, - }, - Payload: &disk.Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - }, - }, - }, - - "luks+lvm": { - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Type: "gpt", - Partitions: []disk.Partition{ - { - Size: 1048576, // 1MB - Bootable: true, - Type: disk.BIOSBootPartitionGUID, - UUID: disk.BIOSBootPartitionUUID, - }, - { - Size: 209715200, // 200 MB - Type: disk.EFISystemPartitionGUID, - UUID: disk.EFISystemPartitionUUID, - Payload: &disk.Filesystem{ - Type: "vfat", - UUID: disk.EFIFilesystemUUID, - Mountpoint: "/boot/efi", - Label: "EFI-SYSTEM", - FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", - FSTabFreq: 0, - FSTabPassNo: 2, - }, - }, - { - Size: 1024000, // 500 MB - Type: disk.FilesystemDataGUID, - UUID: disk.FilesystemDataUUID, - Payload: &disk.Filesystem{ - Type: "xfs", - Mountpoint: "/boot", - Label: "boot", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - { - Type: disk.FilesystemDataGUID, - UUID: disk.RootPartitionUUID, - Size: 5 * 1024 * 1024 * 1024, - Payload: &disk.LUKSContainer{ - Label: "crypt-root", - Passphrase: "osbuild", - PBKDF: disk.Argon2id{ - Memory: 32, - Iterations: 4, - Parallelism: 1, - }, - Payload: &disk.LVMVolumeGroup{ - Name: "root", - Description: "root volume group", - LogicalVolumes: []disk.LVMLogicalVolume{ - { - Size: 2 * 1024 * 1024 * 1024, - Name: "rootlv", - Payload: &disk.Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - { - Size: 2 * 1024 * 1024 * 1024, - Name: "homelv", - Payload: &disk.Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/home", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - }, - }, - }, - }, - }, - }, - - "luks+lvm+clevisBind": { - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Type: "gpt", - Partitions: []disk.Partition{ - { - Size: 1048576, // 1MB - Bootable: true, - Type: disk.BIOSBootPartitionGUID, - UUID: disk.BIOSBootPartitionUUID, - }, - { - Size: 209715200, // 200 MB - Type: disk.EFISystemPartitionGUID, - UUID: disk.EFISystemPartitionUUID, - Payload: &disk.Filesystem{ - Type: "vfat", - UUID: disk.EFIFilesystemUUID, - Mountpoint: "/boot/efi", - Label: "EFI-SYSTEM", - FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", - FSTabFreq: 0, - FSTabPassNo: 2, - }, - }, - { - Size: 1024000, // 500 MB - Type: disk.FilesystemDataGUID, - UUID: disk.FilesystemDataUUID, - Payload: &disk.Filesystem{ - Type: "xfs", - Mountpoint: "/boot", - Label: "boot", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - { - Type: disk.FilesystemDataGUID, - UUID: disk.RootPartitionUUID, - Payload: &disk.LUKSContainer{ - Label: "crypt_root", - Cipher: "cipher_null", - Passphrase: "osbuild", - PBKDF: disk.Argon2id{ - Memory: 32, - Iterations: 4, - Parallelism: 1, - }, - Clevis: &disk.ClevisBind{ - Pin: "null", - Policy: "{}", - RemovePassphrase: true, - }, - Payload: &disk.LVMVolumeGroup{ - Name: "rootvg", - Description: "built with lvm2 and osbuild", - LogicalVolumes: []disk.LVMLogicalVolume{ - { - Size: 9 * 1024 * 1024 * 1024, // 9 GB - Name: "rootlv", - Payload: &disk.Filesystem{ - Type: "xfs", - Label: "root", - Mountpoint: "/", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - }, - }, - }, - }, - }, - }, - - "btrfs": { - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Type: "gpt", - Partitions: []disk.Partition{ - { - Size: 1048576, // 1MB - Bootable: true, - Type: disk.BIOSBootPartitionGUID, - UUID: disk.BIOSBootPartitionUUID, - }, - { - Size: 209715200, // 200 MB - Type: disk.EFISystemPartitionGUID, - UUID: disk.EFISystemPartitionUUID, - Payload: &disk.Filesystem{ - Type: "vfat", - UUID: disk.EFIFilesystemUUID, - Mountpoint: "/boot/efi", - Label: "EFI-SYSTEM", - FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt", - FSTabFreq: 0, - FSTabPassNo: 2, - }, - }, - { - Size: 1024000, // 500 MB - Type: disk.FilesystemDataGUID, - UUID: disk.FilesystemDataUUID, - Payload: &disk.Filesystem{ - Type: "xfs", - Mountpoint: "/boot", - Label: "boot", - FSTabOptions: "defaults", - FSTabFreq: 0, - FSTabPassNo: 0, - }, - }, - { - Type: disk.FilesystemDataGUID, - UUID: disk.RootPartitionUUID, - Size: 10 * 1024 * 1024 * 1024, - Payload: &disk.Btrfs{ - Label: "rootfs", - Subvolumes: []disk.BtrfsSubvolume{ - { - Size: 0, - Mountpoint: "/", - GroupID: 0, - }, - { - Size: 5 * 1024 * 1024 * 1024, - Mountpoint: "/var", - GroupID: 0, - }, - }, - }, - }, - }, - }, -} diff --git a/internal/osbuild/containers_storage_conf_stage_test.go b/internal/osbuild/containers_storage_conf_stage_test.go deleted file mode 100644 index 1289b029e..000000000 --- a/internal/osbuild/containers_storage_conf_stage_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestContainersStorageConfStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.containers.storage.conf", - Options: &ContainersStorageConfStageOptions{ - Filename: "/usr/share/containers/storage.conf", - Config: ContainersStorageConfig{ - Storage: CSCStorage{ - Options: &CSCStorageOptions{ - AdditionalImageStores: []string{ - "/usr/share/containers/storage/", - }, - }, - }, - }, - }, - } - - actualStage := NewContainersStorageConfStage( - NewContainerStorageOptions("/usr/share/containers/storage.conf", - "/usr/share/containers/storage/"), - ) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/copy_stage_test.go b/internal/osbuild/copy_stage_test.go deleted file mode 100644 index f57ce2f14..000000000 --- a/internal/osbuild/copy_stage_test.go +++ /dev/null @@ -1,71 +0,0 @@ -package osbuild - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewCopyStage(t *testing.T) { - - paths := []CopyStagePath{ - { - From: "input://tree-input/", - To: "mount://root/", - }, - } - - devices := make(map[string]Device) - devices["root"] = Device{ - Type: "org.osbuild.loopback", - Options: LoopbackDeviceOptions{ - Filename: "/somekindofimage.img", - Start: 0, - Size: 1073741824, - }, - } - - mounts := []Mount{ - *NewBtrfsMount("root", "root", "/"), - } - - treeInput := NewTreeInput("name:input-pipeline") - expectedStage := &Stage{ - Type: "org.osbuild.copy", - Options: &CopyStageOptions{paths}, - Inputs: &PipelineTreeInputs{"tree-input": *treeInput}, - Devices: devices, - Mounts: mounts, - } - // convert to alias types - stageMounts := Mounts(mounts) - stageDevices := Devices(devices) - actualStage := NewCopyStage(&CopyStageOptions{paths}, NewPipelineTreeInputs("tree-input", "input-pipeline"), &stageDevices, &stageMounts) - assert.Equal(t, expectedStage, actualStage) -} - -func TestNewCopyStageSimpleSourcesInputs(t *testing.T) { - fileSum := "sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" - - paths := []CopyStagePath{ - { - From: fmt.Sprintf("input://inlinefile/%x", fileSum), - To: "tree://etc/inlinefile", - }, - } - - filesInputs := CopyStageFilesInputs{ - "inlinefile": NewFilesInput(NewFilesInputSourceArrayRef([]FilesInputSourceArrayRefEntry{ - NewFilesInputSourceArrayRefEntry(fileSum, nil), - })), - } - - expectedStage := &Stage{ - Type: "org.osbuild.copy", - Options: &CopyStageOptions{paths}, - Inputs: &filesInputs, - } - actualStage := NewCopyStageSimple(&CopyStageOptions{paths}, &filesInputs) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/device_test.go b/internal/osbuild/device_test.go deleted file mode 100644 index 4b3bdf708..000000000 --- a/internal/osbuild/device_test.go +++ /dev/null @@ -1,141 +0,0 @@ -package osbuild - -import ( - "math/rand" - "testing" - - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/stretchr/testify/assert" -) - -func TestGenDeviceCreationStages(t *testing.T) { - assert := assert.New(t) - - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(rand.NewSource(13)) - - luks_lvm := testPartitionTables["luks+lvm"] - - pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, false, make(map[string]uint64), rng) - assert.NoError(err) - - stages := GenDeviceCreationStages(pt, "image.raw") - - // we should have two stages - assert.Equal(len(stages), 2) - - // first one should be a "org.osbuild.luks2.format" - luks := stages[0] - assert.Equal(luks.Type, "org.osbuild.luks2.format") - - // it needs to have one device - assert.Equal(len(luks.Devices), 1) - - // the device should be called `device` - device, ok := luks.Devices["device"] - assert.True(ok, "Need device called `device`") - - // device should be a loopback device - assert.Equal(device.Type, "org.osbuild.loopback") - - lvm := stages[1] - assert.Equal(lvm.Type, "org.osbuild.lvm2.create") - lvmOptions, ok := lvm.Options.(*LVM2CreateStageOptions) - assert.True(ok, "Need LVM2CreateStageOptions for org.osbuild.lvm2.create") - - // LVM should have two volumes - assert.Equal(len(lvmOptions.Volumes), 2) - rootlv := lvmOptions.Volumes[0] - assert.Equal(rootlv.Name, "rootlv") - - homelv := lvmOptions.Volumes[1] - assert.Equal(homelv.Name, "homelv") - - // it needs to have two(!) devices, the loopback and the luks - assert.Equal(len(lvm.Devices), 2) - - // this is the target one, which should be the luks one - device, ok = lvm.Devices["device"] - assert.True(ok, "Need device called `device`") - assert.Equal(device.Type, "org.osbuild.luks2") - assert.NotEmpty(device.Parent, "Need a parent device for LUKS on loopback") - - luksOptions, ok := device.Options.(*LUKS2DeviceOptions) - assert.True(ok, "Need LUKS2DeviceOptions for luks device") - assert.Equal(luksOptions.Passphrase, "osbuild") - - parent, ok := lvm.Devices[device.Parent] - assert.True(ok, "Need device called `device`") - assert.Equal(parent.Type, "org.osbuild.loopback") - -} - -func TestGenDeviceFinishStages(t *testing.T) { - assert := assert.New(t) - - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(rand.NewSource(13)) - - luks_lvm := testPartitionTables["luks+lvm"] - - pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, false, make(map[string]uint64), rng) - assert.NoError(err) - - stages := GenDeviceFinishStages(pt, "image.raw") - - // we should have one stage - assert.Equal(1, len(stages)) - - // it should be a "org.osbuild.lvm2.metadata" - lvm := stages[0] - assert.Equal("org.osbuild.lvm2.metadata", lvm.Type) - - // it should have two devices - assert.Equal(2, len(lvm.Devices)) - - // this is the target one, which should be the luks one - device, ok := lvm.Devices["device"] - assert.True(ok, "Need device called `device`") - assert.Equal("org.osbuild.luks2", device.Type) - assert.NotEmpty(device.Parent, "Need a parent device for LUKS on loopback") - - luksOptions, ok := device.Options.(*LUKS2DeviceOptions) - assert.True(ok, "Need LUKS2DeviceOptions for luks device") - assert.Equal("osbuild", luksOptions.Passphrase) - - parent, ok := lvm.Devices[device.Parent] - assert.True(ok, "Need device called `device`") - assert.Equal("org.osbuild.loopback", parent.Type) - - opts, ok := lvm.Options.(*LVM2MetadataStageOptions) - assert.True(ok, "Need LVM2MetadataStageOptions for org.osbuild.lvm2.metadata") - assert.Equal("root", opts.VGName) -} - -func TestGenDeviceFinishStagesOrderWithLVMClevisBind(t *testing.T) { - assert := assert.New(t) - - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(rand.NewSource(13)) - - luks_lvm := testPartitionTables["luks+lvm+clevisBind"] - - pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, false, make(map[string]uint64), rng) - assert.NoError(err) - - stages := GenDeviceFinishStages(pt, "image.raw") - - // we should have two stages - assert.Equal(2, len(stages)) - lvm := stages[0] - luks := stages[1] - - // the first one should be "org.osbuild.lvm2.metadata" - assert.Equal("org.osbuild.lvm2.metadata", lvm.Type) - // followed by "org.osbuild.luks2.remove-key" - assert.Equal("org.osbuild.luks2.remove-key", luks.Type) -} diff --git a/internal/osbuild/disk_test.go b/internal/osbuild/disk_test.go deleted file mode 100644 index 1e28d5f04..000000000 --- a/internal/osbuild/disk_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package osbuild - -import ( - "math/rand" - "testing" - - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/stretchr/testify/assert" -) - -func TestGenImageKernelOptions(t *testing.T) { - assert := assert.New(t) - - // math/rand is good enough in this case - /* #nosec G404 */ - rng := rand.New(rand.NewSource(13)) - - luks_lvm := testPartitionTables["luks+lvm"] - - pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, false, make(map[string]uint64), rng) - assert.NoError(err) - - var uuid string - - findLuksUUID := func(e disk.Entity, path []disk.Entity) error { - switch ent := e.(type) { - case *disk.LUKSContainer: - uuid = ent.UUID - } - - return nil - } - _ = pt.ForEachEntity(findLuksUUID) - - assert.NotEmpty(uuid, "Could not find LUKS container") - cmdline := GenImageKernelOptions(pt) - - assert.Subset(cmdline, []string{"luks.uuid=" + uuid}) -} diff --git a/internal/osbuild/dnf_automatic_config_stage_test.go b/internal/osbuild/dnf_automatic_config_stage_test.go deleted file mode 100644 index b6e4ac911..000000000 --- a/internal/osbuild/dnf_automatic_config_stage_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" -) - -func TestNewDNFAutomaticConfigStage(t *testing.T) { - stageOptions := NewDNFAutomaticConfigStageOptions(&DNFAutomaticConfig{}) - expectedStage := &Stage{ - Type: "org.osbuild.dnf-automatic.config", - Options: stageOptions, - } - actualStage := NewDNFAutomaticConfigStage(stageOptions) - assert.Equal(t, expectedStage, actualStage) -} - -func TestDNFAutomaticConfigStageOptionsValidate(t *testing.T) { - tests := []struct { - name string - options DNFAutomaticConfigStageOptions - err bool - }{ - { - name: "empty-options", - options: DNFAutomaticConfigStageOptions{}, - err: false, - }, - { - name: "invalid-upgrade_type", - options: DNFAutomaticConfigStageOptions{ - Config: &DNFAutomaticConfig{ - Commands: &DNFAutomaticConfigCommands{ - ApplyUpdates: common.ToPtr(true), - UpgradeType: "invalid", - }, - }, - }, - err: true, - }, - { - name: "valid-data-1", - options: DNFAutomaticConfigStageOptions{ - Config: &DNFAutomaticConfig{ - Commands: &DNFAutomaticConfigCommands{ - ApplyUpdates: common.ToPtr(true), - UpgradeType: DNFAutomaticUpgradeTypeDefault, - }, - }, - }, - err: false, - }, - { - name: "valid-data-2", - options: DNFAutomaticConfigStageOptions{ - Config: &DNFAutomaticConfig{ - Commands: &DNFAutomaticConfigCommands{ - ApplyUpdates: common.ToPtr(false), - UpgradeType: DNFAutomaticUpgradeTypeSecurity, - }, - }, - }, - err: false, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.err { - assert.Errorf(t, tt.options.validate(), "%q didn't return an error [idx: %d]", tt.name, idx) - assert.Panics(t, func() { NewDNFAutomaticConfigStage(&tt.options) }) - } else { - assert.NoErrorf(t, tt.options.validate(), "%q returned an error [idx: %d]", tt.name, idx) - assert.NotPanics(t, func() { NewDNFAutomaticConfigStage(&tt.options) }) - } - }) - } -} diff --git a/internal/osbuild/dnf_config_stage_test.go b/internal/osbuild/dnf_config_stage_test.go deleted file mode 100644 index 798422586..000000000 --- a/internal/osbuild/dnf_config_stage_test.go +++ /dev/null @@ -1,133 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestNewDNFConfigStageOptions(t *testing.T) { - variables := []DNFVariable{ - { - Name: "release", - Value: "8.4", - }, - } - - dnfconfig := &DNFConfig{ - Main: &DNFConfigMain{ - IPResolve: "4", - }, - } - - expectedOptions := &DNFConfigStageOptions{ - Variables: variables, - Config: dnfconfig, - } - actualOptions := NewDNFConfigStageOptions(variables, dnfconfig) - assert.Equal(t, expectedOptions, actualOptions) -} - -func TestNewDNFConfigStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.dnf.config", - Options: &DNFConfigStageOptions{}, - } - actualStage := NewDNFConfigStage(&DNFConfigStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestJSONDNFConfigStage(t *testing.T) { - expectedOptions := DNFConfigStageOptions{ - Variables: []DNFVariable{ - { - Name: "release", - Value: "8.4", - }, - }, - Config: &DNFConfig{ - Main: &DNFConfigMain{ - IPResolve: "4", - }, - }, - } - - inputString := `{"variables":[{"name":"release","value":"8.4"}],"config":{"main":{"ip_resolve":"4"}}}` - var inputOptions DNFConfigStageOptions - err := json.Unmarshal([]byte(inputString), &inputOptions) - assert.NoError(t, err, "failed to parse JSON dnf config") - assert.True(t, reflect.DeepEqual(expectedOptions, inputOptions)) - - inputBytes, err := json.Marshal(expectedOptions) - assert.NoError(t, err, "failed to marshal YUM config into JSON") - assert.Equal(t, inputString, string(inputBytes)) -} - -func TestDNFConfigValidate(t *testing.T) { - variables := []DNFVariable{ - { - Name: "release", - Value: "8.4", - }, - } - - tests := []struct { - options DNFConfigStageOptions - valid bool - }{ - { - DNFConfigStageOptions{}, - true, - }, - { - DNFConfigStageOptions{ - Variables: variables, - Config: &DNFConfig{ - Main: nil, - }, - }, - true, - }, - { - DNFConfigStageOptions{ - Variables: variables, - Config: &DNFConfig{ - Main: &DNFConfigMain{}, - }, - }, - true, - }, - { - DNFConfigStageOptions{ - Variables: variables, - Config: &DNFConfig{ - Main: &DNFConfigMain{ - IPResolve: "4", - }, - }, - }, - true, - }, - { - DNFConfigStageOptions{ - Variables: variables, - Config: &DNFConfig{ - Main: &DNFConfigMain{ - IPResolve: "urgh", - }, - }, - }, - false, - }, - } - for _, test := range tests { - if test.valid { - require.NotPanics(t, func() { NewDNFConfigStage(&test.options) }) - } else { - require.Panics(t, func() { NewDNFConfigStage(&test.options) }) - } - } -} diff --git a/internal/osbuild/dracut_conf_stage_test.go b/internal/osbuild/dracut_conf_stage_test.go deleted file mode 100644 index e83d09e81..000000000 --- a/internal/osbuild/dracut_conf_stage_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewDracutConfStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.dracut.conf", - Options: &DracutConfStageOptions{}, - } - actualStage := NewDracutConfStage(&DracutConfStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestDracutConfStage_MarshalJSON_Invalid(t *testing.T) { - tests := []struct { - name string - options DracutConfStageOptions - }{ - { - name: "empty-options", - options: DracutConfStageOptions{}, - }, - { - name: "no-options-in-config", - options: DracutConfStageOptions{ - Filename: "testing.conf", - Config: DracutConfigFile{}, - }, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotBytes, err := json.Marshal(tt.options) - assert.NotNilf(t, err, "json.Marshal() didn't return an error, but %s [idx: %d]", string(gotBytes), idx) - }) - } -} diff --git a/internal/osbuild/dracut_stage_test.go b/internal/osbuild/dracut_stage_test.go deleted file mode 100644 index 043bac4a1..000000000 --- a/internal/osbuild/dracut_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewDracutStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.dracut", - Options: &DracutStageOptions{}, - } - actualStage := NewDracutStage(&DracutStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/fdo_stage_test.go b/internal/osbuild/fdo_stage_test.go deleted file mode 100644 index 204ece2c4..000000000 --- a/internal/osbuild/fdo_stage_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewFDOStageForRootCerts(t *testing.T) { - - assert := assert.New(t) - - tests := []struct { - data string - hash string - }{ - {"42\n", "sha256:084c799cd551dd1d8d5c5f9a5d593b2e931f5e36122ee5c793c1d08a19839cc0"}, - {"Hallo Welt\n", "sha256:f950375066d74787f31cbd8f9f91c71819357cad243fb9d4a0d9ef4fa76709e0"}, - } - - for _, tt := range tests { - stage := NewFDOStageForRootCerts(tt.data) - - inputs := stage.Inputs.(*FDOStageInputs) - certs := inputs.RootCerts - refs := certs.References.(*FilesInputSourcePlainRef) - - assert.Len(*refs, 1) - assert.Equal((*refs)[0], tt.hash) - - } -} diff --git a/internal/osbuild/files_input_test.go b/internal/osbuild/files_input_test.go deleted file mode 100644 index 7f637c97f..000000000 --- a/internal/osbuild/files_input_test.go +++ /dev/null @@ -1,93 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestFilesInput_UnmarshalJSON(t *testing.T) { - testCases := []struct { - name string - ref FilesInputRef - rawJson []byte - }{ - { - name: "pipeline-object-ref", - ref: NewFilesInputPipelineObjectRef("os", "image.raw", nil), - rawJson: []byte(`{"type":"org.osbuild.files","origin":"org.osbuild.pipeline","references":{"name:os":{"file":"image.raw"}}}`), - }, - { - name: "pipeline-array-ref", - ref: NewFilesInputPipelineArrayRef("os", "image.raw", nil), - rawJson: []byte(`{"type":"org.osbuild.files","origin":"org.osbuild.pipeline","references":[{"id":"name:os","options":{"file":"image.raw"}}]}`), - }, - { - name: "source-plain-ref", - ref: NewFilesInputSourcePlainRef([]string{"sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"}), - rawJson: []byte(`{"type":"org.osbuild.files","origin":"org.osbuild.source","references":["sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"]}`), - }, - { - name: "source-array-ref", - ref: NewFilesInputSourceArrayRef([]FilesInputSourceArrayRefEntry{ - NewFilesInputSourceArrayRefEntry("sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", nil), - }), - rawJson: []byte(`{"type":"org.osbuild.files","origin":"org.osbuild.source","references":[{"id":"sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"}]}`), - }, - { - name: "source-object-ref", - ref: NewFilesInputSourceObjectRef(map[string]FilesInputRefMetadata{ - "sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef": nil, - }), - rawJson: []byte(`{"type":"org.osbuild.files","origin":"org.osbuild.source","references":{"sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef":{}}}`), - }, - } - - for _, tt := range testCases { - t.Run(tt.name, func(t *testing.T) { - var gotInput FilesInput - err := json.Unmarshal(tt.rawJson, &gotInput) - assert.NoErrorf(t, err, "FilesInput.UnmarshalJSON() error = %v", err) - - input := NewFilesInput(tt.ref) - gotBytes, err := json.Marshal(input) - assert.NoErrorf(t, err, "FilesInput.MarshalJSON() error = %v", err) - - assert.EqualValuesf(t, tt.rawJson, gotBytes, "Expected JSON `%v`, got JSON `%v`", string(tt.rawJson), string(gotBytes)) - assert.EqualValuesf(t, input, &gotInput, "Expected input `%v`, got input `%v` [test: %q]", input, &gotInput, tt.name) - }) - } - - // test invalid cases - invalidTestCases := []struct { - name string - rawJson []byte - }{ - { - name: "invalid-pipeline-ref", - rawJson: []byte(`{"type":"org.osbuild.files","origin":"org.osbuild.pipeline","references":1}`), - }, - { - name: "invalid-source-ref", - rawJson: []byte(`{"type":"org.osbuild.files","origin":"org.osbuild.source","references":2}`), - }, - { - name: "invalid-origin", - rawJson: []byte(`{"type":"org.osbuild.files","origin":"org.osbuild.invalid","references":{}}`), - }, - { - name: "invalid-input", - rawJson: []byte(`[]`), - }, - } - - for _, tt := range invalidTestCases { - t.Run(tt.name, func(t *testing.T) { - var gotInput FilesInput - err := json.Unmarshal(tt.rawJson, &gotInput) - assert.Error(t, err) - }) - } - -} diff --git a/internal/osbuild/firewall_stage_test.go b/internal/osbuild/firewall_stage_test.go deleted file mode 100644 index e4e64b4e3..000000000 --- a/internal/osbuild/firewall_stage_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewFirewallStage(t *testing.T) { - expectedFirewall := &Stage{ - Type: "org.osbuild.firewall", - Options: &FirewallStageOptions{}, - } - actualFirewall := NewFirewallStage(&FirewallStageOptions{}) - assert.Equal(t, expectedFirewall, actualFirewall) -} - -func TestFirewallStageZones_ValidateInvalid(t *testing.T) { - options := FirewallStageOptions{} - var sources []string - options.Zones = append(options.Zones, FirewallZone{ - Name: "", - Sources: sources, - }) - assert := assert.New(t) - assert.Error(options.validate()) -} diff --git a/internal/osbuild/first_boot_stage_test.go b/internal/osbuild/first_boot_stage_test.go deleted file mode 100644 index b2f62cadf..000000000 --- a/internal/osbuild/first_boot_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewFirstBootStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.first-boot", - Options: &FirstBootStageOptions{}, - } - actualStage := NewFirstBootStage(&FirstBootStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/fix_bls_stage_test.go b/internal/osbuild/fix_bls_stage_test.go deleted file mode 100644 index c888ccb72..000000000 --- a/internal/osbuild/fix_bls_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewFixBLSStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.fix-bls", - Options: &FixBLSStageOptions{}, - } - actualStage := NewFixBLSStage(&FixBLSStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/fsnode_test.go b/internal/osbuild/fsnode_test.go deleted file mode 100644 index 4f3ecab9f..000000000 --- a/internal/osbuild/fsnode_test.go +++ /dev/null @@ -1,272 +0,0 @@ -package osbuild - -import ( - "crypto/sha256" - "fmt" - "os" - "testing" - - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/fsnode" - "github.com/stretchr/testify/assert" -) - -func TestGenFileNodesStages(t *testing.T) { - fileData1 := []byte("hello world") - fileData2 := []byte("hello world 2") - - ensureFileCreation := func(file *fsnode.File, err error) *fsnode.File { - t.Helper() - assert.NoError(t, err) - assert.NotNil(t, file) - return file - } - - testCases := []struct { - name string - files []*fsnode.File - expected []*Stage - }{ - { - name: "empty-files-list", - files: []*fsnode.File{}, - expected: nil, - }, - { - name: "nil-files-list", - files: nil, - expected: nil, - }, - { - name: "single-file-simple", - files: []*fsnode.File{ - ensureFileCreation(fsnode.NewFile("/etc/file", nil, nil, nil, []byte(fileData1))), - }, - expected: []*Stage{ - NewCopyStageSimple(&CopyStageOptions{ - Paths: []CopyStagePath{ - { - From: fmt.Sprintf("input://file-%[1]x/sha256:%[1]x", sha256.Sum256(fileData1)), - To: "tree:///etc/file", - RemoveDestination: true, - }, - }, - }, &CopyStageFilesInputs{ - fmt.Sprintf("file-%x", sha256.Sum256(fileData1)): NewFilesInput(NewFilesInputSourceArrayRef([]FilesInputSourceArrayRefEntry{ - NewFilesInputSourceArrayRefEntry(fmt.Sprintf("sha256:%x", sha256.Sum256(fileData1)), nil), - })), - }), - }, - }, - { - name: "multiple-files-simple", - files: []*fsnode.File{ - ensureFileCreation(fsnode.NewFile("/etc/file", nil, nil, nil, []byte(fileData1))), - ensureFileCreation(fsnode.NewFile("/etc/file2", nil, nil, nil, []byte(fileData2))), - }, - expected: []*Stage{ - NewCopyStageSimple(&CopyStageOptions{ - Paths: []CopyStagePath{ - { - From: fmt.Sprintf("input://file-%[1]x/sha256:%[1]x", sha256.Sum256(fileData1)), - To: "tree:///etc/file", - RemoveDestination: true, - }, - { - From: fmt.Sprintf("input://file-%[1]x/sha256:%[1]x", sha256.Sum256(fileData2)), - To: "tree:///etc/file2", - RemoveDestination: true, - }, - }, - }, &CopyStageFilesInputs{ - fmt.Sprintf("file-%x", sha256.Sum256(fileData1)): NewFilesInput(NewFilesInputSourceArrayRef([]FilesInputSourceArrayRefEntry{ - NewFilesInputSourceArrayRefEntry(fmt.Sprintf("sha256:%x", sha256.Sum256(fileData1)), nil), - })), - fmt.Sprintf("file-%x", sha256.Sum256(fileData2)): NewFilesInput(NewFilesInputSourceArrayRef([]FilesInputSourceArrayRefEntry{ - NewFilesInputSourceArrayRefEntry(fmt.Sprintf("sha256:%x", sha256.Sum256(fileData2)), nil), - })), - }), - }, - }, - { - name: "multiple-files-with-all-options", - files: []*fsnode.File{ - ensureFileCreation(fsnode.NewFile("/etc/file", common.ToPtr(os.FileMode(0644)), "root", int64(12345), []byte(fileData1))), - ensureFileCreation(fsnode.NewFile("/etc/file2", common.ToPtr(os.FileMode(0755)), int64(12345), "root", []byte(fileData2))), - }, - expected: []*Stage{ - NewCopyStageSimple(&CopyStageOptions{ - Paths: []CopyStagePath{ - { - From: fmt.Sprintf("input://file-%[1]x/sha256:%[1]x", sha256.Sum256(fileData1)), - To: "tree:///etc/file", - RemoveDestination: true, - }, - { - From: fmt.Sprintf("input://file-%[1]x/sha256:%[1]x", sha256.Sum256(fileData2)), - To: "tree:///etc/file2", - RemoveDestination: true, - }, - }, - }, &CopyStageFilesInputs{ - fmt.Sprintf("file-%x", sha256.Sum256(fileData1)): NewFilesInput(NewFilesInputSourceArrayRef([]FilesInputSourceArrayRefEntry{ - NewFilesInputSourceArrayRefEntry(fmt.Sprintf("sha256:%x", sha256.Sum256(fileData1)), nil), - })), - fmt.Sprintf("file-%x", sha256.Sum256(fileData2)): NewFilesInput(NewFilesInputSourceArrayRef([]FilesInputSourceArrayRefEntry{ - NewFilesInputSourceArrayRefEntry(fmt.Sprintf("sha256:%x", sha256.Sum256(fileData2)), nil), - })), - }), - NewChmodStage(&ChmodStageOptions{ - Items: map[string]ChmodStagePathOptions{ - "/etc/file": { - Mode: fmt.Sprintf("%#o", os.FileMode(0644)), - }, - "/etc/file2": { - Mode: fmt.Sprintf("%#o", os.FileMode(0755)), - }, - }, - }), - NewChownStage(&ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "/etc/file": { - User: "root", - Group: int64(12345), - }, - "/etc/file2": { - User: int64(12345), - Group: "root", - }, - }, - }), - }, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - gotStages := GenFileNodesStages(tc.files) - assert.EqualValues(t, tc.expected, gotStages) - }) - } -} - -func TestGenDirectoryNodesStages(t *testing.T) { - - ensureDirCreation := func(dir *fsnode.Directory, err error) *fsnode.Directory { - t.Helper() - assert.NoError(t, err) - assert.NotNil(t, dir) - return dir - } - - testCases := []struct { - name string - dirs []*fsnode.Directory - expected []*Stage - }{ - { - name: "empty-dirs-list", - dirs: []*fsnode.Directory{}, - expected: nil, - }, - { - name: "nil-dirs-list", - dirs: nil, - expected: nil, - }, - { - name: "single-dir-simple", - dirs: []*fsnode.Directory{ - ensureDirCreation(fsnode.NewDirectory("/etc/dir", nil, nil, nil, false)), - }, - expected: []*Stage{ - NewMkdirStage(&MkdirStageOptions{ - Paths: []MkdirStagePath{ - { - Path: "/etc/dir", - ExistOk: true, - }, - }, - }), - }, - }, - { - name: "multiple-dirs-simple", - dirs: []*fsnode.Directory{ - ensureDirCreation(fsnode.NewDirectory("/etc/dir", nil, nil, nil, false)), - ensureDirCreation(fsnode.NewDirectory("/etc/dir2", nil, nil, nil, false)), - }, - expected: []*Stage{ - NewMkdirStage(&MkdirStageOptions{ - Paths: []MkdirStagePath{ - { - Path: "/etc/dir", - ExistOk: true, - }, - { - Path: "/etc/dir2", - ExistOk: true, - }, - }, - }), - }, - }, - { - name: "multiple-dirs-with-all-options", - dirs: []*fsnode.Directory{ - ensureDirCreation(fsnode.NewDirectory("/etc/dir", common.ToPtr(os.FileMode(0700)), "root", int64(12345), true)), - ensureDirCreation(fsnode.NewDirectory("/etc/dir2", common.ToPtr(os.FileMode(0755)), int64(12345), "root", false)), - ensureDirCreation(fsnode.NewDirectory("/etc/dir3", nil, nil, nil, true)), - }, - expected: []*Stage{ - NewMkdirStage(&MkdirStageOptions{ - Paths: []MkdirStagePath{ - { - Path: "/etc/dir", - Parents: true, - ExistOk: false, - }, - { - Path: "/etc/dir2", - ExistOk: false, - }, - { - Path: "/etc/dir3", - Parents: true, - ExistOk: true, - }, - }, - }), - NewChmodStage(&ChmodStageOptions{ - Items: map[string]ChmodStagePathOptions{ - "/etc/dir": { - Mode: fmt.Sprintf("%#o", os.FileMode(0700)), - }, - "/etc/dir2": { - Mode: fmt.Sprintf("%#o", os.FileMode(0755)), - }, - }, - }), - NewChownStage(&ChownStageOptions{ - Items: map[string]ChownStagePathOptions{ - "/etc/dir": { - User: "root", - Group: int64(12345), - }, - "/etc/dir2": { - User: int64(12345), - Group: "root", - }, - }, - }), - }, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - gotStages := GenDirectoryNodesStages(tc.dirs) - assert.EqualValues(t, tc.expected, gotStages) - }) - } -} diff --git a/internal/osbuild/fstab_stage_test.go b/internal/osbuild/fstab_stage_test.go deleted file mode 100644 index e8b6fc223..000000000 --- a/internal/osbuild/fstab_stage_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewFSTabStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.fstab", - Options: &FSTabStageOptions{}, - } - actualStage := NewFSTabStage(&FSTabStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestAddFilesystem(t *testing.T) { - options := &FSTabStageOptions{} - filesystems := []*FSTabEntry{ - { - UUID: "76a22bf4-f153-4541-b6c7-0332c0dfaeac", - VFSType: "ext4", - Path: "/", - Options: "defaults", - Freq: 1, - PassNo: 1, - }, - { - UUID: "bba22bf4-f153-4541-b6c7-0332c0dfaeac", - VFSType: "xfs", - Path: "/home", - Options: "defaults", - Freq: 1, - PassNo: 2, - }, - { - UUID: "cca22bf4-f153-4541-b6c7-0332c0dfaeac", - VFSType: "xfs", - Path: "/var", - Options: "defaults", - Freq: 1, - PassNo: 1, - }, - } - - for i, fs := range filesystems { - options.AddFilesystem(fs.UUID, fs.VFSType, fs.Path, fs.Options, fs.Freq, fs.PassNo) - assert.Equal(t, options.FileSystems[i], fs) - } - assert.Equal(t, len(filesystems), len(options.FileSystems)) -} diff --git a/internal/osbuild/gcp_guest_agent_conf_stage_test.go b/internal/osbuild/gcp_guest_agent_conf_stage_test.go deleted file mode 100644 index 6b1a4e768..000000000 --- a/internal/osbuild/gcp_guest_agent_conf_stage_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewGcpGuestAgentConfigOptionsValidate(t *testing.T) { - tests := []struct { - name string - options GcpGuestAgentConfigOptions - err bool - }{ - { - name: "empty-config", - options: GcpGuestAgentConfigOptions{}, - err: true, - }, - { - name: "empty-config", - options: GcpGuestAgentConfigOptions{ - ConfigScope: GcpGuestAgentConfigScopeDistro, - Config: &GcpGuestAgentConfig{}, - }, - err: true, - }, - { - name: "invalid-ConfigScope", - options: GcpGuestAgentConfigOptions{ - ConfigScope: "incorrect", - Config: &GcpGuestAgentConfig{ - Accounts: &GcpGuestAgentConfigAccounts{ - Groups: []string{"group1", "group2"}, - }, - }, - }, - err: true, - }, - { - name: "valid-data", - options: GcpGuestAgentConfigOptions{ - ConfigScope: GcpGuestAgentConfigScopeDistro, - Config: &GcpGuestAgentConfig{ - Accounts: &GcpGuestAgentConfigAccounts{ - Groups: []string{"group1", "group2"}, - }, - }, - }, - err: false, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.err { - assert.Errorf(t, tt.options.validate(), "%q didn't return an error [idx: %d]", tt.name, idx) - assert.Panics(t, func() { NewGcpGuestAgentConfigStage(&tt.options) }) - } else { - assert.NoErrorf(t, tt.options.validate(), "%q returned an error [idx: %d]", tt.name, idx) - assert.NotPanics(t, func() { NewGcpGuestAgentConfigStage(&tt.options) }) - } - }) - } -} -func TestNewGcpGuestAgentConfigStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.gcp.guest-agent.conf", - Options: &GcpGuestAgentConfigOptions{ - Config: &GcpGuestAgentConfig{ - Accounts: &GcpGuestAgentConfigAccounts{ - Groups: []string{"group1", "group2"}, - }, - }, - }, - } - actualStage := NewGcpGuestAgentConfigStage(&GcpGuestAgentConfigOptions{ - Config: &GcpGuestAgentConfig{ - Accounts: &GcpGuestAgentConfigAccounts{ - Groups: []string{"group1", "group2"}, - }, - }, - }) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/groups_stage_test.go b/internal/osbuild/groups_stage_test.go deleted file mode 100644 index 271f85583..000000000 --- a/internal/osbuild/groups_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewGroupsStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.groups", - Options: &GroupsStageOptions{}, - } - actualStage := NewGroupsStage(&GroupsStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/grub2_inst_stage_test.go b/internal/osbuild/grub2_inst_stage_test.go deleted file mode 100644 index 6aaa31c05..000000000 --- a/internal/osbuild/grub2_inst_stage_test.go +++ /dev/null @@ -1,113 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" -) - -func TestNewGrub2InstStage(t *testing.T) { - options := Grub2InstStageOptions{ - Filename: "img.raw", - Platform: "i386-pc", - Location: 2048, - Core: CoreMkImage{ - Type: "mkimage", - PartLabel: "gpt", - Filesystem: "ext4", - }, - Prefix: PrefixPartition{ - Type: "partition", - PartLabel: "gpt", - Number: 1, - Path: "/boot/grub2", - }, - SectorSize: common.ToPtr(uint64(512)), - } - - expectedStage := &Stage{ - Type: "org.osbuild.grub2.inst", - Options: &options, - } - - actualStage := NewGrub2InstStage(&options) - assert.Equal(t, expectedStage, actualStage) -} - -func TestMarshalGrub2InstStage(t *testing.T) { - goodOptions := func() Grub2InstStageOptions { - return Grub2InstStageOptions{ - Filename: "img.raw", - Platform: "i386-pc", - Location: 2048, - Core: CoreMkImage{ - Type: "mkimage", - PartLabel: "gpt", - Filesystem: "ext4", - }, - Prefix: PrefixPartition{ - Type: "partition", - PartLabel: "gpt", - Number: 1, - Path: "/boot/grub2", - }, - SectorSize: common.ToPtr(uint64(512)), - } - } - - { - options := goodOptions() - - stage := NewGrub2InstStage(&options) - _, err := json.Marshal(stage) - assert.NoError(t, err) - } - - { - options := goodOptions() - options.Core.Type = "notmkimage" - - stage := NewGrub2InstStage(&options) - _, err := json.Marshal(stage) - assert.Error(t, err) - } - - { - options := goodOptions() - options.Core.PartLabel = "notgpt" - - stage := NewGrub2InstStage(&options) - _, err := json.Marshal(stage) - assert.Error(t, err) - } - - { - options := goodOptions() - options.Core.Filesystem = "apfs" - - stage := NewGrub2InstStage(&options) - _, err := json.Marshal(stage) - assert.Error(t, err) - } - - { - options := goodOptions() - options.Prefix.Type = "notpartition" - - stage := NewGrub2InstStage(&options) - _, err := json.Marshal(stage) - assert.Error(t, err) - } - - { - options := goodOptions() - options.Prefix.PartLabel = "notdos" - - stage := NewGrub2InstStage(&options) - _, err := json.Marshal(stage) - assert.Error(t, err) - } -} diff --git a/internal/osbuild/grub2_legacy_stage_test.go b/internal/osbuild/grub2_legacy_stage_test.go deleted file mode 100644 index da74ec082..000000000 --- a/internal/osbuild/grub2_legacy_stage_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestGrub2LegacyStage_Validation(t *testing.T) { - - options := GRUB2LegacyStageOptions{} - - err := options.validate() - assert.Error(t, err) - - options.RootFS.Device = "/dev/sda" - err = options.validate() - assert.Error(t, err) - - prod := GRUB2Product{ - Name: "Fedora", - Nick: "Foo", - Version: "1", - } - options.Entries = MakeGrub2MenuEntries("id", "kernel", prod, false) - err = options.validate() - assert.Error(t, err) - - options.BIOS = &GRUB2BIOS{ - Platform: "i386-pc", - } - err = options.validate() - assert.NoError(t, err) -} diff --git a/internal/osbuild/grub2_stage_test.go b/internal/osbuild/grub2_stage_test.go deleted file mode 100644 index 2f53daf0c..000000000 --- a/internal/osbuild/grub2_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewGRUB2Stage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.grub2", - Options: &GRUB2StageOptions{}, - } - actualStage := NewGRUB2Stage(&GRUB2StageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/hostname_stage_test.go b/internal/osbuild/hostname_stage_test.go deleted file mode 100644 index 6abe8c6f8..000000000 --- a/internal/osbuild/hostname_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewHostnameStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.hostname", - Options: &HostnameStageOptions{}, - } - actualStage := NewHostnameStage(&HostnameStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/inline_source_test.go b/internal/osbuild/inline_source_test.go deleted file mode 100644 index cb3ef9a11..000000000 --- a/internal/osbuild/inline_source_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestInlineSource(t *testing.T) { - - assert := assert.New(t) - - tests := []struct { - data string - hash string - encoded string - }{ - {"42\n", "sha256:084c799cd551dd1d8d5c5f9a5d593b2e931f5e36122ee5c793c1d08a19839cc0", "NDIK"}, - {"Hallo Welt\n", "sha256:f950375066d74787f31cbd8f9f91c71819357cad243fb9d4a0d9ef4fa76709e0", "SGFsbG8gV2VsdAo="}, - } - - ils := NewInlineSource() - - for _, tt := range tests { - hash := ils.AddItem(tt.data) - assert.Equal(tt.hash, hash) - - item := ils.Items[hash] - assert.Equal(item.Data, tt.encoded) - } - -} diff --git a/internal/osbuild/kernel_cmdline_stage_test.go b/internal/osbuild/kernel_cmdline_stage_test.go deleted file mode 100644 index aa2149e14..000000000 --- a/internal/osbuild/kernel_cmdline_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewKernelCmdlineStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.kernel-cmdline", - Options: &KernelCmdlineStageOptions{}, - } - actualStage := NewKernelCmdlineStage(&KernelCmdlineStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/keymap_stage_test.go b/internal/osbuild/keymap_stage_test.go deleted file mode 100644 index 833dbb267..000000000 --- a/internal/osbuild/keymap_stage_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewKeymapStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.keymap", - Options: &KeymapStageOptions{}, - } - actualStage := NewKeymapStage(&KeymapStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestKeymapStage_MarshalJSON_Invalid(t *testing.T) { - tests := []struct { - name string - options KeymapStageOptions - }{ - { - name: "x11-keymap-empty-layout-list", - options: KeymapStageOptions{ - X11Keymap: &X11KeymapOptions{}, - }, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotBytes, err := json.Marshal(tt.options) - assert.NotNilf(t, err, "json.Marshal() didn't return an error, but: %s [idx: %d]", string(gotBytes), idx) - }) - } -} diff --git a/internal/osbuild/locale_stage_test.go b/internal/osbuild/locale_stage_test.go deleted file mode 100644 index f3a15e6f0..000000000 --- a/internal/osbuild/locale_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewLocaleStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.locale", - Options: &LocaleStageOptions{}, - } - actualStage := NewLocaleStage(&LocaleStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/lvm2_create_stage_test.go b/internal/osbuild/lvm2_create_stage_test.go deleted file mode 100644 index 93bf24309..000000000 --- a/internal/osbuild/lvm2_create_stage_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewLVM2CreateStageValidation(t *testing.T) { - assert := assert.New(t) - - okOptions := LVM2CreateStageOptions{ - Volumes: []LogicalVolume{ - { - Name: "a_volume_name", - Size: "", - }, - { - Name: "good-volume.name", - Size: "10G", - }, - { - Name: "99-luft+volumes", - Size: "10737418240", - }, - { - Name: "++", - Size: "1337", - }, - { - Name: "_", - Size: "0", - }, - }, - } - assert.NoError(okOptions.validate()) - - badVolumes := []LogicalVolume{ - { - Name: "!bad-bad-volume-name", - Size: "1337", - }, - { - Name: "even worse", - }, - { - Name: "-", - }, - } - - for _, vol := range badVolumes { - options := LVM2CreateStageOptions{ - Volumes: []LogicalVolume{vol}, - } - assert.Error(options.validate(), vol.Name) - } - - empty := LVM2CreateStageOptions{} - assert.Error(empty.validate()) -} diff --git a/internal/osbuild/lvm2_lv_device_test.go b/internal/osbuild/lvm2_lv_device_test.go deleted file mode 100644 index cdc397c38..000000000 --- a/internal/osbuild/lvm2_lv_device_test.go +++ /dev/null @@ -1 +0,0 @@ -package osbuild diff --git a/internal/osbuild/lvm2_metadata_stage_test.go b/internal/osbuild/lvm2_metadata_stage_test.go deleted file mode 100644 index a5cab60c6..000000000 --- a/internal/osbuild/lvm2_metadata_stage_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewLVM2MetadataStageValidation(t *testing.T) { - assert := assert.New(t) - - okOptions := []LVM2MetadataStageOptions{ - { - VGName: "a_volume_name", - CreationTime: "0", - }, - { - VGName: "good-volume.name", - CreationTime: "1629282647", - }, - { - VGName: "99-luft+volumes", - CreationTime: "2147483648", - }, - { - VGName: "++", - CreationTime: "42", - }, - { - VGName: "_", - CreationTime: "4294967297", - }, - } - for _, o := range okOptions { - assert.NoError(o.validate(), o) - } - - badOptions := []LVM2MetadataStageOptions{ - { - VGName: "ok-name-bad-time", - CreationTime: "-10", - }, - { - VGName: "!bad-name", - CreationTime: "1629282647", - }, - { - VGName: "worse.time", - CreationTime: "TIME", - }, - } - for _, o := range badOptions { - assert.Error(o.validate(), o) - } -} diff --git a/internal/osbuild/mkfs_stages_test.go b/internal/osbuild/mkfs_stages_test.go deleted file mode 100644 index e8035a904..000000000 --- a/internal/osbuild/mkfs_stages_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/google/uuid" - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" -) - -func TestNewMkfsStage(t *testing.T) { - devOpts := LoopbackDeviceOptions{ - Filename: "file.img", - Start: 0, - Size: 1024, - SectorSize: common.ToPtr(uint64(512)), - } - device := NewLoopbackDevice(&devOpts) - - devices := map[string]Device{ - "device": *device, - } - - btrfsOptions := &MkfsBtrfsStageOptions{ - UUID: uuid.New().String(), - Label: "test", - } - mkbtrfs := NewMkfsBtrfsStage(btrfsOptions, devices) - mkbtrfsExpected := &Stage{ - Type: "org.osbuild.mkfs.btrfs", - Options: btrfsOptions, - Devices: Devices{"device": *device}, - } - assert.Equal(t, mkbtrfsExpected, mkbtrfs) - - ext4Options := &MkfsExt4StageOptions{ - UUID: uuid.New().String(), - Label: "test", - } - mkext4 := NewMkfsExt4Stage(ext4Options, devices) - mkext4Expected := &Stage{ - Type: "org.osbuild.mkfs.ext4", - Options: ext4Options, - Devices: Devices{"device": *device}, - } - assert.Equal(t, mkext4Expected, mkext4) - - fatOptions := &MkfsFATStageOptions{ - VolID: "7B7795E7", - Label: "test", - FATSize: common.ToPtr(12), - } - mkfat := NewMkfsFATStage(fatOptions, devices) - mkfatExpected := &Stage{ - Type: "org.osbuild.mkfs.fat", - Options: fatOptions, - Devices: Devices{"device": *device}, - } - assert.Equal(t, mkfatExpected, mkfat) - - xfsOptions := &MkfsXfsStageOptions{ - UUID: uuid.New().String(), - Label: "test", - } - mkxfs := NewMkfsXfsStage(xfsOptions, devices) - mkxfsExpected := &Stage{ - Type: "org.osbuild.mkfs.xfs", - Options: xfsOptions, - Devices: Devices{"device": *device}, - } - assert.Equal(t, mkxfsExpected, mkxfs) -} diff --git a/internal/osbuild/modprobe_stage_test.go b/internal/osbuild/modprobe_stage_test.go deleted file mode 100644 index 7b5c6b869..000000000 --- a/internal/osbuild/modprobe_stage_test.go +++ /dev/null @@ -1,147 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewModprobeStage(t *testing.T) { - stageOptions := &ModprobeStageOptions{ - Filename: "testing.conf", - Commands: ModprobeConfigCmdList{ - NewModprobeConfigCmdBlacklist("testing_module"), - }, - } - expectedStage := &Stage{ - Type: "org.osbuild.modprobe", - Options: stageOptions, - } - actualStage := NewModprobeStage(stageOptions) - assert.Equal(t, expectedStage, actualStage) -} - -func TestModprobeStageOptionsValidate(t *testing.T) { - tests := []struct { - name string - options ModprobeStageOptions - err bool - }{ - { - name: "empty-options", - options: ModprobeStageOptions{}, - err: true, - }, - { - name: "no-commands", - options: ModprobeStageOptions{ - Filename: "disallow-modules.conf", - Commands: ModprobeConfigCmdList{}, - }, - err: true, - }, - { - name: "no-filename", - options: ModprobeStageOptions{ - Commands: ModprobeConfigCmdList{NewModprobeConfigCmdBlacklist("module_name")}, - }, - err: true, - }, - { - name: "incorrect-filename", - options: ModprobeStageOptions{ - Filename: "disallow-modules.ccoonnff", - Commands: ModprobeConfigCmdList{NewModprobeConfigCmdBlacklist("module_name")}, - }, - err: true, - }, - { - name: "good-options", - options: ModprobeStageOptions{ - Filename: "disallow-modules.conf", - Commands: ModprobeConfigCmdList{NewModprobeConfigCmdBlacklist("module_name")}, - }, - err: false, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.err { - assert.Errorf(t, tt.options.validate(), "%q didn't return an error [idx: %d]", tt.name, idx) - assert.Panics(t, func() { NewModprobeStage(&tt.options) }) - } else { - assert.NoErrorf(t, tt.options.validate(), "%q returned an error [idx: %d]", tt.name, idx) - assert.NotPanics(t, func() { NewModprobeStage(&tt.options) }) - } - }) - } -} - -func TestNewModprobeConfigCmdBlacklist(t *testing.T) { - tests := []struct { - name string - modulename string - err bool - }{ - { - name: "empty-modulename", - modulename: "", - err: true, - }, - { - name: "non-empty-modulename", - modulename: "module_name", - err: false, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.err { - assert.Errorf(t, ModprobeConfigCmdBlacklist{Command: "blacklist", Modulename: tt.modulename}.validate(), "%q didn't return an error [idx: %d]", tt.name, idx) - assert.Panics(t, func() { NewModprobeConfigCmdBlacklist(tt.modulename) }) - } else { - assert.NoErrorf(t, ModprobeConfigCmdBlacklist{Command: "blacklist", Modulename: tt.modulename}.validate(), "%q returned an error [idx: %d]", tt.name, idx) - assert.NotPanics(t, func() { NewModprobeConfigCmdBlacklist(tt.modulename) }) - } - }) - } -} - -func TestNewModprobeConfigCmdInstall(t *testing.T) { - tests := []struct { - name string - modulename string - cmdline string - err bool - }{ - { - name: "empty-modulename", - modulename: "", - cmdline: "/usr/bin/true", - err: true, - }, - { - name: "empty-cmdline", - modulename: "module_name", - cmdline: "", - err: true, - }, - { - name: "non-empty-modulename", - modulename: "module_name", - cmdline: "/usr/bin/true", - err: false, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.err { - assert.Errorf(t, ModprobeConfigCmdInstall{Command: "install", Modulename: tt.modulename, Cmdline: tt.cmdline}.validate(), "%q didn't return an error [idx: %d]", tt.name, idx) - assert.Panics(t, func() { NewModprobeConfigCmdInstall(tt.modulename, tt.cmdline) }) - } else { - assert.NoErrorf(t, ModprobeConfigCmdInstall{Command: "install", Modulename: tt.modulename, Cmdline: tt.cmdline}.validate(), "%q returned an error [idx: %d]", tt.name, idx) - assert.NotPanics(t, func() { NewModprobeConfigCmdInstall(tt.modulename, tt.cmdline) }) - } - }) - } -} diff --git a/internal/osbuild/mount_test.go b/internal/osbuild/mount_test.go deleted file mode 100644 index e7fc38736..000000000 --- a/internal/osbuild/mount_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewMounts(t *testing.T) { - assert := assert.New(t) - - { // btrfs - actual := NewBtrfsMount("btrfs", "/dev/sda1", "/mnt/btrfs") - expected := &Mount{ - Name: "btrfs", - Type: "org.osbuild.btrfs", - Source: "/dev/sda1", - Target: "/mnt/btrfs", - } - assert.Equal(expected, actual) - } - - { // ext4 - actual := NewExt4Mount("ext4", "/dev/sda2", "/mnt/ext4") - expected := &Mount{ - Name: "ext4", - Type: "org.osbuild.ext4", - Source: "/dev/sda2", - Target: "/mnt/ext4", - } - assert.Equal(expected, actual) - } - - { // fat - actual := NewFATMount("fat", "/dev/sda3", "/mnt/fat") - expected := &Mount{ - Name: "fat", - Type: "org.osbuild.fat", - Source: "/dev/sda3", - Target: "/mnt/fat", - } - assert.Equal(expected, actual) - } - - { // xfs - actual := NewXfsMount("xfs", "/dev/sda4", "/mnt/xfs") - expected := &Mount{ - Name: "xfs", - Type: "org.osbuild.xfs", - Source: "/dev/sda4", - Target: "/mnt/xfs", - } - assert.Equal(expected, actual) - } -} diff --git a/internal/osbuild/oci_archive_stage_test.go b/internal/osbuild/oci_archive_stage_test.go deleted file mode 100644 index ac3af14bd..000000000 --- a/internal/osbuild/oci_archive_stage_test.go +++ /dev/null @@ -1,105 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestOCIArchiveStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.oci-archive", - Options: &OCIArchiveStageOptions{}, - Inputs: &OCIArchiveStageInputs{}, - } - actualStage := NewOCIArchiveStage(&OCIArchiveStageOptions{}, &OCIArchiveStageInputs{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestOCIArchiveInputs(t *testing.T) { - exp := `{ - "base": { - "type": "org.osbuild.oci-archive", - "origin":"org.osbuild.pipeline", - "references": ["name:container-tree"] - }, - "layer.1": { - "type": "org.osbuild.tree", - "origin": "org.osbuild.pipeline", - "references": ["name:container-ostree"] - }, - "layer.2": { - "type": "org.osbuild.tree", - "origin": "org.osbuild.pipeline", - "references": ["name:container-ostree2"] - } - }` - inputs := new(OCIArchiveStageInputs) - base := &TreeInput{ - References: []string{ - "name:container-tree", - }, - } - base.Type = "org.osbuild.oci-archive" - base.Origin = "org.osbuild.pipeline" - - layer1 := TreeInput{ - References: []string{ - "name:container-ostree", - }, - } - layer1.Type = "org.osbuild.tree" - layer1.Origin = "org.osbuild.pipeline" - layer2 := TreeInput{ - References: []string{ - "name:container-ostree2", - }, - } - layer2.Type = "org.osbuild.tree" - layer2.Origin = "org.osbuild.pipeline" - - inputs.Base = base - inputs.Layers = []TreeInput{layer1, layer2} - - data, err := json.Marshal(inputs) - assert.NoError(t, err) - assert.JSONEq(t, exp, string(data)) - - inputsRead := new(OCIArchiveStageInputs) - err = json.Unmarshal([]byte(exp), inputsRead) - assert.NoError(t, err) - assert.Equal(t, inputs, inputsRead) -} - -func TestOCIArchiveInputsErrors(t *testing.T) { - noBase := `{ - "layer.10": { - "type": "org.osbuild.tree", - "origin": "org.osbuild.pipeline", - "references": ["name:container-ostree"] - }, - "layer.2": { - "type": "org.osbuild.tree", - "origin": "org.osbuild.pipeline", - "references": ["name:container-ostree2"] - } - }` - - inputsRead := new(OCIArchiveStageInputs) - assert.Error(t, json.Unmarshal([]byte(noBase), inputsRead)) - - invalidKey := `{ - "base": { - "type": "org.osbuild.oci-archive", - "origin":"org.osbuild.pipeline", - "references": ["name:container-tree"] - }, - "not-a-layer": { - "type": "org.osbuild.tree", - "origin": "org.osbuild.pipeline", - "references": ["name:container-ostree2"] - } - }` - assert.Error(t, json.Unmarshal([]byte(invalidKey), inputsRead)) -} diff --git a/internal/osbuild/osbuild_test.go b/internal/osbuild/osbuild_test.go deleted file mode 100644 index 817532023..000000000 --- a/internal/osbuild/osbuild_test.go +++ /dev/null @@ -1,28 +0,0 @@ -// Package osbuild provides primitives for representing and (un)marshalling -// OSBuild types. -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestPipeline_AddStage(t *testing.T) { - expectedPipeline := &Pipeline{ - Build: "name:build", - Stages: []*Stage{ - { - Type: "org.osbuild.rpm", - }, - }, - } - actualPipeline := &Pipeline{ - Build: "name:build", - } - actualPipeline.AddStage(&Stage{ - Type: "org.osbuild.rpm", - }) - assert.Equal(t, expectedPipeline, actualPipeline) - assert.Equal(t, 1, len(actualPipeline.Stages)) -} diff --git a/internal/osbuild/oscap_remediation_stage_test.go b/internal/osbuild/oscap_remediation_stage_test.go deleted file mode 100644 index f8657b22e..000000000 --- a/internal/osbuild/oscap_remediation_stage_test.go +++ /dev/null @@ -1,85 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewOscapRemediationStage(t *testing.T) { - stageOptions := &OscapRemediationStageOptions{DataDir: "/var/tmp", Config: OscapConfig{ - Datastream: "test_stream", - ProfileID: "test_profile", - }} - expectedStage := &Stage{ - Type: "org.osbuild.oscap.remediation", - Options: stageOptions, - } - actualStage := NewOscapRemediationStage(stageOptions) - assert.Equal(t, expectedStage, actualStage) -} - -func TestOscapRemediationStageOptionsValidate(t *testing.T) { - tests := []struct { - name string - options OscapRemediationStageOptions - err bool - }{ - { - name: "empty-options", - options: OscapRemediationStageOptions{}, - err: true, - }, - { - name: "empty-datastream", - options: OscapRemediationStageOptions{ - Config: OscapConfig{ - ProfileID: "test-profile", - }, - }, - err: true, - }, - { - name: "empty-profile-id", - options: OscapRemediationStageOptions{ - Config: OscapConfig{ - Datastream: "test-datastream", - }, - }, - err: true, - }, - { - name: "invalid-verbosity-level", - options: OscapRemediationStageOptions{ - Config: OscapConfig{ - Datastream: "test-datastream", - ProfileID: "test-profile", - VerboseLevel: "FAKE", - }, - }, - err: true, - }, - { - name: "valid-data", - options: OscapRemediationStageOptions{ - Config: OscapConfig{ - Datastream: "test-datastream", - ProfileID: "test-profile", - VerboseLevel: "INFO", - }, - }, - err: false, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.err { - assert.Errorf(t, tt.options.Config.validate(), "%q didn't return an error [idx: %d]", tt.name, idx) - assert.Panics(t, func() { NewOscapRemediationStage(&tt.options) }) - } else { - assert.NoErrorf(t, tt.options.Config.validate(), "%q returned an error [idx: %d]", tt.name, idx) - assert.NotPanics(t, func() { NewOscapRemediationStage(&tt.options) }) - } - }) - } -} diff --git a/internal/osbuild/pam_limits_conf_stage_test.go b/internal/osbuild/pam_limits_conf_stage_test.go deleted file mode 100644 index dafce1876..000000000 --- a/internal/osbuild/pam_limits_conf_stage_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewPamLimitsConfStageOptions(t *testing.T) { - filename := "example.conf" - config := []PamLimitsConfigLine{{ - Domain: "user1", - Type: PamLimitsTypeHard, - Item: PamLimitsItemCpu, - Value: PamLimitsValueInt(123), - }} - - expectedOptions := &PamLimitsConfStageOptions{ - Filename: filename, - Config: config, - } - actualOptions := NewPamLimitsConfStageOptions(filename, config) - assert.Equal(t, expectedOptions, actualOptions) -} - -func TestNewPamLimitsConfStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.pam.limits.conf", - Options: &PamLimitsConfStageOptions{}, - } - actualStage := NewPamLimitsConfStage(&PamLimitsConfStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestPamLimitsConfStageOptions_MarshalJSON_Invalid(t *testing.T) { - tests := []struct { - name string - options PamLimitsConfStageOptions - }{ - { - name: "empty-options", - options: PamLimitsConfStageOptions{}, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotBytes, err := json.Marshal(tt.options) - assert.NotNilf(t, err, "json.Marshal() didn't return an error, but: %s [idx: %d]", string(gotBytes), idx) - }) - } -} diff --git a/internal/osbuild/pwquality_conf_stage_test.go b/internal/osbuild/pwquality_conf_stage_test.go deleted file mode 100644 index 43592936e..000000000 --- a/internal/osbuild/pwquality_conf_stage_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" -) - -func TestNewPwqualityConfStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.pwquality.conf", - Options: &PwqualityConfStageOptions{}, - } - actualStage := NewPwqualityConfStage(&PwqualityConfStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestJsonPwqualityConfStage(t *testing.T) { - // First test that the JSON can be parsed into the expected structure. - expectedOptions := PwqualityConfStageOptions{ - Config: PwqualityConfConfig{ - Minlen: common.ToPtr(9), - Minclass: common.ToPtr(0), - Dcredit: common.ToPtr(1), - }, - } - inputString := `{ - "config": { - "minlen": 9, - "minclass": 0, - "dcredit": 1 - } - }` - var inputOptions PwqualityConfStageOptions - err := json.Unmarshal([]byte(inputString), &inputOptions) - assert.NoError(t, err, "failed to parse JSON yum config") - assert.True(t, reflect.DeepEqual(expectedOptions, inputOptions)) - - // Second try the other way around with stress on missing values - // for those parameters that the user didn't specify. - inputOptions = PwqualityConfStageOptions{ - Config: PwqualityConfConfig{ - Minlen: common.ToPtr(9), - Minclass: common.ToPtr(0), - }, - } - expectedString := `{"config":{"minlen":9,"minclass":0}}` - inputBytes, err := json.Marshal(inputOptions) - assert.NoError(t, err, "failed to marshal sshd config into JSON") - assert.Equal(t, expectedString, string(inputBytes)) -} diff --git a/internal/osbuild/qemu_stage_test.go b/internal/osbuild/qemu_stage_test.go deleted file mode 100644 index 80bd48034..000000000 --- a/internal/osbuild/qemu_stage_test.go +++ /dev/null @@ -1,224 +0,0 @@ -package osbuild - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" -) - -func TestNewQemuStage(t *testing.T) { - - formatOptionsList := []QEMUFormatOptions{ - QCOW2Options{ - Type: QEMUFormatQCOW2, - Compat: "0.10", - }, - VDIOptions{ - Type: QEMUFormatVDI, - }, - VPCOptions{ - Type: QEMUFormatVPC, - }, - VMDKOptions{ - Type: QEMUFormatVMDK, - }, - VHDXOptions{ - Type: QEMUFormatVHDX, - }, - } - - input := NewFilesInput(NewFilesInputPipelineObjectRef("stage", "img.raw", nil)) - inputs := QEMUStageInputs{Image: input} - - for _, format := range formatOptionsList { - options := QEMUStageOptions{ - Filename: "img.out", - Format: format, - } - expectedStage := &Stage{ - Type: "org.osbuild.qemu", - Options: &options, - Inputs: &inputs, - } - - actualStage := NewQEMUStage(&options, &inputs) - assert.Equal(t, expectedStage, actualStage) - } -} - -func TestNewQEMUStageOptions(t *testing.T) { - tests := []struct { - Filename string - Format QEMUFormat - FormatOptions QEMUFormatOptions - ExpectedOptions *QEMUStageOptions - Error bool - }{ - { - Filename: "image.qcow2", - Format: QEMUFormatQCOW2, - FormatOptions: QCOW2Options{ - Compat: "1.1", - }, - ExpectedOptions: &QEMUStageOptions{ - Filename: "image.qcow2", - Format: QCOW2Options{ - Type: QEMUFormatQCOW2, - Compat: "1.1", - }, - }, - }, - { - Filename: "image.qcow2", - Format: QEMUFormatQCOW2, - FormatOptions: QCOW2Options{ - Type: QEMUFormatQCOW2, - }, - ExpectedOptions: &QEMUStageOptions{ - Filename: "image.qcow2", - Format: QCOW2Options{ - Type: QEMUFormatQCOW2, - }, - }, - }, - { - Filename: "image.qcow2", - Format: QEMUFormatQCOW2, - FormatOptions: QCOW2Options{}, - ExpectedOptions: &QEMUStageOptions{ - Filename: "image.qcow2", - Format: QCOW2Options{ - Type: QEMUFormatQCOW2, - }, - }, - }, - { - Filename: "image.qcow2", - Format: QEMUFormatQCOW2, - FormatOptions: nil, - ExpectedOptions: &QEMUStageOptions{ - Filename: "image.qcow2", - Format: QCOW2Options{ - Type: QEMUFormatQCOW2, - }, - }, - }, - { - Filename: "image.vdi", - Format: QEMUFormatVDI, - FormatOptions: nil, - ExpectedOptions: &QEMUStageOptions{ - Filename: "image.vdi", - Format: VDIOptions{ - Type: QEMUFormatVDI, - }, - }, - }, - { - Filename: "image.vpc", - Format: QEMUFormatVPC, - FormatOptions: nil, - ExpectedOptions: &QEMUStageOptions{ - Filename: "image.vpc", - Format: VPCOptions{ - Type: QEMUFormatVPC, - }, - }, - }, - { - Filename: "image.vpc", - Format: QEMUFormatVPC, - FormatOptions: VPCOptions{ - ForceSize: common.ToPtr(false), - }, - ExpectedOptions: &QEMUStageOptions{ - Filename: "image.vpc", - Format: VPCOptions{ - Type: QEMUFormatVPC, - ForceSize: common.ToPtr(false), - }, - }, - }, - { - Filename: "image.vmdk", - Format: QEMUFormatVMDK, - FormatOptions: nil, - ExpectedOptions: &QEMUStageOptions{ - Filename: "image.vmdk", - Format: VMDKOptions{ - Type: QEMUFormatVMDK, - }, - }, - }, - { - Filename: "image.vmdk", - Format: QEMUFormatVMDK, - FormatOptions: VMDKOptions{ - Subformat: VMDKSubformatStreamOptimized, - }, - ExpectedOptions: &QEMUStageOptions{ - Filename: "image.vmdk", - Format: VMDKOptions{ - Type: QEMUFormatVMDK, - Subformat: VMDKSubformatStreamOptimized, - }, - }, - }, - { - Filename: "image.vhdx", - Format: QEMUFormatVHDX, - FormatOptions: nil, - ExpectedOptions: &QEMUStageOptions{ - Filename: "image.vhdx", - Format: VHDXOptions{ - Type: QEMUFormatVHDX, - }, - }, - }, - // mismatch between format and format options type - { - Filename: "image.qcow2", - Format: QEMUFormatQCOW2, - FormatOptions: VMDKOptions{}, - Error: true, - }, - // mismatch between format and format options type - { - Filename: "image.qcow2", - Format: QEMUFormatQCOW2, - FormatOptions: VMDKOptions{ - Type: QEMUFormatQCOW2, - }, - Error: true, - }, - // mismatch between format and format options type - { - Filename: "image.qcow2", - Format: QEMUFormatQCOW2, - FormatOptions: VMDKOptions{ - Type: QEMUFormatVMDK, - }, - Error: true, - }, - // unknown format - { - Filename: "image.qcow2", - Format: "", - FormatOptions: nil, - Error: true, - }, - } - for idx, test := range tests { - t.Run(fmt.Sprintf("test-(%d/%d)", idx, len(tests)), func(t *testing.T) { - if test.Error { - assert.Panics(t, func() { NewQEMUStageOptions(test.Filename, test.Format, test.FormatOptions) }) - } else { - stageOptions := NewQEMUStageOptions(test.Filename, test.Format, test.FormatOptions) - assert.EqualValues(t, test.ExpectedOptions, stageOptions) - } - }) - } -} diff --git a/internal/osbuild/result_test.go b/internal/osbuild/result_test.go deleted file mode 100644 index 4d1752445..000000000 --- a/internal/osbuild/result_test.go +++ /dev/null @@ -1,378 +0,0 @@ -package osbuild - -import ( - "bytes" - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/osbuild/osbuild-composer/internal/common" -) - -func TestStageResult_UnmarshalJSON(t *testing.T) { - cases := []struct { - input string - success bool - }{ - {input: `{}`, success: true}, - {input: `{"success": true}`, success: true}, - {input: `{"success": false}`, success: false}, - } - - for _, c := range cases { - t.Run(c.input, func(t *testing.T) { - var result StageResult - err := json.Unmarshal([]byte(c.input), &result) - assert.NoError(t, err) - assert.Equal(t, c.success, result.Success) - }) - } -} - -func TestUnmarshal(t *testing.T) { - assert := assert.New(t) - var result Result - err := json.Unmarshal([]byte(fullResultRaw), &result) - assert.NoError(err) - - assert.True(result.Success) - - assert.Equal(len(result.Log), 4) - for _, plName := range []string{"build", "image", "os", "qcow2"} { - assert.Contains(result.Log, plName) - for _, stage := range result.Log[plName] { - assert.True(stage.Success) - } - } - assert.Equal(len(result.Metadata), 2) - - pipelinePackageCount := map[string]int{ - "build": 254, - "os": 449, - } - for _, plName := range []string{"build", "os"} { - assert.Contains(result.Metadata, plName) - for stageType, stageMetadata := range result.Metadata[plName] { - if stageType == "org.osbuild.rpm" { - rpmMd, convOk := stageMetadata.(*RPMStageMetadata) - assert.True(convOk) - assert.Len(rpmMd.Packages, pipelinePackageCount[plName]) - } - } - } -} - -func TestUnmarshalV1Success(t *testing.T) { - var result Result - err := json.Unmarshal([]byte(v1ResultSuccess), &result) - - assert := assert.New(t) - assert.NoError(err) - - assert.True(result.Success) - - pipelineStageCount := map[string]int{ - "build": 2, - "os": 11, - "assembler": 1, - } - assert.Len(result.Log, len(pipelineStageCount)) - for name, stageCount := range pipelineStageCount { - assert.Contains(result.Log, name) - assert.Len(result.Log[name], stageCount) - for _, stage := range result.Log[name] { - assert.True(stage.Success) - } - } - - buildLog := result.Log["build"] - assert.Equal("org.osbuild.rpm", buildLog[0].Type) - - osLog := result.Log["os"] - assert.Equal(osLog[0].Type, "org.osbuild.rpm") - - assemblerLog := result.Log["assembler"] - assert.Equal(assemblerLog[0].Type, "org.osbuild.qemu") - - for _, plName := range []string{"build", "os"} { - assert.Contains(result.Metadata, plName) - for stageType, stageMetadata := range result.Metadata[plName] { - if stageType == "org.osbuild.rpm" { - rpmMd, convOk := stageMetadata.(*RPMStageMetadata) - assert.True(convOk) - assert.Len(rpmMd.Packages, 1) - } - } - } -} - -func TestUnmarshalV1Failure(t *testing.T) { - assert := assert.New(t) - var result Result - err := json.Unmarshal([]byte(v1ResultFailure), &result) - assert.NoError(err) - - assert.False(result.Success) - - pipelineStageCount := map[string]int{ - "build": 2, - "os": 9, - } - assert.Len(result.Log, len(pipelineStageCount)) - for name, stageCount := range pipelineStageCount { - assert.Contains(result.Log, name) - assert.Len(result.Log[name], stageCount) - for idx, stage := range result.Log[name] { - // lastStage should be false, all else true - lastStage := (name == "os") && (idx == pipelineStageCount["os"]-1) - assert.Equal(stage.Success, !lastStage) - } - } - - buildLog := result.Log["build"] - assert.Equal("org.osbuild.rpm", buildLog[0].Type) - - osLog := result.Log["os"] - assert.False(osLog[8].Success) - assert.Equal(osLog[0].Type, "org.osbuild.rpm") -} - -func TestUnmarshalV2Success(t *testing.T) { - assert := assert.New(t) - var result Result - err := json.Unmarshal([]byte(v2ResultSuccess), &result) - assert.NoError(err) - - assert.True(result.Success) - - pipelineStageCount := map[string]int{ - "build": 2, - "ostree-tree": 7, - "ostree-commit": 2, - "container-tree": 4, - "assembler": 1, - } - assert.Len(result.Log, len(pipelineStageCount)) - for name, stageCount := range pipelineStageCount { - assert.Contains(result.Log, name) - assert.Len(result.Log[name], stageCount) - for _, stage := range result.Log[name] { - assert.True(stage.Success) - } - } - - // check metadata - for _, pipeline := range result.Metadata { - for stageType, stageMetadata := range pipeline { - if stageType == "org.osbuild.rpm" { - rpmMd, convOk := stageMetadata.(*RPMStageMetadata) - assert.True(convOk) - assert.Greater(len(rpmMd.Packages), 0) - } else if stageType == "org.osbuild.ostree.commit" { - commitMd, convOk := stageMetadata.(*OSTreeCommitStageMetadata) - assert.True(convOk) - assert.NotEmpty(commitMd.Compose.Ref) - } - } - } -} - -func TestUnmarshalV2Failure(t *testing.T) { - assert := assert.New(t) - var result Result - err := json.Unmarshal([]byte(v2ResultFailure), &result) - assert.NoError(err) - - assert.False(result.Success) - - pipelineStageCount := map[string]int{ - "build": 2, - "ostree-tree": 5, - } - assert.Len(result.Log, len(pipelineStageCount)) - for name, stageCount := range pipelineStageCount { - assert.Contains(result.Log, name) - assert.Len(result.Log[name], stageCount) - for idx, stage := range result.Log[name] { - // success of last stage in last pipeline should be 'false' and - // 'true' everywhere else (Success == !lastStage) - lastStage := (name == "ostree-tree") && (idx == pipelineStageCount["ostree-tree"]-1) - assert.Equal(stage.Success, !lastStage) - } - } -} - -func TestUnmarshalValidationFailure(t *testing.T) { - assert := assert.New(t) - require := require.New(t) - var result Result - err := json.Unmarshal([]byte(validationResultFailure), &result) - assert.NoError(err) - - assert.False(result.Success) - assert.Equal(result.Title, "JSON Schema validation failed") - require.Len(result.Errors, 2) - assert.Len(result.Errors[0].Path, 2) - assert.Len(result.Errors[1].Path, 5) -} - -func TestWrite(t *testing.T) { - assert := assert.New(t) - result := Result{ - Type: "result", - Success: true, - Error: []byte{}, - Log: map[string]PipelineResult{ - "build": { - StageResult{ - ID: "7de66f934df730534ea120a819480fb94913a5f448aa2fe6827c49d884cb9bd1", - Type: "org.osbuild.rpm", - Output: "", - }, - StageResult{ - ID: "5fca77a102097ff631d7e125a838a42235c7bfbdbd45fd872a61e3f0805125c5", - Type: "org.osbuild.selinux", - Output: "", - }, - }, - "os": { - StageResult{ - ID: "some ID", - Type: "org.osbuild.rpm", - Output: "", - }, - }, - "final-pipeline": { - StageResult{ - ID: "assembler ID", - Type: "org.osbuild.qcow2", - Output: "assmelber the image", - }, - }, - }, - Metadata: map[string]PipelineMetadata{ - "build": map[string]StageMetadata{ - "org.osbuild.rpm": RPMStageMetadata{ - Packages: []RPMPackageMetadata{ - { - Name: "fake-package", - Version: "1", - Release: "2", - Arch: "x86_64", - }, - }, - }, - }, - "os": map[string]StageMetadata{ - "org.osbuild.rpm": RPMStageMetadata{ - Packages: []RPMPackageMetadata{ - { - Name: "vim-minimal", - Version: "8.0.1763", - Release: "15.el8", - Epoch: common.ToPtr("2"), - Arch: "x86_64", - SigMD5: "4b3ddc56cbb1be95e0973b4a98047820", - SigPGP: "8902150305005ed77b28199e2f91fd431d510108a4141000995156bc9f610ad386ee49c42ab31c864fc605cae26592ba58f973fe97b54ea12b42c8e7ee2d716162714fe815de63b60cadb7400a0c71aa56dd3b0af656c6ea413eaaada53374e2e910e556d90e4d157a5b41a6540e355a0176fb3879bf17d90533d1aa3b3d23f06a99a42ad80f17498af2c321193b7be5a504f5dc759d6787a180f9fb3c1903be75f448429537eb0abeb96bb2e73cdc5fe91465c3d54154f6717ffd0a1b42a178e5093500d475639ef60ee483a1ec0d3148d23e0c2ab7bde7c68e5dfdd1103f8e9da7d53ec637c057bc1496d0504fe92760942f9f6de7382fbdef481489c7f6f943bf7fb8c8aadb6484569a6a8f074db78f84579dbaccc86c1eb49379b47033a9eca2577df00d60b353b08bc3850d852365792f194dd8b2b9ba4a1ad5c103afd4db853382520a64ecc362339f3642f4f1ad4e52d8f67b2e731b8d10cef29cb3ed05837245bfca37335f3760f3fb64cbf7acae7e18916a3d4272b0d1589320ab963123649eb9722c8c0e444952900caf39caa371fa77bec8a0e4b010f370eab3d4fe5653a38d88a5a4a415a89f917a31da856a4616ae07ce5749d90ac84bb9189263b162e0cf54ba58a8012d64c89196abae9113e0cda60b4e86879e23d8693691a234784ad3e161733798a0aa41416c045feeb8e2f5859a8a64272298da3d2c1ece675ee802fe8cb273e0b3c1b0f00960d3da09adbdbc531e", - }, - }, - }, - }, - }} - - var b bytes.Buffer - assert.NoError(result.Write(&b)) - expectedOutput := - `Pipeline build -Stage org.osbuild.rpm -Output: - -Metadata: -{ - "packages": [ - { - "name": "fake-package", - "version": "1", - "release": "2", - "epoch": null, - "arch": "x86_64", - "sigmd5": "", - "sigpgp": "", - "siggpg": "" - } - ] -} - -Stage org.osbuild.selinux -Output: - - -Pipeline final-pipeline -Stage org.osbuild.qcow2 -Output: -assmelber the image -Pipeline os -Stage org.osbuild.rpm -Output: - -Metadata: -{ - "packages": [ - { - "name": "vim-minimal", - "version": "8.0.1763", - "release": "15.el8", - "epoch": "2", - "arch": "x86_64", - "sigmd5": "4b3ddc56cbb1be95e0973b4a98047820", - "sigpgp": "8902150305005ed77b28199e2f91fd431d510108a4141000995156bc9f610ad386ee49c42ab31c864fc605cae26592ba58f973fe97b54ea12b42c8e7ee2d716162714fe815de63b60cadb7400a0c71aa56dd3b0af656c6ea413eaaada53374e2e910e556d90e4d157a5b41a6540e355a0176fb3879bf17d90533d1aa3b3d23f06a99a42ad80f17498af2c321193b7be5a504f5dc759d6787a180f9fb3c1903be75f448429537eb0abeb96bb2e73cdc5fe91465c3d54154f6717ffd0a1b42a178e5093500d475639ef60ee483a1ec0d3148d23e0c2ab7bde7c68e5dfdd1103f8e9da7d53ec637c057bc1496d0504fe92760942f9f6de7382fbdef481489c7f6f943bf7fb8c8aadb6484569a6a8f074db78f84579dbaccc86c1eb49379b47033a9eca2577df00d60b353b08bc3850d852365792f194dd8b2b9ba4a1ad5c103afd4db853382520a64ecc362339f3642f4f1ad4e52d8f67b2e731b8d10cef29cb3ed05837245bfca37335f3760f3fb64cbf7acae7e18916a3d4272b0d1589320ab963123649eb9722c8c0e444952900caf39caa371fa77bec8a0e4b010f370eab3d4fe5653a38d88a5a4a415a89f917a31da856a4616ae07ce5749d90ac84bb9189263b162e0cf54ba58a8012d64c89196abae9113e0cda60b4e86879e23d8693691a234784ad3e161733798a0aa41416c045feeb8e2f5859a8a64272298da3d2c1ece675ee802fe8cb273e0b3c1b0f00960d3da09adbdbc531e", - "siggpg": "" - } - ] -} - -` - assert.Equal(expectedOutput, b.String()) -} - -func TestWriteEmpty(t *testing.T) { - assert := assert.New(t) - var b bytes.Buffer - - var testNilResult *Result - assert.NoError(testNilResult.Write(&b)) - assert.Equal("The compose result is empty.\n", b.String()) - - b.Reset() - result := Result{} - assert.NoError(result.Write(&b)) - assert.Equal("The compose result is empty.\n", b.String()) -} - -func TestValidationFailWrite(t *testing.T) { - assert := assert.New(t) - result := Result{ - Type: "https://osbuild.org/validation-error", - Success: false, - Title: "JSON Schema validation failed", - Errors: []ValidationError{{ - Message: "Additional properties are not allowed ('homer' was unexpected)", - Path: []string{"sources", "org.osbuild.curl"}, - }, { - Message: "Additional properties are not allowed ('file_contextso' was unexpected)", - Path: []string{"pipelines", "[0]", "stages", "[1]", "options"}, - }}, - } - - var b bytes.Buffer - assert.NoError(result.Write(&b)) - expectedOutput := `Error JSON Schema validation failed -sources.org.osbuild.curl: Additional properties are not allowed ('homer' was unexpected) -pipelines.[0].stages.[1].options: Additional properties are not allowed ('file_contextso' was unexpected) -The compose result is empty. -` - - assert.Equal(expectedOutput, b.String()) -} diff --git a/internal/osbuild/rhsm_facts_stage_test.go b/internal/osbuild/rhsm_facts_stage_test.go deleted file mode 100644 index 579b98683..000000000 --- a/internal/osbuild/rhsm_facts_stage_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "fmt" - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestNewRHSMFactsStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.rhsm.facts", - Options: &RHSMFactsStageOptions{}, - } - actualStage := NewRHSMFactsStage(&RHSMFactsStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestRHSMFactsStageJson(t *testing.T) { - tests := []struct { - Options RHSMFactsStageOptions - JsonString string - }{ - { - Options: RHSMFactsStageOptions{ - Facts: RHSMFacts{ - ApiType: "test-api", - }, - }, - JsonString: fmt.Sprintf(`{"facts":{"image-builder.osbuild-composer.api-type":"%s"}}`, "test-api"), - }, - } - for _, test := range tests { - marshaledJson, err := json.Marshal(test.Options) - require.NoError(t, err, "failed to marshal JSON") - require.Equal(t, test.JsonString, string(marshaledJson)) - - var jsonOptions RHSMFactsStageOptions - err = json.Unmarshal([]byte(test.JsonString), &jsonOptions) - require.NoError(t, err, "failed to parse JSON") - require.True(t, reflect.DeepEqual(test.Options, jsonOptions)) - } -} diff --git a/internal/osbuild/rhsm_stage_test.go b/internal/osbuild/rhsm_stage_test.go deleted file mode 100644 index 79c1a8cbb..000000000 --- a/internal/osbuild/rhsm_stage_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestNewRhsmStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.rhsm", - Options: &RHSMStageOptions{}, - } - actualStage := NewRHSMStage(&RHSMStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestRhsmStageJson(t *testing.T) { - tests := []struct { - Options RHSMStageOptions - JsonString string - }{ - { - Options: RHSMStageOptions{ - YumPlugins: &RHSMStageOptionsDnfPlugins{ - ProductID: &RHSMStageOptionsDnfPlugin{ - Enabled: true, - }, - SubscriptionManager: &RHSMStageOptionsDnfPlugin{ - Enabled: false, - }, - }, - }, - JsonString: `{"yum-plugins":{"product-id":{"enabled":true},"subscription-manager":{"enabled":false}}}`, - }, - { - Options: RHSMStageOptions{ - DnfPlugins: &RHSMStageOptionsDnfPlugins{ - ProductID: &RHSMStageOptionsDnfPlugin{ - Enabled: true, - }, - SubscriptionManager: &RHSMStageOptionsDnfPlugin{ - Enabled: false, - }, - }, - }, - JsonString: `{"dnf-plugins":{"product-id":{"enabled":true},"subscription-manager":{"enabled":false}}}`, - }, - { - Options: RHSMStageOptions{ - SubMan: &RHSMStageOptionsSubMan{ - Rhsm: &SubManConfigRHSMSection{}, - Rhsmcertd: &SubManConfigRHSMCERTDSection{}, - }, - }, - JsonString: `{"subscription-manager":{"rhsm":{},"rhsmcertd":{}}}`, - }, - } - for _, test := range tests { - marshaledJson, err := json.Marshal(test.Options) - require.NoError(t, err, "failed to marshal JSON") - require.Equal(t, string(marshaledJson), test.JsonString) - - var jsonOptions RHSMStageOptions - err = json.Unmarshal([]byte(test.JsonString), &jsonOptions) - require.NoError(t, err, "failed to parse JSON") - require.True(t, reflect.DeepEqual(test.Options, jsonOptions)) - } -} diff --git a/internal/osbuild/rpm_stage_test.go b/internal/osbuild/rpm_stage_test.go deleted file mode 100644 index 0ded7646b..000000000 --- a/internal/osbuild/rpm_stage_test.go +++ /dev/null @@ -1,182 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "fmt" - "testing" - - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestNewRPMStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.rpm", - Options: &RPMStageOptions{}, - Inputs: &RPMStageInputs{}, - } - actualStage := NewRPMStage(&RPMStageOptions{}, &RPMStageInputs{}) - assert.Equal(t, expectedStage, actualStage) -} - -func Test_OSBuildMetadataToRPMs(t *testing.T) { - raw := ` -{ - "org.osbuild.rpm": { - "packages": [ - { - "name": "python3-pyserial", - "version": "3.4", - "release": "7.fc32", - "epoch": null, - "arch": "noarch", - "sigmd5": "378cb32f9f850b275ac4e04d21e8144b", - "sigpgp": "89023304000108001d162104963a2beb02009608fe67ea4249fd77499570ff3105025f5a272b000a091049fd77499570ff31ccdb0ffe38b95a55ebf3c021526b3cd4f2358c7e23f7767d1f5ce4b7cccef7b33653c6a96a23022313a818fbaf7abeb41837910f0d3ac15664e02838d5939d38ff459aa0076e248728a032d3ae09ddfaec955f941601081a2e3f9bbd49586fd65c1bc1b31685aeb0405687d1791471eab7359ccf00d5584ddef680e99ebc8a4846316391b9baa68ac8ed8ad696ee16fd625d847f8edd92517df3ea6920a46b77b4f119715a0f619f38835d25e0bd0eb5cfad08cd9c796eace6a2b28f4d3dee552e6068255d9748dc2a1906c951e0ba8aed9922ab24e1f659413a06083f8a0bfea56cfff14bddef23bced449f36bcd369da72f90ddf0512e7b0801ba5a0c8eaa8eb0582c630815e992192042cfb0a7c7239f76219197c2fdf18b6553260c105280806d4f037d7b04bdf3da9fd7e9a207db5c71f7e548f4288928f047c989c4cb9cbb8088eec7bd2fa5c252e693f51a3cfc660f666af6a255a5ca0fd2216d5ccd66cbd9c11afa61067d7f615ec8d0dc0c879b5fe633d8c9443f97285da597e4da8a3993af36f0be06acfa9b8058ec70bbc78b876e4c6c5d2108fb05c15a74ba48a3d7ded697cbc1748c228d77d1e0794a41fd5240fa67c3ed745fe47555a47c3d6163d8ce95fd6c2d0d6fa48f8e5b411e571e442109b1cb200d9a8117ee08bfe645f96aca34f7b7559622bbab75143dcad59f126ae0d319e6668ebba417e725638c4febf2e", - "siggpg": "883f0305005f2310139ec3e4c0f7e257e611023e11009f639c5fe64abaa76224dab3a9f70c2714a84c63bd009d1cc184fb4b428dfcd7c3556f4a5f860cc0187740" - }, - { - "name": "libgcc", - "version": "10.0.1", - "release": "0.11.fc32", - "epoch": null, - "arch": "x86_64", - "sigmd5": "84fc907a5047aeebaf8da1642925a417", - "sigpgp": "89023304000108001d162104963a2beb02009608fe67ea4249fd77499570ff3105025f5a272b000a091049fd77499570ff31ccdb0ffe38b95a55ebf3c021526b3cd4f2358c7e23f7767d1f5ce4b7cccef7b33653c6a96a23022313a818fbaf7abeb41837910f0d3ac15664e02838d5939d38ff459aa0076e248728a032d3ae09ddfaec955f941601081a2e3f9bbd49586fd65c1bc1b31685aeb0405687d1791471eab7359ccf00d5584ddef680e99ebc8a4846316391b9baa68ac8ed8ad696ee16fd625d847f8edd92517df3ea6920a46b77b4f119715a0f619f38835d25e0bd0eb5cfad08cd9c796eace6a2b28f4d3dee552e6068255d9748dc2a1906c951e0ba8aed9922ab24e1f659413a06083f8a0bfea56cfff14bddef23bced449f36bcd369da72f90ddf0512e7b0801ba5a0c8eaa8eb0582c630815e992192042cfb0a7c7239f76219197c2fdf18b6553260c105280806d4f037d7b04bdf3da9fd7e9a207db5c71f7e548f4288928f047c989c4cb9cbb8088eec7bd2fa5c252e693f51a3cfc660f666af6a255a5ca0fd2216d5ccd66cbd9c11afa61067d7f615ec8d0dc0c879b5fe633d8c9443f97285da597e4da8a3993af36f0be06acfa9b8058ec70bbc78b876e4c6c5d2108fb05c15a74ba48a3d7ded697cbc1748c228d77d1e0794a41fd5240fa67c3ed745fe47555a47c3d6163d8ce95fd6c2d0d6fa48f8e5b411e571e442109b1cb200d9a8117ee08bfe645f96aca34f7b7559622bbab75143dcad59f126ae0d319e6668ebba417e725638c4febf2e", - "siggpg": null - }, - { - "name": "libgcc-madeup", - "version": "10.0.1", - "release": "0.11.fc32", - "epoch": null, - "arch": "x86_64", - "sigmd5": "84fc907a5047aeebaf8da1642925a418", - "sigpgp": null, - "siggpg": null - } - ] - } -} -` - metadata := new(PipelineMetadata) - err := json.Unmarshal([]byte(raw), metadata) - require.NoError(t, err) - - fmt.Printf("Result: %#v", metadata) - rpms := OSBuildMetadataToRPMs(*metadata) - - require.Len(t, rpms, 3) - - signature1 := "89023304000108001d162104963a2beb02009608fe67ea4249fd77499570ff3105025f5a272b000a091049fd77499570ff31ccdb0ffe38b95a55ebf3c021526b3cd4f2358c7e23f7767d1f5ce4b7cccef7b33653c6a96a23022313a818fbaf7abeb41837910f0d3ac15664e02838d5939d38ff459aa0076e248728a032d3ae09ddfaec955f941601081a2e3f9bbd49586fd65c1bc1b31685aeb0405687d1791471eab7359ccf00d5584ddef680e99ebc8a4846316391b9baa68ac8ed8ad696ee16fd625d847f8edd92517df3ea6920a46b77b4f119715a0f619f38835d25e0bd0eb5cfad08cd9c796eace6a2b28f4d3dee552e6068255d9748dc2a1906c951e0ba8aed9922ab24e1f659413a06083f8a0bfea56cfff14bddef23bced449f36bcd369da72f90ddf0512e7b0801ba5a0c8eaa8eb0582c630815e992192042cfb0a7c7239f76219197c2fdf18b6553260c105280806d4f037d7b04bdf3da9fd7e9a207db5c71f7e548f4288928f047c989c4cb9cbb8088eec7bd2fa5c252e693f51a3cfc660f666af6a255a5ca0fd2216d5ccd66cbd9c11afa61067d7f615ec8d0dc0c879b5fe633d8c9443f97285da597e4da8a3993af36f0be06acfa9b8058ec70bbc78b876e4c6c5d2108fb05c15a74ba48a3d7ded697cbc1748c228d77d1e0794a41fd5240fa67c3ed745fe47555a47c3d6163d8ce95fd6c2d0d6fa48f8e5b411e571e442109b1cb200d9a8117ee08bfe645f96aca34f7b7559622bbab75143dcad59f126ae0d319e6668ebba417e725638c4febf2e" - require.Equal(t, rpmmd.RPM{ - Type: "rpm", - Name: "libgcc", - Version: "10.0.1", - Release: "0.11.fc32", - Epoch: nil, - Arch: "x86_64", - Sigmd5: "84fc907a5047aeebaf8da1642925a417", - Signature: &signature1, - }, rpms[1]) - - // GPG has a priority over PGP - signature0 := "883f0305005f2310139ec3e4c0f7e257e611023e11009f639c5fe64abaa76224dab3a9f70c2714a84c63bd009d1cc184fb4b428dfcd7c3556f4a5f860cc0187740" - require.Equal(t, signature0, *rpms[0].Signature) - - // if neither GPG nor PGP is set, the signature is nil - require.Nil(t, rpms[2].Signature) -} - -func TestNewRpmStageSourceFilesInputs(t *testing.T) { - - assert := assert.New(t) - require := require.New(t) - - pkgSpecs := []rpmmd.PackageSpec{ - { - Name: "openssl-libs", - Epoch: 1, - Version: "3.0.1", - Release: "5.el9", - Arch: "x86_64", - RemoteLocation: "https://example.com/repo/Packages/openssl-libs-3.0.1-5.el9.x86_64.rpm", - Checksum: "sha256:fcf2515ec9115551c99d552da721803ecbca23b7ae5a974309975000e8bef666", - Secrets: "", - CheckGPG: false, - IgnoreSSL: true, - }, - { - Name: "openssl-pkcs11", - Epoch: 0, - Version: "0.4.11", - Release: "7.el9", - Arch: "x86_64", - RemoteLocation: "https://example.com/repo/Packages/openssl-pkcs11-0.4.11-7.el9.x86_64.rpm", - Checksum: "sha256:4be41142a5fb2b4cd6d812e126838cffa57b7c84e5a79d65f66bb9cf1d2830a3", - Secrets: "", - CheckGPG: false, - IgnoreSSL: true, - }, - { - Name: "p11-kit", - Epoch: 0, - Version: "0.24.1", - Release: "2.el9", - Arch: "x86_64", - RemoteLocation: "https://example.com/repo/Packages/p11-kit-0.24.1-2.el9.x86_64.rpm", - Checksum: "sha256:da167e41efd19cf25fd1c708b6f123d0203824324b14dd32401d49f2aa0ef0a6", - Secrets: "", - CheckGPG: false, - IgnoreSSL: true, - }, - { - Name: "package-with-sha1-checksum", - Epoch: 1, - Version: "3.4.2.", - Release: "10.el9", - Arch: "x86_64", - RemoteLocation: "https://example.com/repo/Packages/package-with-sha1-checksum-4.3.2-10.el9.x86_64.rpm", - Checksum: "sha1:6e01b8076a2ab729d564048bf2e3a97c7ac83c13", - Secrets: "", - CheckGPG: true, - IgnoreSSL: true, - }, - { - Name: "package-with-md5-checksum", - Epoch: 1, - Version: "3.4.2.", - Release: "5.el9", - Arch: "x86_64", - RemoteLocation: "https://example.com/repo/Packages/package-with-md5-checksum-4.3.2-5.el9.x86_64.rpm", - Checksum: "md5:8133f479f38118c5f9facfe2a2d9a071", - Secrets: "", - CheckGPG: true, - IgnoreSSL: true, - }, - } - inputs := NewRpmStageSourceFilesInputs(pkgSpecs) - - refsArrayPtr, convOk := inputs.Packages.References.(*FilesInputSourceArrayRef) - require.True(convOk) - require.NotNil(refsArrayPtr) - - refsArray := *refsArrayPtr - - for idx := range refsArray { - refItem := refsArray[idx] - pkg := pkgSpecs[idx] - assert.Equal(pkg.Checksum, refItem.ID) - - if pkg.CheckGPG { - // GPG check enabled: metadata expected - require.NotNil(refItem.Options) - require.NotNil(refItem.Options.Metadata) - - md, convOk := refItem.Options.Metadata.(*RPMStageReferenceMetadata) - require.True(convOk) - require.NotNil(md) - assert.Equal(md.CheckGPG, pkg.CheckGPG) - } - } -} diff --git a/internal/osbuild/script_stage_test.go b/internal/osbuild/script_stage_test.go deleted file mode 100644 index b813aff68..000000000 --- a/internal/osbuild/script_stage_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewScriptStageOptions(t *testing.T) { - expectedOptions := &ScriptStageOptions{ - Script: "/root/test.sh", - } - actualOptions := NewScriptStageOptions("/root/test.sh") - assert.Equal(t, expectedOptions, actualOptions) -} - -func TestNewScriptStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.script", - Options: &ScriptStageOptions{}, - } - actualStage := NewScriptStage(&ScriptStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/selinux_config_stage_test.go b/internal/osbuild/selinux_config_stage_test.go deleted file mode 100644 index b8fabf676..000000000 --- a/internal/osbuild/selinux_config_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewSELinuxConfigStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.selinux.config", - Options: &SELinuxConfigStageOptions{}, - } - actualStage := NewSELinuxConfigStage(&SELinuxConfigStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/selinux_stage_test.go b/internal/osbuild/selinux_stage_test.go deleted file mode 100644 index 833f6bfae..000000000 --- a/internal/osbuild/selinux_stage_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewSELinuxStageOptions(t *testing.T) { - expectedOptions := &SELinuxStageOptions{ - FileContexts: "etc/selinux/targeted/contexts/files/file_contexts", - } - actualOptions := NewSELinuxStageOptions("etc/selinux/targeted/contexts/files/file_contexts") - assert.Equal(t, expectedOptions, actualOptions) -} - -func TestNewSELinuxStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.selinux", - Options: &SELinuxStageOptions{}, - } - actualStage := NewSELinuxStage(&SELinuxStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/sfdisk_stage_test.go b/internal/osbuild/sfdisk_stage_test.go deleted file mode 100644 index 09da6a8f2..000000000 --- a/internal/osbuild/sfdisk_stage_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewSfdiskStage(t *testing.T) { - - partition := SfdiskPartition{ - Bootable: true, - Name: "root", - Size: 2097152, - Start: 0, - Type: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", - UUID: "68B2905B-DF3E-4FB3-80FA-49D1E773AA33", - } - - options := SfdiskStageOptions{ - Label: "gpt", - UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - Partitions: []SfdiskPartition{partition}, - } - - device := NewLoopbackDevice(&LoopbackDeviceOptions{Filename: "disk.raw"}) - devices := Devices{"device": *device} - - expectedStage := &Stage{ - Type: "org.osbuild.sfdisk", - Options: &options, - Devices: devices, - } - - actualStage := NewSfdiskStage(&options, device) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/sgdisk_stage_test.go b/internal/osbuild/sgdisk_stage_test.go deleted file mode 100644 index b53b9f32c..000000000 --- a/internal/osbuild/sgdisk_stage_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/google/uuid" - "github.com/stretchr/testify/assert" -) - -func TestNewSgdiskStage(t *testing.T) { - - uid := uuid.MustParse("68B2905B-DF3E-4FB3-80FA-49D1E773AA33") - partition := SgdiskPartition{ - Bootable: true, - Name: "root", - Size: 2097152, - Start: 0, - Type: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", - UUID: &uid, - } - - options := SgdiskStageOptions{ - UUID: uuid.MustParse("D209C89E-EA5E-4FBD-B161-B461CCE297E0"), - Partitions: []SgdiskPartition{partition}, - } - - device := NewLoopbackDevice(&LoopbackDeviceOptions{Filename: "disk.raw"}) - devices := Devices{"device": *device} - - expectedStage := &Stage{ - Type: "org.osbuild.sgdisk", - Options: &options, - Devices: devices, - } - - actualStage := NewSgdiskStage(&options, device) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/shell_init_stage_test.go b/internal/osbuild/shell_init_stage_test.go deleted file mode 100644 index 5f5db0131..000000000 --- a/internal/osbuild/shell_init_stage_test.go +++ /dev/null @@ -1,184 +0,0 @@ -package osbuild - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestValidShellInitStageOptions(t *testing.T) { - tests := []ShellInitStageOptions{ - { - Files: map[string]ShellInitFile{ - "filename": { - Env: []EnvironmentVariable{ - { - Key: "KEY", - Value: "value", - }, - { - Key: "KEY2", - Value: "value2", - }, - { - Key: "EMPTY", - Value: "", - }, - }, - }, - "filename2": { - Env: []EnvironmentVariable{ - { - Key: "KEY21", - Value: "value21", - }, - { - Key: "KEY22", - Value: "value22", - }, - { - Key: "EMPTY", - Value: "", - }, - }, - }, - }, - }, - { - Files: map[string]ShellInitFile{ - "gawk.sh": { - Env: []EnvironmentVariable{ - { - Key: "AWKPATH", - Value: "$AWKPATH:$*", - }, - { - Key: "AWKLIBPATH", - Value: "$AWKLIBPATH:$*", - }, - }, - }, - "flatpak.sh": { - Env: []EnvironmentVariable{ - { - Key: "XDG_DATA_DIRS", - Value: "${new_dirs:+${new_dirs}:}${XDG_DATA_DIRS:-/usr/local/share:/usr/share}", - }, - }, - }, - }, - }, - } - - assert := assert.New(t) - for idx := range tests { - tt := tests[idx] - name := fmt.Sprintf("ValidShellInitStage-%d", idx) - t.Run(name, func(t *testing.T) { - assert.NoErrorf(tt.validate(), "%q returned an error [idx: %d]", name, idx) - assert.NotPanics(func() { NewShellInitStage(&tt) }) - }) - } -} - -func TestInvalidShellInitStageOptions(t *testing.T) { - tests := []ShellInitStageOptions{ - { - Files: map[string]ShellInitFile{ - - "path/filename": { - Env: []EnvironmentVariable{ - { - Key: "DOESNT", - Value: "matter", - }, - }, - }, - "ok": { - Env: []EnvironmentVariable{ - { - Key: "EMPTYOK", - Value: "", - }, - }, - }, - }, - }, - { - Files: map[string]ShellInitFile{ - "gawk.sh": { - Env: []EnvironmentVariable{ - { - Key: "", - Value: "badkey", - }, - }, - }, - }, - }, - { - Files: map[string]ShellInitFile{ - "$FILENAME": { - Env: []EnvironmentVariable{ - { - Key: "BAD", - Value: "filename", - }, - }, - }, - }, - }, - { - Files: map[string]ShellInitFile{ - "FILENAME": { - Env: []EnvironmentVariable{ - { - Key: "bad.var", - Value: "okval", - }, - }, - }, - }, - }, - { - Files: map[string]ShellInitFile{ - "FILENAME": { - Env: []EnvironmentVariable{ - { - Key: "BAD.VAR", - Value: "okval", - }, - }, - }, - }, - }, - { - Files: map[string]ShellInitFile{ - "me.sh": { - Env: []EnvironmentVariable{ - { - Key: "-SH", - Value: "", - }, - }, - }, - }, - }, - { - Files: map[string]ShellInitFile{ - "empty.sh": {}, - }, - }, - } - - assert := assert.New(t) - for idx := range tests { - tt := tests[idx] - name := fmt.Sprintf("InvalidShellInitStage-%d", idx) - t.Run(name, func(t *testing.T) { - assert.Errorf(tt.validate(), "%q didn't return an error [idx: %d]", name, idx) - assert.Panics(func() { NewShellInitStage(&tt) }) - }) - } -} diff --git a/internal/osbuild/skopeo_source_test.go b/internal/osbuild/skopeo_source_test.go deleted file mode 100644 index eeb9e2a01..000000000 --- a/internal/osbuild/skopeo_source_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" -) - -func TestNewSkopeoSource(t *testing.T) { - testDigest := "sha256:f29b6cd42a94a574583439addcd6694e6224f0e4b32044c9e3aee4c4856c2a50" - imageID := "sha256:c2ecf25cf190e76b12b07436ad5140d4ba53d8a136d498705e57a006837a720f" - - source := NewSkopeoSource() - - source.AddItem("name", testDigest, imageID, common.ToPtr(false)) - assert.Len(t, source.Items, 1) - - item, ok := source.Items[imageID] - assert.True(t, ok) - assert.Equal(t, item.Image.Name, "name") - assert.Equal(t, item.Image.Digest, testDigest) - assert.Equal(t, item.Image.TLSVerify, common.ToPtr(false)) - - testDigest = "sha256:d49eebefb6c7ce5505594bef652bd4adc36f413861bd44209d9b9486310b1264" - imageID = "sha256:d2ab8fea7f08a22f03b30c13c6ea443121f25e87202a7496e93736efa6fe345a" - - source.AddItem("name2", testDigest, imageID, nil) - assert.Len(t, source.Items, 2) - item, ok = source.Items[imageID] - assert.True(t, ok) - assert.Nil(t, item.Image.TLSVerify) - - // empty name - assert.Panics(t, func() { - source.AddItem("", testDigest, imageID, nil) - }) - - // empty digest - assert.Panics(t, func() { - source.AddItem("name", "", imageID, nil) - }) - - // empty image id - assert.Panics(t, func() { - source.AddItem("name", testDigest, "", nil) - }) - - // invalid digest - assert.Panics(t, func() { - source.AddItem("name", "foo", imageID, nil) - }) - - // invalid image id - assert.Panics(t, func() { - source.AddItem("name", testDigest, "sha256:foo", nil) - }) -} diff --git a/internal/osbuild/source_test.go b/internal/osbuild/source_test.go deleted file mode 100644 index a49b5f3fc..000000000 --- a/internal/osbuild/source_test.go +++ /dev/null @@ -1,115 +0,0 @@ -package osbuild - -import ( - "bytes" - "encoding/json" - "reflect" - "testing" -) - -func TestSource_UnmarshalJSON(t *testing.T) { - type fields struct { - Type string - Source Source - } - type args struct { - data []byte - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "invalid json", - args: args{ - data: []byte(`{"name":"org.osbuild.foo","options":{"bar":null}`), - }, - wantErr: true, - }, - { - name: "unknown source", - args: args{ - data: []byte(`{"name":"org.osbuild.foo","options":{"bar":null}}`), - }, - wantErr: true, - }, - { - name: "missing options", - args: args{ - data: []byte(`{"name":"org.osbuild.curl"}`), - }, - wantErr: true, - }, - { - name: "missing name", - args: args{ - data: []byte(`{"foo":null,"options":{"bar":null}}`), - }, - wantErr: true, - }, - { - name: "curl-empty", - fields: fields{ - Type: "org.osbuild.curl", - Source: &CurlSource{Items: map[string]CurlSourceItem{}}, - }, - args: args{ - data: []byte(`{"org.osbuild.curl":{"items":{}}}`), - }, - }, - { - name: "curl-with-secrets", - fields: fields{ - Type: "org.osbuild.curl", - Source: &CurlSource{ - Items: map[string]CurlSourceItem{ - "checksum1": CurlSourceOptions{URL: "url1", Secrets: &URLSecrets{Name: "org.osbuild.rhsm"}}, - "checksum2": CurlSourceOptions{URL: "url2", Secrets: &URLSecrets{Name: "whatever"}}, - }}, - }, - args: args{ - data: []byte(`{"org.osbuild.curl":{"items":{"checksum1":{"url":"url1","secrets":{"name":"org.osbuild.rhsm"}},"checksum2":{"url":"url2","secrets":{"name":"whatever"}}}}}`), - }, - }, - { - name: "curl-url-only", - fields: fields{ - Type: "org.osbuild.curl", - Source: &CurlSource{ - Items: map[string]CurlSourceItem{ - "checksum1": URL("url1"), - "checksum2": URL("url2"), - }}, - }, - args: args{ - data: []byte(`{"org.osbuild.curl":{"items":{"checksum1":"url1","checksum2":"url2"}}}`), - }, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - sources := &Sources{ - tt.fields.Type: tt.fields.Source, - } - var gotSources Sources - if err := gotSources.UnmarshalJSON(tt.args.data); (err != nil) != tt.wantErr { - t.Errorf("Sources.UnmarshalJSON() error = %v, wantErr %v [idx: %d]", err, tt.wantErr, idx) - } - if tt.wantErr { - return - } - gotBytes, err := json.Marshal(sources) - if err != nil { - t.Errorf("Could not marshal source: %v [idx: %d]", err, idx) - } - if !bytes.Equal(gotBytes, tt.args.data) { - t.Errorf("Expected '%v', got '%v' [idx: %d]", string(tt.args.data), string(gotBytes), idx) - } - if !reflect.DeepEqual(&gotSources, sources) { - t.Errorf("got '%v', expected '%v' [idx:%d]", &gotSources, sources, idx) - } - }) - } -} diff --git a/internal/osbuild/sshd_config_stage_test.go b/internal/osbuild/sshd_config_stage_test.go deleted file mode 100644 index d7372ff25..000000000 --- a/internal/osbuild/sshd_config_stage_test.go +++ /dev/null @@ -1,109 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" -) - -func TestNewSshdConfigStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.sshd.config", - Options: &SshdConfigStageOptions{}, - } - actualStage := NewSshdConfigStage(&SshdConfigStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestJsonSshdConfigStage(t *testing.T) { - // First test that the JSON can be parsed into the expected structure. - expectedOptions := SshdConfigStageOptions{ - Config: SshdConfigConfig{ - PasswordAuthentication: common.ToPtr(false), - ChallengeResponseAuthentication: common.ToPtr(false), - ClientAliveInterval: common.ToPtr(180), - PermitRootLogin: PermitRootLoginValueProhibitPassword, - }, - } - inputString := `{ - "config": { - "PasswordAuthentication": false, - "ChallengeResponseAuthentication": false, - "ClientAliveInterval": 180, - "PermitRootLogin": "prohibit-password" - } - }` - var inputOptions SshdConfigStageOptions - err := json.Unmarshal([]byte(inputString), &inputOptions) - assert.NoError(t, err, "failed to parse JSON into sshd config") - assert.True(t, reflect.DeepEqual(expectedOptions, inputOptions)) - - // Second try the other way around with stress on missing values - // for those parameters that the user didn't specify. - inputOptions = SshdConfigStageOptions{ - Config: SshdConfigConfig{ - PasswordAuthentication: common.ToPtr(true), - }, - } - expectedString := `{"config":{"PasswordAuthentication":true}}` - inputBytes, err := json.Marshal(inputOptions) - assert.NoError(t, err, "failed to marshal sshd config into JSON") - assert.Equal(t, expectedString, string(inputBytes)) -} - -func TestSshdConfigStageOptionsValidate(t *testing.T) { - tests := []struct { - name string - options SshdConfigStageOptions - err bool - }{ - { - name: "empty-options", - options: SshdConfigStageOptions{}, - err: false, - }, - { - name: "invalid-permit-root-login-str-value", - options: SshdConfigStageOptions{ - Config: SshdConfigConfig{ - PermitRootLogin: PermitRootLoginValueStr("invalid"), - }, - }, - err: true, - }, - { - name: "valid-permit-root-login-str-value-1", - options: SshdConfigStageOptions{ - Config: SshdConfigConfig{ - PermitRootLogin: PermitRootLoginValueForcedCommandsOnly, - }, - }, - err: false, - }, - { - name: "valid-permit-root-login-str-value-1", - options: SshdConfigStageOptions{ - Config: SshdConfigConfig{ - PermitRootLogin: PermitRootLoginValueProhibitPassword, - }, - }, - err: false, - }, - } - - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.err { - assert.Errorf(t, tt.options.validate(), "%q didn't return an error [idx: %d]", tt.name, idx) - assert.Panics(t, func() { NewSshdConfigStage(&tt.options) }) - } else { - assert.NoErrorf(t, tt.options.validate(), "%q returned an error [idx: %d]", tt.name, idx) - assert.NotPanics(t, func() { NewSshdConfigStage(&tt.options) }) - } - }) - } -} diff --git a/internal/osbuild/sysconfig_stage_test.go b/internal/osbuild/sysconfig_stage_test.go deleted file mode 100644 index 9fcc99cf9..000000000 --- a/internal/osbuild/sysconfig_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewSysconfigStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.sysconfig", - Options: &SysconfigStageOptions{}, - } - actualStage := NewSysconfigStage(&SysconfigStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/sysctld_stage_test.go b/internal/osbuild/sysctld_stage_test.go deleted file mode 100644 index dd601ffd5..000000000 --- a/internal/osbuild/sysctld_stage_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewSysctldStageOptions(t *testing.T) { - filename := "example.conf" - config := []SysctldConfigLine{{ - Key: "net.ipv4.conf.default.rp_filter", - Value: "2", - }} - - expectedOptions := &SysctldStageOptions{ - Filename: filename, - Config: config, - } - actualOptions := NewSysctldStageOptions(filename, config) - assert.Equal(t, expectedOptions, actualOptions) -} - -func TestNewSysctldStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.sysctld", - Options: &SysctldStageOptions{}, - } - actualStage := NewSysctldStage(&SysctldStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestSysctldStageOptions_MarshalJSON_Invalid(t *testing.T) { - tests := []struct { - name string - options SysctldStageOptions - }{ - { - name: "empty-options", - options: SysctldStageOptions{}, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotBytes, err := json.Marshal(tt.options) - assert.NotNilf(t, err, "json.Marshal() didn't return an error, but: %s [idx: %d]", string(gotBytes), idx) - }) - } -} - -func TestSysctldConfigLine_MarshalJSON_Invalid(t *testing.T) { - tests := []struct { - name string - options SysctldConfigLine - }{ - { - name: "no-value-without-prefix", - options: SysctldConfigLine{ - Key: "key-without-prefix", - }, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotBytes, err := json.Marshal(tt.options) - assert.NotNilf(t, err, "json.Marshal() didn't return an error, but: %s [idx: %d]", string(gotBytes), idx) - }) - } -} diff --git a/internal/osbuild/systemd_journald_stage_test.go b/internal/osbuild/systemd_journald_stage_test.go deleted file mode 100644 index 550147fed..000000000 --- a/internal/osbuild/systemd_journald_stage_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewSystemdJournalStage(t *testing.T) { - options := &SystemdJournaldStageOptions{ - Filename: "journald-config.conf", - Config: SystemdJournaldConfigDropin{ - Journal: SystemdJournaldConfigJournalSection{ - Storage: StoragePresistent, - Compress: "yes", - MaxFileSec: "10day", - Audit: AuditYes, - }, - }} - expectedStage := &Stage{ - Type: "org.osbuild.systemd-journald", - Options: options, - } - actualStage := NewSystemdJournaldStage(options) - assert.Equal(t, expectedStage, actualStage) -} - -func TestSystemdJournaldStage_ValidateInvalid(t *testing.T) { - tests := []struct { - name string - options SystemdJournaldStageOptions - }{ - { - name: "empty-options", - options: SystemdJournaldStageOptions{}, - }, - { - name: "no-journal-section-options", - options: SystemdJournaldStageOptions{ - Filename: "10-some-file.conf", - Config: SystemdJournaldConfigDropin{ - Journal: SystemdJournaldConfigJournalSection{}, - }, - }, - }, - } - for idx, te := range tests { - t.Run(te.name, func(t *testing.T) { - assert.Errorf(t, te.options.validate(), "%q didn't return an error [idx: %d]", te.name, idx) - assert.Panics(t, func() { NewSystemdJournaldStage(&te.options) }) - }) - } -} - -func TestInvalidFilename(t *testing.T) { - options := &SystemdJournaldStageOptions{ - Filename: "invalid-filename", - Config: SystemdJournaldConfigDropin{ - Journal: SystemdJournaldConfigJournalSection{ - Storage: StoragePresistent, - Compress: "yes", - MaxFileSec: "10day", - Audit: AuditYes, - }, - }, - } - - assert.Errorf(t, options.validate(), "test didn't return any error ") - assert.Panics(t, func() { NewSystemdJournaldStage(options) }) -} diff --git a/internal/osbuild/systemd_logind_stage_test.go b/internal/osbuild/systemd_logind_stage_test.go deleted file mode 100644 index 4c3f63e8a..000000000 --- a/internal/osbuild/systemd_logind_stage_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewSystemdLogindStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.systemd-logind", - Options: &SystemdLogindStageOptions{}, - } - actualStage := NewSystemdLogindStage(&SystemdLogindStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestSystemdLogindStage_MarshalJSON_Invalid(t *testing.T) { - tests := []struct { - name string - options SystemdLogindStageOptions - }{ - { - name: "empty-options", - options: SystemdLogindStageOptions{}, - }, - { - name: "no-section-options", - options: SystemdLogindStageOptions{ - Filename: "10-ec2-getty-fix.conf", - Config: SystemdLogindConfigDropin{ - Login: SystemdLogindConfigLoginSection{}, - }, - }, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotBytes, err := json.Marshal(tt.options) - assert.NotNilf(t, err, "json.Marshal() didn't return an error, but: %s [idx: %d]", string(gotBytes), idx) - }) - } -} diff --git a/internal/osbuild/systemd_stage_test.go b/internal/osbuild/systemd_stage_test.go deleted file mode 100644 index 7a47b2c33..000000000 --- a/internal/osbuild/systemd_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewSystemdStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.systemd", - Options: &SystemdStageOptions{}, - } - actualStage := NewSystemdStage(&SystemdStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/systemd_unit_stage_test.go b/internal/osbuild/systemd_unit_stage_test.go deleted file mode 100644 index 38059f768..000000000 --- a/internal/osbuild/systemd_unit_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewSystemdUnitStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.systemd.unit", - Options: &SystemdUnitStageOptions{}, - } - actualStage := NewSystemdUnitStage(&SystemdUnitStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/tar_stage_test.go b/internal/osbuild/tar_stage_test.go deleted file mode 100644 index 24888ac49..000000000 --- a/internal/osbuild/tar_stage_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewTarStage(t *testing.T) { - stageOptions := &TarStageOptions{Filename: "archive.tar.xz"} - stageInputs := &PipelineTreeInputs{"tree": TreeInput{ - inputCommon: inputCommon{ - Type: "org.osbuild.tree", - Origin: "org.osbuild.pipeline", - }, - References: []string{ - "name:pipeline33", - }, - }, - } - expectedStage := &Stage{ - Type: "org.osbuild.tar", - Options: stageOptions, - Inputs: stageInputs, - } - actualStage := NewTarStage(stageOptions, "pipeline33") - assert.Equal(t, expectedStage, actualStage) -} - -func TestTarStageOptionsValidate(t *testing.T) { - tests := []struct { - name string - options TarStageOptions - err bool - }{ - { - name: "empty-options", - options: TarStageOptions{}, - err: false, - }, - { - name: "invalid-archive-format", - options: TarStageOptions{ - Filename: "archive.tar.xz", - Format: "made-up-format", - }, - err: true, - }, - { - name: "invalid-root-node", - options: TarStageOptions{ - Filename: "archive.tar.xz", - RootNode: "I-don't-care", - }, - err: true, - }, - { - name: "valid-data", - options: TarStageOptions{ - Filename: "archive.tar.xz", - Format: TarArchiveFormatOldgnu, - RootNode: TarRootNodeOmit, - }, - err: false, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.err { - assert.Errorf(t, tt.options.validate(), "%q didn't return an error [idx: %d]", tt.name, idx) - assert.Panics(t, func() { NewTarStage(&tt.options, "") }) - } else { - assert.NoErrorf(t, tt.options.validate(), "%q returned an error [idx: %d]", tt.name, idx) - assert.NotPanics(t, func() { NewTarStage(&tt.options, "") }) - } - }) - } -} diff --git a/internal/osbuild/timezone_stage_test.go b/internal/osbuild/timezone_stage_test.go deleted file mode 100644 index 857ac5245..000000000 --- a/internal/osbuild/timezone_stage_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewTimezoneStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.timezone", - Options: &TimezoneStageOptions{}, - } - actualStage := NewTimezoneStage(&TimezoneStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/tmpfilesd_stage_test.go b/internal/osbuild/tmpfilesd_stage_test.go deleted file mode 100644 index eb2739bb8..000000000 --- a/internal/osbuild/tmpfilesd_stage_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewTmpfilesdStageOptions(t *testing.T) { - filename := "example.conf" - config := []TmpfilesdConfigLine{{ - Type: "d", - Path: "/tmp/my-example-path", - }} - - expectedOptions := &TmpfilesdStageOptions{ - Filename: filename, - Config: config, - } - actualOptions := NewTmpfilesdStageOptions(filename, config) - assert.Equal(t, expectedOptions, actualOptions) -} - -func TestNewTmpfilesdStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.tmpfilesd", - Options: &TmpfilesdStageOptions{}, - } - actualStage := NewTmpfilesdStage(&TmpfilesdStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestTmpfilesdStageOptions_MarshalJSON_Invalid(t *testing.T) { - tests := []struct { - name string - options TmpfilesdStageOptions - }{ - { - name: "empty-options", - options: TmpfilesdStageOptions{}, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotBytes, err := json.Marshal(tt.options) - assert.NotNilf(t, err, "json.Marshal() didn't return an error, but: %s [idx: %d]", string(gotBytes), idx) - }) - } -} diff --git a/internal/osbuild/truncate_stage_test.go b/internal/osbuild/truncate_stage_test.go deleted file mode 100644 index af8d79e03..000000000 --- a/internal/osbuild/truncate_stage_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewTruncateStage(t *testing.T) { - options := TruncateStageOptions{ - Filename: "image.raw", - Size: "42G", - } - expectedStage := &Stage{ - Type: "org.osbuild.truncate", - Options: &options, - } - actualStage := NewTruncateStage(&options) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/tuned_stage_test.go b/internal/osbuild/tuned_stage_test.go deleted file mode 100644 index 31c2c88c0..000000000 --- a/internal/osbuild/tuned_stage_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "fmt" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewTunedStageOptions(t *testing.T) { - tests := []struct { - profiles []string - expectedOptions *TunedStageOptions - }{ - { - profiles: []string{"balanced"}, - expectedOptions: &TunedStageOptions{Profiles: []string{"balanced"}}, - }, - { - profiles: []string{"balanced", "sap-hana"}, - expectedOptions: &TunedStageOptions{Profiles: []string{"balanced", "sap-hana"}}, - }, - } - - for idx, tt := range tests { - t.Run(fmt.Sprint(idx), func(t *testing.T) { - actualOptions := NewTunedStageOptions(tt.profiles...) - assert.Equalf(t, tt.expectedOptions, actualOptions, "NewTunedStageOptions() failed [idx: %d]", idx) - }) - } -} - -func TestNewTunedStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.tuned", - Options: &TunedStageOptions{}, - } - actualStage := NewTunedStage(&TunedStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestTunedStageOptions_MarshalJSON_Invalid(t *testing.T) { - tests := []struct { - name string - options TunedStageOptions - }{ - { - name: "empty-options", - options: TunedStageOptions{}, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotBytes, err := json.Marshal(tt.options) - assert.NotNilf(t, err, "json.Marshal() didn't return an error, but: %s [idx: %d]", string(gotBytes), idx) - }) - } -} diff --git a/internal/osbuild/udev_rules_stage_test.go b/internal/osbuild/udev_rules_stage_test.go deleted file mode 100644 index ff151ad02..000000000 --- a/internal/osbuild/udev_rules_stage_test.go +++ /dev/null @@ -1,184 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewUdevRulesStage(t *testing.T) { - stage := NewUdevRulesStage( - &UdevRulesStageOptions{ - Filename: "/etc/udev/udev.rules", - Rules: UdevRules{ - NewUdevRuleComment([]string{"This is a comment"}), - NewUdevRule( - []UdevKV{ - {K: "ACTION", O: "==", V: "add"}, - {K: "ENV", A: "OSBUILD", O: "=", V: "1"}, - }, - ), - }, - }, - ) - - want := &Stage{ - Type: "org.osbuild.udev.rules", - Options: &UdevRulesStageOptions{ - Filename: "/etc/udev/udev.rules", - Rules: UdevRules{ - UdevRuleComment{ - Comment: []string{"This is a comment"}, - }, - UdevOps{ - UdevOpSimple{ - Key: "ACTION", - Op: "==", - Value: "add", - }, - UdevOpArg{ - Key: UdevRuleKeyArg{ - Name: "ENV", - Arg: "OSBUILD", - }, - Op: "=", - Value: "1", - }, - }, - }, - }, - } - - assert.Equal(t, stage, want) -} - -func TestNewUdevRulesStageValidate(t *testing.T) { - assert := assert.New(t) - - tests := []struct { - name string - filename string - rules []UdevRule - }{ - { - name: "no filename", - rules: UdevRules{ - UdevRuleComment{ - Comment: []string{ - "This is a comment", - }, - }, - }, - }, - { - name: "wrong filename", - filename: "/etc/udev/udev.conf", - rules: UdevRules{ - UdevRuleComment{ - Comment: []string{ - "This is a comment", - }, - }, - }, - }, - { - name: "missing rules", - filename: "/etc/udev/rules.d/osbuild.rules", - }, - { - name: "empty rules", - filename: "/etc/udev/rules.d/osbuild.rules", - rules: UdevRules{}, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - assert.Panics(func() { - NewUdevRulesStage(&UdevRulesStageOptions{ - Filename: tt.filename, - Rules: tt.rules, - }) - }) - }) - } -} - -func TestUdevRuleValidation(t *testing.T) { - assert := assert.New(t) - - tests := []struct { - name string - rule UdevKV - }{ - { - name: "no key", - rule: UdevKV{ - O: "==", - V: "add", - }, - }, - { - name: "no op", - rule: UdevKV{ - K: "ACTION", - V: "add", - }, - }, - { - name: "no value", - rule: UdevKV{ - K: "ACTION", - O: "==", - }, - }, - { - name: "unknown key", - rule: UdevKV{ - K: "ACHILLEAS", - O: "==", - V: "RE GOMBARE", - }, - }, - { - name: "missing arg", - rule: UdevKV{ - K: "ENV", - O: "==", - V: "RE GOMBARE", - }, - }, - { - name: "unknown op", - rule: UdevKV{ - K: "ENV", - O: "?", - V: "RE GOMBARE", - }, - }, - { - name: "false assign", - rule: UdevKV{ - K: "ACTION", - O: "=", - V: "RE GOMBARE", - }, - }, - { - name: "false match", - rule: UdevKV{ - K: "OPTIONS", - O: "==", - V: "RE GOMBARE", - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - assert.Panics(func() { - NewUdevRule([]UdevKV{tt.rule}) - }) - }) - } -} diff --git a/internal/osbuild/users_stage_test.go b/internal/osbuild/users_stage_test.go deleted file mode 100644 index 5e0aa161c..000000000 --- a/internal/osbuild/users_stage_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package osbuild - -import ( - "strings" - "testing" - - "github.com/osbuild/osbuild-composer/internal/users" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestNewUsersStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.users", - Options: &UsersStageOptions{}, - } - actualStage := NewUsersStage(&UsersStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestNewUsersStageOptionsPassword(t *testing.T) { - Pass := "testpass" - EmptyPass := "" - CryptPass := "$6$RWdHzrPfoM6BMuIP$gKYlBXQuJgP.G2j2twbOyxYjFDPUQw8Jp.gWe1WD/obX0RMyfgw5vt.Mn/tLLX4mQjaklSiIzoAW3HrVQRg4Q." // #nosec G101 - - users := []users.User{ - { - Name: "bart", - Password: &Pass, - }, - { - Name: "lisa", - Password: &CryptPass, - }, - { - Name: "maggie", - Password: &EmptyPass, - }, - { - Name: "homer", - }, - } - - options, err := NewUsersStageOptions(users, false) - require.Nil(t, err) - require.NotNil(t, options) - - // bart's password should now be a hash - assert.True(t, strings.HasPrefix(*options.Users["bart"].Password, "$6$")) - - // lisa's password should be left alone (already hashed) - assert.Equal(t, CryptPass, *options.Users["lisa"].Password) - - // maggie's password should now be nil (locked account) - assert.Nil(t, options.Users["maggie"].Password) - - // homer's password should still be nil (locked account) - assert.Nil(t, options.Users["homer"].Password) -} diff --git a/internal/osbuild/xz_stage_test.go b/internal/osbuild/xz_stage_test.go deleted file mode 100644 index ff7e94f33..000000000 --- a/internal/osbuild/xz_stage_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewXzStageOptions(t *testing.T) { - filename := "image.raw.xz" - - expectedOptions := &XzStageOptions{ - Filename: filename, - } - - actualOptions := NewXzStageOptions(filename) - assert.Equal(t, expectedOptions, actualOptions) -} - -func TestNewXzStage(t *testing.T) { - inputFilename := "image.raw" - filename := "image.raw.xz" - pipeline := "os" - - expectedStage := &Stage{ - Type: "org.osbuild.xz", - Options: NewXzStageOptions(filename), - Inputs: NewXzStageInputs(NewFilesInputPipelineObjectRef(pipeline, inputFilename, nil)), - } - - actualStage := NewXzStage(NewXzStageOptions(filename), - NewXzStageInputs(NewFilesInputPipelineObjectRef(pipeline, inputFilename, nil))) - assert.Equal(t, expectedStage, actualStage) -} - -func TestNewXzStageNoInputs(t *testing.T) { - filename := "image.raw.xz" - - expectedStage := &Stage{ - Type: "org.osbuild.xz", - Options: &XzStageOptions{Filename: filename}, - Inputs: nil, - } - - actualStage := NewXzStage(&XzStageOptions{Filename: filename}, nil) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/osbuild/yum_config_stage_test.go b/internal/osbuild/yum_config_stage_test.go deleted file mode 100644 index 78282cd66..000000000 --- a/internal/osbuild/yum_config_stage_test.go +++ /dev/null @@ -1,113 +0,0 @@ -package osbuild - -import ( - "encoding/json" - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/osbuild/osbuild-composer/internal/common" -) - -func TestNewYumConfigStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.yum.config", - Options: &YumConfigStageOptions{}, - } - actualStage := NewYumConfigStage(&YumConfigStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} - -func TestJsonYumConfigStage(t *testing.T) { - expectedOptions := YumConfigStageOptions{ - Config: &YumConfigConfig{ - HttpCaching: common.ToPtr("packages"), - }, - Plugins: &YumConfigPlugins{ - &YumConfigPluginsLangpacks{ - Locales: []string{"en_US.UTF-8"}, - }, - }, - } - inputString := `{"config": { - "http_caching": "packages" - }, - "plugins": { - "langpacks": { - "locales": [ - "en_US.UTF-8" - ] - } - }}` - var inputOptions YumConfigStageOptions - err := json.Unmarshal([]byte(inputString), &inputOptions) - assert.NoError(t, err, "failed to parse JSON yum config") - assert.True(t, reflect.DeepEqual(expectedOptions, inputOptions)) - - inputOptions = YumConfigStageOptions{ - Config: &YumConfigConfig{ - HttpCaching: common.ToPtr("packages"), - }, - } - expectedString := `{"config":{"http_caching":"packages"}}` - inputBytes, err := json.Marshal(inputOptions) - assert.NoError(t, err, "failed to marshal YUM config into JSON") - assert.Equal(t, expectedString, string(inputBytes)) -} - -func TestYumConfigValidate(t *testing.T) { - tests := []struct { - options YumConfigStageOptions - valid bool - }{ - { - YumConfigStageOptions{}, - true, - }, - { - YumConfigStageOptions{ - Plugins: &YumConfigPlugins{ - Langpacks: &YumConfigPluginsLangpacks{ - Locales: []string{}, - }, - }, - }, - false, - }, - { - YumConfigStageOptions{ - Plugins: &YumConfigPlugins{ - Langpacks: &YumConfigPluginsLangpacks{ - Locales: []string{"en_US.UTF-8"}, - }, - }, - }, - true, - }, - { - YumConfigStageOptions{ - Config: &YumConfigConfig{ - HttpCaching: common.ToPtr(""), - }, - }, - false, - }, - { - YumConfigStageOptions{ - Config: &YumConfigConfig{ - HttpCaching: common.ToPtr("all"), - }, - }, - true, - }, - } - for _, test := range tests { - if test.valid { - require.NotPanics(t, func() { NewYumConfigStage(&test.options) }) - } else { - require.Panics(t, func() { NewYumConfigStage(&test.options) }) - } - } -} diff --git a/internal/osbuild/yum_repos_stage_test.go b/internal/osbuild/yum_repos_stage_test.go deleted file mode 100644 index 046533b37..000000000 --- a/internal/osbuild/yum_repos_stage_test.go +++ /dev/null @@ -1,188 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/rpmmd" -) - -func TestNewYumReposStage(t *testing.T) { - stageOptions := NewYumReposStageOptions("testing.repo", []rpmmd.RepoConfig{ - { - Id: "cool-id", - BaseURLs: []string{"http://example.org/repo"}, - }, - }) - expectedStage := &Stage{ - Type: "org.osbuild.yum.repos", - Options: stageOptions, - } - actualStage := NewYumReposStage(stageOptions) - assert.Equal(t, expectedStage, actualStage) -} - -func TestYumReposStageOptionsValidate(t *testing.T) { - tests := []struct { - name string - options YumReposStageOptions - err bool - }{ - { - name: "empty-options", - options: YumReposStageOptions{}, - err: true, - }, - { - name: "no-repos", - options: YumReposStageOptions{ - Filename: "test.repo", - Repos: []YumRepository{}, - }, - err: true, - }, - { - name: "invalid-filename", - options: YumReposStageOptions{ - Filename: "@#$%^&.rap", - Repos: []YumRepository{ - { - Id: "cool-id", - BaseURLs: []string{"http://example.org/repo"}, - }, - }, - }, - err: true, - }, - { - name: "no-filename", - options: YumReposStageOptions{ - Repos: []YumRepository{ - { - Id: "cool-id", - BaseURLs: []string{"http://example.org/repo"}, - }, - }, - }, - err: true, - }, - { - name: "no-baseurl-mirrorlist-metalink", - options: YumReposStageOptions{ - Filename: "test.repo", - Repos: []YumRepository{ - { - Id: "cool-id", - }, - }, - }, - err: true, - }, - { - name: "baseurl-empty-string", - options: YumReposStageOptions{ - Filename: "test.repo", - Repos: []YumRepository{ - { - Id: "cool-id", - BaseURLs: []string{""}, - }, - }, - }, - err: true, - }, - { - name: "gpgkey-empty-string", - options: YumReposStageOptions{ - Filename: "test.repo", - Repos: []YumRepository{ - { - Id: "cool-id", - BaseURLs: []string{"http://example.org/repo"}, - GPGKey: []string{""}, - }, - }, - }, - err: true, - }, - { - name: "invalid-repo-id", - options: YumReposStageOptions{ - Filename: "test.repo", - Repos: []YumRepository{ - { - Id: "c@@l-id", - BaseURLs: []string{"http://example.org/repo"}, - }, - }, - }, - err: true, - }, - { - name: "good-options-baseurl", - options: YumReposStageOptions{ - Filename: "test.repo", - Repos: []YumRepository{ - { - Id: "cool-id", - Cost: common.ToPtr(0), - Enabled: common.ToPtr(false), - ModuleHotfixes: common.ToPtr(false), - Name: "c@@l-name", - GPGCheck: common.ToPtr(true), - RepoGPGCheck: common.ToPtr(true), - BaseURLs: []string{"http://example.org/repo"}, - GPGKey: []string{"secretkey"}, - }, - }, - }, - err: false, - }, - { - name: "good-options-mirrorlist", - options: YumReposStageOptions{ - Filename: "test.repo", - Repos: []YumRepository{ - { - Id: "cool-id", - Cost: common.ToPtr(200), - Enabled: common.ToPtr(true), - ModuleHotfixes: common.ToPtr(true), - Name: "c@@l-name", - GPGCheck: common.ToPtr(false), - RepoGPGCheck: common.ToPtr(false), - Mirrorlist: "http://example.org/mirrorlist", - GPGKey: []string{"secretkey"}, - }, - }, - }, - err: false, - }, - { - name: "good-options-metalink", - options: YumReposStageOptions{ - Filename: "test.repo", - Repos: []YumRepository{ - { - Id: "cool-id", - Metalink: "http://example.org/metalink", - }, - }, - }, - err: false, - }, - } - for idx, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.err { - assert.Errorf(t, tt.options.validate(), "%q didn't return an error [idx: %d]", tt.name, idx) - assert.Panics(t, func() { NewYumReposStage(&tt.options) }) - } else { - assert.NoErrorf(t, tt.options.validate(), "%q returned an error [idx: %d]", tt.name, idx) - assert.NotPanics(t, func() { NewYumReposStage(&tt.options) }) - } - }) - } -} diff --git a/internal/osbuild/zipl_stage_test.go b/internal/osbuild/zipl_stage_test.go deleted file mode 100644 index 89a39ad04..000000000 --- a/internal/osbuild/zipl_stage_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package osbuild - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewZiplStageOptions(t *testing.T) { - expectedOptions := &ZiplStageOptions{ - Timeout: 0, - } - actualOptions := NewZiplStageOptions() - assert.Equal(t, expectedOptions, actualOptions) -} - -func TestNewZiplStage(t *testing.T) { - expectedStage := &Stage{ - Type: "org.osbuild.zipl", - Options: &ZiplStageOptions{}, - } - actualStage := NewZiplStage(&ZiplStageOptions{}) - assert.Equal(t, expectedStage, actualStage) -} diff --git a/internal/ostree/ostree_test.go b/internal/ostree/ostree_test.go deleted file mode 100644 index ca8abdf9e..000000000 --- a/internal/ostree/ostree_test.go +++ /dev/null @@ -1,120 +0,0 @@ -package ostree - -import ( - "fmt" - "net/http" - "net/http/httptest" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/osbuild/osbuild-composer/internal/ostree/test_mtls_server" - "github.com/osbuild/osbuild-composer/internal/rhsm" -) - -func TestOstreeResolveRef(t *testing.T) { - goodRef := "5330bb1b8820944567f519de66ad6354c729b6b490dea1c5a7ba320c9f147c58" - badRef := "not a ref" - - handler := http.NewServeMux() - handler.HandleFunc("/refs/heads/rhel/8/x86_64/edge", func(w http.ResponseWriter, r *http.Request) { - http.NotFound(w, r) - }) - handler.HandleFunc("/refs/heads/test_forbidden", func(w http.ResponseWriter, r *http.Request) { - http.Error(w, "", http.StatusForbidden) - }) - handler.HandleFunc("/refs/heads/get_bad_ref", func(w http.ResponseWriter, r *http.Request) { - fmt.Fprint(w, badRef) - }) - - handler.HandleFunc("/refs/heads/test_redir", func(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, "/refs/heads/valid/ostree/ref", http.StatusFound) - }) - handler.HandleFunc("/refs/heads/valid/ostree/ref", func(w http.ResponseWriter, r *http.Request) { - fmt.Fprint(w, goodRef) - }) - - srv := httptest.NewServer(handler) - defer srv.Close() - - mTLSSrv, err := test_mtls_server.NewMTLSServer(handler) - srv2 := mTLSSrv.Server - require.NoError(t, err) - defer srv2.Close() - subs := &rhsm.Subscriptions{ - Consumer: &rhsm.ConsumerSecrets{ - ConsumerKey: mTLSSrv.ClientKeyPath, - ConsumerCert: mTLSSrv.ClientCrtPath, - }, - } - - type srvConfig struct { - Srv *httptest.Server - RHSM bool - Subs *rhsm.Subscriptions - } - srvConfs := []srvConfig{ - srvConfig{ - Srv: srv, - RHSM: false, - Subs: nil, - }, - srvConfig{ - Srv: srv2, - RHSM: true, - Subs: subs, - }, - } - - type input struct { - location string - ref string - } - - for _, srvConf := range srvConfs { - validCases := map[input]string{ - {srvConf.Srv.URL, "test_redir"}: goodRef, - {srvConf.Srv.URL, "valid/ostree/ref"}: goodRef, - } - for in, expOut := range validCases { - out, err := ResolveRef(in.location, in.ref, srvConf.RHSM, srvConf.Subs, &mTLSSrv.CAPath) - assert.NoError(t, err) - assert.Equal(t, expOut, out) - } - - errCases := map[input]string{ - {"not-a-url", "a-bad-ref"}: "error sending request to ostree repository \"not-a-url/refs/heads/a-bad-ref\": Get \"not-a-url/refs/heads/a-bad-ref\": unsupported protocol scheme \"\"", - {"http://0.0.0.0:10/repo", "whatever"}: "error sending request to ostree repository \"http://0.0.0.0:10/repo/refs/heads/whatever\": Get \"http://0.0.0.0:10/repo/refs/heads/whatever\": dial tcp 0.0.0.0:10: connect: connection refused", - {srvConf.Srv.URL, "rhel/8/x86_64/edge"}: fmt.Sprintf("ostree repository \"%s/refs/heads/rhel/8/x86_64/edge\" returned status: 404 Not Found", srvConf.Srv.URL), - {srvConf.Srv.URL, "test_forbidden"}: fmt.Sprintf("ostree repository \"%s/refs/heads/test_forbidden\" returned status: 403 Forbidden", srvConf.Srv.URL), - {srvConf.Srv.URL, "get_bad_ref"}: fmt.Sprintf("ostree repository \"%s/refs/heads/get_bad_ref\" returned invalid reference", srvConf.Srv.URL), - } - for in, expMsg := range errCases { - _, err := ResolveRef(in.location, in.ref, srvConf.RHSM, srvConf.Subs, &mTLSSrv.CAPath) - assert.EqualError(t, err, expMsg) - } - } -} - -func TestVerifyRef(t *testing.T) { - cases := map[string]bool{ - "a_perfectly_valid_ref": true, - "another/valid/ref": true, - "this-one-has/all.the/_valid-/characters/even/_numbers_42": true, - "rhel/8/aarch64/edge": true, - "1337": true, - "1337/but/also/more": true, - "_good_start/ref": true, - "/bad/ref": false, - "invalid)characters": false, - "this/was/doing/fine/until/the/very/end/": false, - "-bad_start/ref": false, - ".another/bad/start": false, - "how/about/now?": false, - } - - for in, expOut := range cases { - assert.Equal(t, expOut, VerifyRef(in), in) - } -} diff --git a/internal/ostree/test_mtls_server/ca.crt b/internal/ostree/test_mtls_server/ca.crt deleted file mode 100644 index f4c00ef9c..000000000 --- a/internal/ostree/test_mtls_server/ca.crt +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDUzCCAjugAwIBAgIUQ2t8FSMBRHm94ydwULyQrxnKWi8wDQYJKoZIhvcNAQEL -BQAwFjEUMBIGA1UEAwwLb3NidWlsZC5vcmcwIBcNMjIxMDIxMTExNjI0WhgPMjEy -MjA5MjcxMTE2MjRaMBYxFDASBgNVBAMMC29zYnVpbGQub3JnMIIBIjANBgkqhkiG -9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoeBKaPFnQg7EOLWGyHuqYDQHgFpYxFLwgiiT -PMVDobebOnvR1NdSs7mFs339sXb+ld80KYUrgVTiqXIglWwLvWjbMqRGotN3iIc0 -C70o45VgAT0s5vUyvpw/OqSQ6i4fluGDnzhhmDGWfGMRK/NirvFTGMaxa81BopCH -HB13Vmcsfqgjukol1B3PN5lnjwXVtnYyy75VMZAazkpwF9SAycIKdoqcygUcEipQ -qSJOQ0m0bX4ridhnh4t7zHVeLDEhvK8BnBDRkCiy/mUo3U5MAC4KcYiU9wdjkuvw -eipDNLW8959RJmRmz0Y4BeWbxITo9DkBBG6n3cAePYKEZjRYWQIDAQABo4GWMIGT -MA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFDoE7SvomYFOMNT0Rmjk8aB4JEoS -MFEGA1UdIwRKMEiAFDoE7SvomYFOMNT0Rmjk8aB4JEoSoRqkGDAWMRQwEgYDVQQD -DAtvc2J1aWxkLm9yZ4IUQ2t8FSMBRHm94ydwULyQrxnKWi8wDgYDVR0PAQH/BAQD -AgGGMA0GCSqGSIb3DQEBCwUAA4IBAQAldZN2HiEhwgxvlIijOKTYpRaKJOjvpw5m -kltTQmkt9QVDgrAXQxI1APBM3HPYrwoLRmLE7rluQf46UBvrSi8l0KJWLw262UJF -m7oWPDq+cA1CgSO//bP+CDrYfNb4oxi/3ojLlkQy60lmdH0Gh4AuLNYBjNpoqleP -9VDRibR1hRU8XDwzcmDbEQvF6ql062XO8FM4R6Vv8dPpGaAReBPJekSHmzpsn5fi -k/B5yjYJBxK6++3lqPilX1BPhTH+5HfV+xIxNRhNbiizMmhBdfkpFLdSd+IYZfvn -040Z0QnwM43aWjza82TaX4reWgNUlZugehAcqxZPCS4IYS+BDfeo ------END CERTIFICATE----- diff --git a/internal/ostree/test_mtls_server/client.crt b/internal/ostree/test_mtls_server/client.crt deleted file mode 100644 index 749802ace..000000000 --- a/internal/ostree/test_mtls_server/client.crt +++ /dev/null @@ -1,85 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: - 12:8c:b9:0c:03:44:59:6b:01:ab:68:77:0e:02:9f:17:b9:b8:69:b9 - Signature Algorithm: sha256WithRSAEncryption - Issuer: CN=osbuild.org - Validity - Not Before: Oct 21 11:16:24 2022 GMT - Not After : Sep 27 11:16:24 2122 GMT - Subject: CN=client.osbuild.org/emailAddress=osbuild@example.com - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) - Modulus: - 00:d8:9b:ae:30:a2:5b:7c:e2:08:64:9b:25:e2:61: - fd:69:bb:25:7d:c2:ee:ca:c2:88:e0:96:5d:e7:d0: - 20:f3:a8:cd:8b:31:07:21:01:de:a2:92:c1:b0:f3: - 77:64:82:b3:e1:d0:2d:f4:ca:db:ea:d3:50:a2:f5: - 1e:e4:ea:49:ea:d3:68:46:09:3d:16:0a:20:54:64: - 20:35:2d:89:8d:55:48:75:63:0b:4a:1d:dd:8a:02: - 68:3d:8c:81:fd:60:be:cd:ac:e5:91:da:fd:bf:36: - 77:95:d8:4f:83:14:c2:c6:3f:9e:40:7d:2a:bd:4c: - a6:0d:75:41:30:5d:11:14:ad:11:56:79:58:c3:7b: - 94:b2:db:d1:c9:e3:84:0d:d5:7d:da:92:98:6f:ce: - db:37:2c:da:3a:3e:c9:35:38:67:8a:3b:36:d0:73: - 50:47:75:6e:53:94:55:6b:e4:c1:a4:bd:22:4d:b2: - bf:57:72:aa:a0:73:7e:b6:77:07:85:72:c0:1a:5f: - c1:cb:d9:57:38:54:0c:ed:73:ce:ba:83:5b:00:c4: - 09:62:5e:12:89:0f:a9:05:4e:1d:98:2e:c4:14:63: - 74:5e:16:0b:5f:ac:83:c0:e0:5b:0e:93:35:80:b7: - 8e:85:da:cd:fe:3f:83:c5:35:38:34:e0:de:3d:3e: - 2f:a7 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - X509v3 Subject Key Identifier: - 8F:ED:C1:36:46:5D:80:B7:A9:3A:B9:A5:65:FD:9C:F1:07:F9:3B:A0 - X509v3 Authority Key Identifier: - keyid:3A:04:ED:2B:E8:99:81:4E:30:D4:F4:46:68:E4:F1:A0:78:24:4A:12 - - X509v3 Key Usage: critical - Digital Signature, Non Repudiation, Key Encipherment - X509v3 Extended Key Usage: - TLS Web Client Authentication - X509v3 Subject Alternative Name: - DNS:client.osbuild.org, IP Address:127.0.0.1 - Signature Algorithm: sha256WithRSAEncryption - 8d:4f:f2:ab:1a:08:8f:04:f8:ac:b5:7d:0d:14:7a:38:0f:d6: - 63:72:b0:df:7f:22:d4:a9:bd:5a:f3:53:f2:d6:e4:f2:29:01: - fc:72:7e:df:e7:2a:be:9c:d5:90:2f:9a:60:d3:63:64:49:81: - 58:06:f5:6b:2f:92:80:44:28:2b:e2:95:e3:a0:8e:eb:ef:5c: - 83:e9:d0:02:35:79:8d:21:a5:8b:32:d0:e8:88:7f:c5:72:8c: - 49:5f:6d:d9:20:dc:de:9f:e7:58:bb:bb:7b:10:1a:f9:00:fa: - 8d:c5:ec:05:7d:1b:c5:ac:f5:4a:6b:d3:b7:19:99:bc:a0:dd: - d7:75:4a:06:69:9d:d5:87:9a:f6:50:30:b1:d3:96:4b:a8:67: - 19:55:1d:ab:c2:77:ff:23:85:a4:2d:40:de:cd:d6:50:8c:ee: - de:d8:92:77:4a:6a:06:ee:92:52:04:1e:e6:3f:ff:2d:d0:44: - 75:e8:e5:f1:a2:c5:f8:6b:28:92:67:f6:25:52:52:ae:0a:65: - a9:3f:2a:1e:70:a8:45:d5:5d:14:40:50:05:0d:af:91:8a:68: - 0d:2d:27:ed:32:2b:f4:9e:ac:35:00:ec:f4:07:e1:80:92:59: - a1:aa:3c:60:11:e1:b8:b5:df:14:b5:20:94:9b:cd:2d:a6:ab: - 74:f5:39:17 ------BEGIN CERTIFICATE----- -MIIDgDCCAmigAwIBAgIUEoy5DANEWWsBq2h3DgKfF7m4abkwDQYJKoZIhvcNAQEL -BQAwFjEUMBIGA1UEAwwLb3NidWlsZC5vcmcwIBcNMjIxMDIxMTExNjI0WhgPMjEy -MjA5MjcxMTE2MjRaMEExGzAZBgNVBAMMEmNsaWVudC5vc2J1aWxkLm9yZzEiMCAG -CSqGSIb3DQEJARYTb3NidWlsZEBleGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEB -BQADggEPADCCAQoCggEBANibrjCiW3ziCGSbJeJh/Wm7JX3C7srCiOCWXefQIPOo -zYsxByEB3qKSwbDzd2SCs+HQLfTK2+rTUKL1HuTqSerTaEYJPRYKIFRkIDUtiY1V -SHVjC0od3YoCaD2Mgf1gvs2s5ZHa/b82d5XYT4MUwsY/nkB9Kr1Mpg11QTBdERSt -EVZ5WMN7lLLb0cnjhA3VfdqSmG/O2zcs2jo+yTU4Z4o7NtBzUEd1blOUVWvkwaS9 -Ik2yv1dyqqBzfrZ3B4VywBpfwcvZVzhUDO1zzrqDWwDECWJeEokPqQVOHZguxBRj -dF4WC1+sg8DgWw6TNYC3joXazf4/g8U1ODTg3j0+L6cCAwEAAaOBmDCBlTAJBgNV -HRMEAjAAMB0GA1UdDgQWBBSP7cE2Rl2At6k6uaVl/ZzxB/k7oDAfBgNVHSMEGDAW -gBQ6BO0r6JmBTjDU9EZo5PGgeCRKEjAOBgNVHQ8BAf8EBAMCBeAwEwYDVR0lBAww -CgYIKwYBBQUHAwIwIwYDVR0RBBwwGoISY2xpZW50Lm9zYnVpbGQub3JnhwR/AAAB -MA0GCSqGSIb3DQEBCwUAA4IBAQCNT/KrGgiPBPistX0NFHo4D9ZjcrDffyLUqb1a -81Py1uTyKQH8cn7f5yq+nNWQL5pg02NkSYFYBvVrL5KARCgr4pXjoI7r71yD6dAC -NXmNIaWLMtDoiH/FcoxJX23ZINzen+dYu7t7EBr5APqNxewFfRvFrPVKa9O3GZm8 -oN3XdUoGaZ3Vh5r2UDCx05ZLqGcZVR2rwnf/I4WkLUDezdZQjO7e2JJ3SmoG7pJS -BB7mP/8t0ER16OXxosX4ayiSZ/YlUlKuCmWpPyoecKhF1V0UQFAFDa+RimgNLSft -Miv0nqw1AOz0B+GAklmhqjxgEeG4td8UtSCUm80tpqt09TkX ------END CERTIFICATE----- diff --git a/internal/ostree/test_mtls_server/client.key b/internal/ostree/test_mtls_server/client.key deleted file mode 100644 index 20384d6a3..000000000 --- a/internal/ostree/test_mtls_server/client.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDYm64wolt84ghk -myXiYf1puyV9wu7Kwojgll3n0CDzqM2LMQchAd6iksGw83dkgrPh0C30ytvq01Ci -9R7k6knq02hGCT0WCiBUZCA1LYmNVUh1YwtKHd2KAmg9jIH9YL7NrOWR2v2/NneV -2E+DFMLGP55AfSq9TKYNdUEwXREUrRFWeVjDe5Sy29HJ44QN1X3akphvzts3LNo6 -Psk1OGeKOzbQc1BHdW5TlFVr5MGkvSJNsr9Xcqqgc362dweFcsAaX8HL2Vc4VAzt -c866g1sAxAliXhKJD6kFTh2YLsQUY3ReFgtfrIPA4FsOkzWAt46F2s3+P4PFNTg0 -4N49Pi+nAgMBAAECggEBANR/Hcq+bGw+PqecAPVu1jF0lFok8yhc4fUZ7rPs3XbM -QiDsDydVczkgKf5TSuyCwL+mAH+mx0o+1luXhyBhq/RAQ4p5o8DMXF0OAP7KVqgd -Y0Et0jR6ygyLQgInppqQ335cwLZvFQISCA0rsQ1SP6ZHYRO490XQPRL01egBVTFm -rYXR2ntCFDuqwjy/XN/xzDQPSlgLNfE2MiCt8LaU+1DagdRLfSlFFMjOGIuOgxrU -sT6OyTv0l4EthuKBCyS8olX7Z+ChQ/q7YNqnHxZdKLYBNhG8MWBmSlHh5EOQs8oe -8elBXBMRRcylUCfuyePBy2FwGfbFdijeYuxZ708D9bECgYEA7z54QWrteDtyWDvp -bgh1pBN1XR4vJ9RXJ9YGCvexgemOnhJwqTpoVmpMuF9t0ytNP9t9iqpgTF1qJL7G -KtlfHZTGOW+3bqWzWxSmlmJ4l97akU1mroJLqYjKx3tAopcc4lVLg5jOhcJsj6iw -4qRU57QlOGejRoyU3H21pZRcEe8CgYEA58dcJixwWHLonfxcdAR2wdoV2hUpk9tS -lW/BrsDOoQW6cESwQopD0pfSNqqzLlpArCI+7A/ArzAz311dnM82dYmQCF+p6VJD -01Zh///67zS+/scHtij4aUHokoPAaSRcG5NrXV+M/tmxMbh2VbOiGLyZm1etPdhT -OWbSPPG8lckCgYEAjrh9lMjtESSlee2Du5hgVZkmEn7HMsOBmsoaoMBSrGVgJvxp -KQsm4yZWzkZfhfH3C3ks02QAPo4bnAASx80U6Nivx+PVUbSX4mXXWy8zMaZITRYX -g1NHP8PS9F2amWP8Xyjy+3ZU/YaWrLy9iPbvj6nv6k4pIRUMWNzFWBnBMxECgYEA -oXepIo7i1Tt4AlfEsK5LbVDY2EzV4kNwjNqGO4/mYxbygzPW9wQLq7JIp/zTRv9o -/oH9A8cVnPYfrQQGKy/P6KIkzTCX1guRZLFRJF7YGbzNMgDFxolURT+9HhTa/mRu -JmfU6/+c4g4V+2VeSuYRjtoUyLuT3PnPQLX40Kw3jMECgYBnjh8gKEyoySChHdiu -F3dGr1Q/d/XDdrtQ/oCyYKnCDixFLMJX0KEkLqJkCnXHMV9Mn0SPqJUq9elskYE8 -hQKo65nko0dH0faleM17Ox8j7fpjp0MEjzuO6T7LwibOk8dJnCG0mAoRQNRZW6GB -dLi37U3h2YWvQ8wnre5eBwgZpA== ------END PRIVATE KEY----- diff --git a/internal/ostree/test_mtls_server/http_mtls_server.go b/internal/ostree/test_mtls_server/http_mtls_server.go deleted file mode 100644 index 0a745734f..000000000 --- a/internal/ostree/test_mtls_server/http_mtls_server.go +++ /dev/null @@ -1,76 +0,0 @@ -package test_mtls_server - -import ( - "crypto/tls" - "crypto/x509" - "errors" - "fmt" - "net/http" - "net/http/httptest" - "os" - "path/filepath" -) - -type MTLSServer struct { - Server *httptest.Server - CAPath string - ClientKeyPath string - ClientCrtPath string -} - -func NewMTLSServer(handler http.Handler) (*MTLSServer, error) { - certsPath, err := filepath.Abs("test_mtls_server") - if err != nil { - return nil, err - } - - caPath := filepath.Join(certsPath, "ca.crt") - serverKeyPath := filepath.Join(certsPath, "server.key") - serverCrtPath := filepath.Join(certsPath, "server.crt") - clientKeyPath := filepath.Join(certsPath, "client.key") - clientCrtPath := filepath.Join(certsPath, "client.crt") - - caCertPem, err := os.ReadFile(caPath) - if err != nil { - return nil, err - } - - caPool := x509.NewCertPool() - ok := caPool.AppendCertsFromPEM(caCertPem) - if !ok { - return nil, fmt.Errorf("Unable to append ca cert (%s) to ca pool", caPath) - } - - serverCrt, err := tls.LoadX509KeyPair(serverCrtPath, serverKeyPath) - if err != nil { - return nil, err - } - - server := httptest.NewUnstartedServer(handler) - - server.TLS = &tls.Config{ - Certificates: []tls.Certificate{serverCrt}, - ClientAuth: tls.RequireAndVerifyClientCert, - ClientCAs: caPool, - MinVersion: tls.VersionTLS12, - VerifyPeerCertificate: func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error { - for _, chain := range verifiedChains { - for _, domain := range []string{"127.0.0.1", "localhost", "osbuild.org"} { - if chain[0].VerifyHostname(domain) == nil { - return nil - } - } - } - - return errors.New("domain not in allowlist") - }, - } - server.StartTLS() - - return &MTLSServer{ - Server: server, - CAPath: caPath, - ClientKeyPath: clientKeyPath, - ClientCrtPath: clientCrtPath, - }, nil -} diff --git a/internal/ostree/test_mtls_server/server.crt b/internal/ostree/test_mtls_server/server.crt deleted file mode 100644 index d8811f8f5..000000000 --- a/internal/ostree/test_mtls_server/server.crt +++ /dev/null @@ -1,88 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: - 03:98:ce:0d:99:59:1a:59:c5:51:23:64:c1:86:80:47:82:2a:2f:0e - Signature Algorithm: sha256WithRSAEncryption - Issuer: CN=osbuild.org - Validity - Not Before: Oct 21 11:16:24 2022 GMT - Not After : Sep 27 11:16:24 2122 GMT - Subject: CN=localhost/emailAddress=osbuild@example.com - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public-Key: (2048 bit) - Modulus: - 00:bb:8a:35:4b:56:c5:25:3d:85:ac:56:77:f0:a2: - f7:75:1a:4f:2e:10:d2:a5:15:07:83:9d:96:61:05: - 4d:09:fe:0f:bc:6f:3d:be:d9:8b:90:c2:9c:05:9f: - 92:4d:50:d2:63:da:e5:5e:95:e0:e4:96:db:d0:78: - d8:bb:e9:62:7d:80:6d:b5:42:be:24:8e:f3:15:f7: - ce:de:eb:1a:af:ee:5c:d7:e4:94:cf:f7:e2:e6:fc: - 65:a9:e0:d6:8b:f5:71:6a:af:dd:24:c5:0f:4a:a2: - 09:54:52:fe:05:ac:da:14:40:09:4a:f8:6a:fd:84: - 07:46:c2:5d:b1:ca:ee:8e:62:33:2b:a5:0c:9b:3a: - 34:aa:70:cc:77:1c:e6:0b:e8:7c:60:6f:a2:52:ac: - 15:5f:00:a5:6f:c2:22:8c:bf:59:f3:ee:89:4a:c9: - c3:a6:d3:c3:53:2e:eb:6d:c7:ee:fa:1a:83:06:17: - 00:08:dc:a5:2c:69:1c:4f:26:15:57:72:a1:42:97: - 41:98:9c:6c:db:43:0c:55:e4:41:86:bb:25:0e:37: - 04:17:04:03:fa:45:66:80:8a:e2:9f:66:8d:00:66: - ad:e1:a3:d0:63:0f:6d:a9:01:70:ab:5d:74:7f:73: - 62:17:6d:4d:b3:52:b2:78:34:b7:61:23:7e:fa:85: - e6:5f - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: critical - CA:FALSE - X509v3 Subject Key Identifier: - C0:2F:23:10:5D:C6:BC:97:76:50:71:FC:93:C1:47:59:02:FD:BC:23 - X509v3 Authority Key Identifier: - keyid:3A:04:ED:2B:E8:99:81:4E:30:D4:F4:46:68:E4:F1:A0:78:24:4A:12 - DirName:/CN=osbuild.org - serial:43:6B:7C:15:23:01:44:79:BD:E3:27:70:50:BC:90:AF:19:CA:5A:2F - - X509v3 Key Usage: critical - Digital Signature, Key Encipherment - X509v3 Extended Key Usage: - TLS Web Server Authentication - X509v3 Subject Alternative Name: - DNS:localhost, DNS:composer, IP Address:127.0.0.1 - Signature Algorithm: sha256WithRSAEncryption - 72:f9:19:12:a1:d3:f6:62:66:5b:42:cf:da:c6:62:93:c9:29: - 28:0e:4d:f0:c3:00:f2:c1:a5:10:7b:17:3b:21:2c:3c:96:6f: - b3:0b:e7:fb:69:56:21:fe:dd:ed:25:64:97:0a:5c:8a:ec:c0: - dc:49:b4:9f:14:19:cc:0b:dc:20:a1:09:25:3c:4d:65:8d:56: - c9:16:c0:e5:2c:8b:3f:5d:27:4d:81:0e:1f:77:5e:e6:7d:d7: - e7:96:4c:27:b6:25:e7:42:d1:70:85:7f:08:4c:46:1e:59:21: - 94:6a:f1:dc:2a:38:9e:14:1e:99:07:e3:9e:cc:81:37:55:62: - fb:98:33:4e:2c:fa:eb:9c:9c:3e:76:64:7d:73:62:9f:d0:08: - 5d:ee:34:f3:8d:53:28:6c:20:f8:8c:3b:c8:32:d3:82:2f:3f: - a1:da:f4:ae:48:96:6b:2c:4c:60:b6:d5:19:d1:63:3d:9b:bd: - c2:89:fa:c3:0c:57:80:51:ea:79:1c:2b:ad:29:a5:01:93:6a: - 4e:36:28:60:e6:f3:fd:09:a8:4e:8a:5c:51:31:30:f3:d1:c1: - 2d:e0:7c:23:25:91:6f:bb:a6:f8:5a:01:18:34:51:ed:f9:ab: - c8:ab:6b:29:0e:19:44:25:09:60:e0:7c:a0:0c:45:37:7b:2d: - 62:1d:b6:61 ------BEGIN CERTIFICATE----- -MIIDrTCCApWgAwIBAgIUA5jODZlZGlnFUSNkwYaAR4IqLw4wDQYJKoZIhvcNAQEL -BQAwFjEUMBIGA1UEAwwLb3NidWlsZC5vcmcwIBcNMjIxMDIxMTExNjI0WhgPMjEy -MjA5MjcxMTE2MjRaMDgxEjAQBgNVBAMMCWxvY2FsaG9zdDEiMCAGCSqGSIb3DQEJ -ARYTb3NidWlsZEBleGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC -AQoCggEBALuKNUtWxSU9haxWd/Ci93UaTy4Q0qUVB4OdlmEFTQn+D7xvPb7Zi5DC -nAWfkk1Q0mPa5V6V4OSW29B42LvpYn2AbbVCviSO8xX3zt7rGq/uXNfklM/34ub8 -Zang1ov1cWqv3STFD0qiCVRS/gWs2hRACUr4av2EB0bCXbHK7o5iMyulDJs6NKpw -zHcc5gvofGBvolKsFV8ApW/CIoy/WfPuiUrJw6bTw1Mu623H7voagwYXAAjcpSxp -HE8mFVdyoUKXQZicbNtDDFXkQYa7JQ43BBcEA/pFZoCK4p9mjQBmreGj0GMPbakB -cKtddH9zYhdtTbNSsng0t2EjfvqF5l8CAwEAAaOBzjCByzAMBgNVHRMBAf8EAjAA -MB0GA1UdDgQWBBTALyMQXca8l3ZQcfyTwUdZAv28IzBRBgNVHSMESjBIgBQ6BO0r -6JmBTjDU9EZo5PGgeCRKEqEapBgwFjEUMBIGA1UEAwwLb3NidWlsZC5vcmeCFENr -fBUjAUR5veMncFC8kK8ZylovMA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggr -BgEFBQcDATAkBgNVHREEHTAbgglsb2NhbGhvc3SCCGNvbXBvc2VyhwR/AAABMA0G -CSqGSIb3DQEBCwUAA4IBAQBy+RkSodP2YmZbQs/axmKTySkoDk3wwwDywaUQexc7 -ISw8lm+zC+f7aVYh/t3tJWSXClyK7MDcSbSfFBnMC9wgoQklPE1ljVbJFsDlLIs/ -XSdNgQ4fd17mfdfnlkwntiXnQtFwhX8ITEYeWSGUavHcKjieFB6ZB+OezIE3VWL7 -mDNOLPrrnJw+dmR9c2Kf0Ahd7jTzjVMobCD4jDvIMtOCLz+h2vSuSJZrLExgttUZ -0WM9m73CifrDDFeAUep5HCutKaUBk2pONihg5vP9CahOilxRMTDz0cEt4HwjJZFv -u6b4WgEYNFHt+avIq2spDhlEJQlg4HygDEU3ey1iHbZh ------END CERTIFICATE----- diff --git a/internal/ostree/test_mtls_server/server.key b/internal/ostree/test_mtls_server/server.key deleted file mode 100644 index 970d6c66e..000000000 --- a/internal/ostree/test_mtls_server/server.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC7ijVLVsUlPYWs -Vnfwovd1Gk8uENKlFQeDnZZhBU0J/g+8bz2+2YuQwpwFn5JNUNJj2uVeleDkltvQ -eNi76WJ9gG21Qr4kjvMV987e6xqv7lzX5JTP9+Lm/GWp4NaL9XFqr90kxQ9KoglU -Uv4FrNoUQAlK+Gr9hAdGwl2xyu6OYjMrpQybOjSqcMx3HOYL6Hxgb6JSrBVfAKVv -wiKMv1nz7olKycOm08NTLuttx+76GoMGFwAI3KUsaRxPJhVXcqFCl0GYnGzbQwxV -5EGGuyUONwQXBAP6RWaAiuKfZo0AZq3ho9BjD22pAXCrXXR/c2IXbU2zUrJ4NLdh -I376heZfAgMBAAECggEBAKwBGtg6gR6iypNBy0e9cFDLDIwnics2+mlQg7gAcKQV -jME7FdqRFFx04TyXGkwnMI+9GFokBNwjMQCHleDjMR4CSJzS1ioZogIoAmiaISPy -7txkHciQhl9sZqHkQWKkfp1nJuCujFPbQctBQxJZcrrX8K3+IcLa8QGJCv4iLaIQ -BMMBsqNlpok4qQavW2Bp79WbRSeGXEb4ce4bCjdZob8Qrhx+fCIflQoV2V5IGFTL -R163GGvzyoYxRQz7/35eMoWcCJAPNEN+nbx2V4HGPfnYq0LJGLLt5+wGa62IbHpU -nigDHfXXNPu1lpRjxMenSUJxQf1X/erYmphoWpfEF2ECgYEA41ZYVngSTClGBxKU -mYlYK5L+Lued6R3kqgMcxLd1zO4QdThvNASRe9oTee5JEOheQC0VoVwqEZ+mwoz8 -NueJc017w1HREgOG2WtZfnslKbVhg64XiaM3cK6WuEuWyYXy76cg+BFt025fheLw -4IC4+SNg1prXZQY2uI3kjLdEbcUCgYEA0y9Xa4yOcI8SZmcabMb1Ku708KNPcEpb -Vc56xnDpbdgU2BmXbZOGIxxz/7JtTyrh14Mq34n6L2ddtIREbQ1vgS3cR8uF2Lou -taviH2WdGpuR3SxXmjs5QOxzqf7Riza2Wg3fEctU3DsqrCITGZxhCQQnbm4lsyNc -O4DLzePtidMCgYBhazrnswSERpuPpFKxiL2TzqXGC9MLdpfqkvLdCZEdhFbhJJHi -xKJjZIw8D/SXnjvlXGyMfSY57yRS8n+SN54bHvUOOh1RjtlWij4LiVHfka578zp6 -7MpxKx/DUgEH0rLMJ95k73MUy5N7mEiIrCCYAqUY0bnDvOnuJD/wXQih0QKBgBY4 -tQosEBDn/RepYa5wgPuziTKI/KLkMBgnUePvnaBhTFAw4S42h7bKF6qgK8BY0srK -kohTDHBQgBuuj0SqVUFSggtL7xmO/btACtsi5hUWqZKMR+uCr9OVDdalaYcsiqOP -Mhm9O4Cw+RyDuV7Iha1dMoj8LhtbbSkVtFxFz4jhAoGAE83WDaeRwgYEO2l1P3vy -Rl9Ti2URwadhfid+c/Qmjmu8KMstPp+gPQvnpqkfANaTPE6d+1BjbmHnr5e7u2gY -Al4/pMR/bOD1SYdNECu11nYlFmSZniv95NZuoSvAiYm+SEAVM1vOCFLtB1lPWYkq -lH67FGOJr3Pe2R/oVa9Wcug= ------END PRIVATE KEY----- diff --git a/internal/reporegistry/reporegistry.go b/internal/reporegistry/reporegistry.go index a9ddf38c1..304f879b7 100644 --- a/internal/reporegistry/reporegistry.go +++ b/internal/reporegistry/reporegistry.go @@ -4,8 +4,8 @@ import ( "fmt" "reflect" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/rpmmd" ) // RepoRegistry represents a database of distro and architecture diff --git a/internal/reporegistry/reporegistry_test.go b/internal/reporegistry/reporegistry_test.go index b001e82c6..32a4cdf05 100644 --- a/internal/reporegistry/reporegistry_test.go +++ b/internal/reporegistry/reporegistry_test.go @@ -4,9 +4,9 @@ import ( "reflect" "testing" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/test_distro" + "github.com/osbuild/images/pkg/rpmmd" "github.com/stretchr/testify/assert" ) diff --git a/internal/rhsm/secrets_test.go b/internal/rhsm/secrets_test.go deleted file mode 100644 index c246b1553..000000000 --- a/internal/rhsm/secrets_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package rhsm - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -var VALID_REPO = `[jws] -name = Red Hat JBoss Web Server -baseurl = https://cdn.redhat.com/content/dist/middleware/jws/1.0/$basearch/os -enabled = 0 -gpgcheck = 1 -gpgkey = file:// -sslverify = 1 -sslcacert = /etc/rhsm/ca/redhat-uep.pem -sslclientkey = /etc/pki/entitlement/123-key.pem -sslclientcert = /etc/pki/entitlement/456.pem -metadata_expire = 86400 -enabled_metadata = 0 - -[rhel-atomic] -name = Red Hat Container Development Kit -baseurl = https://cdn.redhat.com/content/dist/rhel/atomic/7/7Server/$basearch/os -enabled = 0 -gpgcheck = 1 -gpgkey = http:// -sslverify = 1 -sslcacert = /etc/rhsm/ca/redhat-uep.pem -sslclientkey = /etc/pki/entitlement/789-key.pem -sslclientcert = /etc/pki/entitlement/101112.pem -metadata_expire = 86400 -enabled_metadata = 0 -` - -func TestParseRepoFile(t *testing.T) { - input := []byte(VALID_REPO) - repoFileContent, err := parseRepoFile(input) - require.NoError(t, err, "Failed to parse the .repo file") - subscriptions := Subscriptions{ - available: repoFileContent, - } - secrets, err := subscriptions.GetSecretsForBaseurl([]string{"https://cdn.redhat.com/content/dist/middleware/jws/1.0/x86_64/os"}, "x86_64", "") - require.NoError(t, err, "Failed to get secrets for a baseurl") - assert.Equal(t, secrets.SSLCACert, "/etc/rhsm/ca/redhat-uep.pem", "Unexpected path to the CA certificate") - assert.Equal(t, secrets.SSLClientCert, "/etc/pki/entitlement/456.pem", "Unexpected path to the client cert") - assert.Equal(t, secrets.SSLClientKey, "/etc/pki/entitlement/123-key.pem", "Unexpected path to the client key") -} diff --git a/internal/rpmmd/metadata_test.go b/internal/rpmmd/metadata_test.go deleted file mode 100644 index a2a5112db..000000000 --- a/internal/rpmmd/metadata_test.go +++ /dev/null @@ -1,140 +0,0 @@ -// a different package is used to prevent import cycles between `rpmmd` and `osbuild` -package rpmmd_test - -import ( - "sort" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" -) - -func TestRPMDeduplication(t *testing.T) { - assert := assert.New(t) - // start with metadata, that includes duplicates, convert, then deduplicate - metadata := osbuild.PipelineMetadata{ - "1": &osbuild.RPMStageMetadata{ - Packages: []osbuild.RPMPackageMetadata{ - // python38 twice - { - Name: "python38", - Version: "3.8.8", - Release: "4.module+el8.5.0+12205+a865257a", - Epoch: nil, - Arch: "x86_64", - SigMD5: "-", - SigPGP: "-", - SigGPG: "-", - }, - { - Name: "python38", - Version: "3.8.8", - Release: "4.module+el8.5.0+12205+a865257a", - Epoch: nil, - Arch: "x86_64", - SigMD5: "-", - SigPGP: "-", - SigGPG: "-", - }, - // made up package - { - Name: "unique", - Version: "1.90", - Release: "10", - Epoch: nil, - Arch: "aarch64", - SigMD5: ".", - SigPGP: ".", - SigGPG: ".", - }, - // made up package with epoch - { - Name: "package-with-epoch", - Version: "0.1", - Release: "a", - Epoch: common.ToPtr("8"), - Arch: "x86_64", - SigMD5: "*", - SigPGP: "*", - SigGPG: "*", - }, - }, - }, - // separate pipeline - "2": &osbuild.RPMStageMetadata{ - Packages: []osbuild.RPMPackageMetadata{ - // duplicate package with epoch - { - Name: "vim-minimal", - Version: "8.0.1763", - Release: "15.el8", - Epoch: common.ToPtr("2"), - Arch: "x86_64", - SigMD5: "v", - SigPGP: "v", - SigGPG: "v", - }, - { - Name: "vim-minimal", - Version: "8.0.1763", - Release: "15.el8", - Epoch: common.ToPtr("2"), - Arch: "x86_64", - SigMD5: "v", - SigPGP: "v", - SigGPG: "v", - }, - // package with same name but different version - { - Name: "dupename", - Version: "1", - Release: "1.el8", - Epoch: nil, - Arch: "x86_64", - SigMD5: "2", - SigPGP: "2", - SigGPG: "2", - }, - { - Name: "dupename", - Version: "2", - Release: "1.el8", - Epoch: nil, - Arch: "x86_64", - SigMD5: "2", - SigPGP: "2", - SigGPG: "2", - }, - }, - }, - } - - testNames := []string{"dupename", "dupename", "package-with-epoch", "python38", "python38", "unique", "vim-minimal", "vim-minimal"} - testNamesDeduped := []string{"dupename", "dupename", "package-with-epoch", "python38", "unique", "vim-minimal"} - - rpms := osbuild.OSBuildMetadataToRPMs(metadata) - - // basic sanity checks - assert.Len(rpms, 8) - - sortedNames := func(rpms []rpmmd.RPM) []string { - names := make([]string, len(rpms)) - for idx, rpm := range rpms { - names[idx] = rpm.Name - } - - sort.Strings(names) - return names - } - - names := sortedNames(rpms) - assert.Equal(names, testNames) - - deduped := rpmmd.DeduplicateRPMs(rpms) - assert.Len(deduped, 6) - dedupedNames := sortedNames(deduped) - assert.Equal(dedupedNames, testNamesDeduped) -} diff --git a/internal/rpmmd/repository_test.go b/internal/rpmmd/repository_test.go deleted file mode 100644 index 5ac270efe..000000000 --- a/internal/rpmmd/repository_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package rpmmd - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestPackageSpecGetEVRA(t *testing.T) { - specs := []PackageSpec{ - { - Name: "tmux", - Epoch: 0, - Version: "3.3a", - Release: "3.fc38", - Arch: "x86_64", - }, - { - Name: "grub2", - Epoch: 1, - Version: "2.06", - Release: "94.fc38", - Arch: "noarch", - }, - } - - assert.Equal(t, "3.3a-3.fc38.x86_64", specs[0].GetEVRA()) - assert.Equal(t, "1:2.06-94.fc38.noarch", specs[1].GetEVRA()) - -} - -func TestPackageSpecGetNEVRA(t *testing.T) { - specs := []PackageSpec{ - { - Name: "tmux", - Epoch: 0, - Version: "3.3a", - Release: "3.fc38", - Arch: "x86_64", - }, - { - Name: "grub2", - Epoch: 1, - Version: "2.06", - Release: "94.fc38", - Arch: "noarch", - }, - } - - assert.Equal(t, "tmux-3.3a-3.fc38.x86_64", specs[0].GetNEVRA()) - assert.Equal(t, "grub2-1:2.06-94.fc38.noarch", specs[1].GetNEVRA()) - -} diff --git a/internal/rpmmd/test/confpaths/priority1/repositories/test-distro.json b/internal/rpmmd/test/confpaths/priority1/repositories/test-distro.json deleted file mode 100644 index 96007b1f3..000000000 --- a/internal/rpmmd/test/confpaths/priority1/repositories/test-distro.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "test_arch": [ - { - "name": "fedora-p1", - "baseurl": "https://rpmrepo.osbuild.org/v1/anon/f33/f33-x86_64-fedora-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "updates-p1", - "baseurl": "https://rpmrepo.osbuild.org/v1/anon/f33/f33-x86_64-fedora-modular-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "fedora-modular-p1", - "baseurl": "https://rpmrepo.osbuild.org/v1/anon/f33/f33-x86_64-updates-released-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "updates-modular-p1", - "baseurl": "https://rpmrepo.osbuild.org/v1/anon/f33/f33-x86_64-updates-released-modular-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - } - ], - "test_arch2": [ - { - "name": "fedora-p1", - "metalink": "https://mirrors.fedoraproject.org/metalink?repo=fedora-33&arch=aarch64", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "updates-p1", - "metalink": "https://mirrors.fedoraproject.org/metalink?repo=updates-released-f33&arch=aarch64", - "metadata_expire": "6h", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "fedora-modular-p1", - "metalink": "https://mirrors.fedoraproject.org/metalink?repo=fedora-modular-33&arch=aarch64", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "updates-modular-p1", - "metalink": "https://mirrors.fedoraproject.org/metalink?repo=updates-released-modular-f33&arch=aarch64", - "metadata_expire": "6h", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - } - ] -} diff --git a/internal/rpmmd/test/confpaths/priority2/repositories/test-distro-2.json b/internal/rpmmd/test/confpaths/priority2/repositories/test-distro-2.json deleted file mode 100644 index 69eadc960..000000000 --- a/internal/rpmmd/test/confpaths/priority2/repositories/test-distro-2.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "test_arch": [ - { - "name": "baseos-p2", - "baseurl": "https://rpmrepo.osbuild.org/v1/psi/el8/el8-x86_64-baseos-8.4.0.n-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBErgSTsBEACh2A4b0O9t+vzC9VrVtL1AKvUWi9OPCjkvR7Xd8DtJxeeMZ5eF\n0HtzIG58qDRybwUe89FZprB1ffuUKzdE+HcL3FbNWSSOXVjZIersdXyH3NvnLLLF\n0DNRB2ix3bXG9Rh/RXpFsNxDp2CEMdUvbYCzE79K1EnUTVh1L0Of023FtPSZXX0c\nu7Pb5DI5lX5YeoXO6RoodrIGYJsVBQWnrWw4xNTconUfNPk0EGZtEnzvH2zyPoJh\nXGF+Ncu9XwbalnYde10OCvSWAZ5zTCpoLMTvQjWpbCdWXJzCm6G+/hx9upke546H\n5IjtYm4dTIVTnc3wvDiODgBKRzOl9rEOCIgOuGtDxRxcQkjrC+xvg5Vkqn7vBUyW\n9pHedOU+PoF3DGOM+dqv+eNKBvh9YF9ugFAQBkcG7viZgvGEMGGUpzNgN7XnS1gj\n/DPo9mZESOYnKceve2tIC87p2hqjrxOHuI7fkZYeNIcAoa83rBltFXaBDYhWAKS1\nPcXS1/7JzP0ky7d0L6Xbu/If5kqWQpKwUInXtySRkuraVfuK3Bpa+X1XecWi24JY\nHVtlNX025xx1ewVzGNCTlWn1skQN2OOoQTV4C8/qFpTW6DTWYurd4+fE0OJFJZQF\nbuhfXYwmRlVOgN5i77NTIJZJQfYFj38c/Iv5vZBPokO6mffrOTv3MHWVgQARAQAB\ntDNSZWQgSGF0LCBJbmMuIChyZWxlYXNlIGtleSAyKSA8c2VjdXJpdHlAcmVkaGF0\nLmNvbT6JAjYEEwECACAFAkrgSTsCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAK\nCRAZni+R/UMdUWzpD/9s5SFR/ZF3yjY5VLUFLMXIKUztNN3oc45fyLdTI3+UClKC\n2tEruzYjqNHhqAEXa2sN1fMrsuKec61Ll2NfvJjkLKDvgVIh7kM7aslNYVOP6BTf\nC/JJ7/ufz3UZmyViH/WDl+AYdgk3JqCIO5w5ryrC9IyBzYv2m0HqYbWfphY3uHw5\nun3ndLJcu8+BGP5F+ONQEGl+DRH58Il9Jp3HwbRa7dvkPgEhfFR+1hI+Btta2C7E\n0/2NKzCxZw7Lx3PBRcU92YKyaEihfy/aQKZCAuyfKiMvsmzs+4poIX7I9NQCJpyE\nIGfINoZ7VxqHwRn/d5mw2MZTJjbzSf+Um9YJyA0iEEyD6qjriWQRbuxpQXmlAJbh\n8okZ4gbVFv1F8MzK+4R8VvWJ0XxgtikSo72fHjwha7MAjqFnOq6eo6fEC/75g3NL\nGht5VdpGuHk0vbdENHMC8wS99e5qXGNDued3hlTavDMlEAHl34q2H9nakTGRF5Ki\nJUfNh3DVRGhg8cMIti21njiRh7gyFI2OccATY7bBSr79JhuNwelHuxLrCFpY7V25\nOFktl15jZJaMxuQBqYdBgSay2G0U6D1+7VsWufpzd/Abx1/c3oi9ZaJvW22kAggq\ndzdA27UUYjWvx42w9menJwh/0jeQcTecIUd0d0rFcw/c1pvgMMl/Q73yzKgKYw==\n=zbHE\n-----END PGP PUBLIC KEY BLOCK-----\n-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBFsy23UBEACUKSphFEIEvNpy68VeW4Dt6qv+mU6am9a2AAl10JANLj1oqWX+\noYk3en1S6cVe2qehSL5DGVa3HMUZkP3dtbD4SgzXzxPodebPcr4+0QNWigkUisri\nXGL5SCEcOP30zDhZvg+4mpO2jMi7Kc1DLPzBBkgppcX91wa0L1pQzBcvYMPyV/Dh\nKbQHR75WdkP6OA2JXdfC94nxYq+2e0iPqC1hCP3Elh+YnSkOkrawDPmoB1g4+ft/\nxsiVGVy/W0ekXmgvYEHt6si6Y8NwXgnTMqxeSXQ9YUgVIbTpsxHQKGy76T5lMlWX\n4LCOmEVomBJg1SqF6yi9Vu8TeNThaDqT4/DddYInd0OO69s0kGIXalVgGYiW2HOD\nx2q5R1VGCoJxXomz+EbOXY+HpKPOHAjU0DB9MxbU3S248LQ69nIB5uxysy0PSco1\nsdZ8sxRNQ9Dw6on0Nowx5m6Thefzs5iK3dnPGBqHTT43DHbnWc2scjQFG+eZhe98\nEll/kb6vpBoY4bG9/wCG9qu7jj9Z+BceCNKeHllbezVLCU/Hswivr7h2dnaEFvPD\nO4GqiWiwOF06XaBMVgxA8p2HRw0KtXqOpZk+o+sUvdPjsBw42BB96A1yFX4jgFNA\nPyZYnEUdP6OOv9HSjnl7k/iEkvHq/jGYMMojixlvXpGXhnt5jNyc4GSUJQARAQAB\ntDNSZWQgSGF0LCBJbmMuIChhdXhpbGlhcnkga2V5KSA8c2VjdXJpdHlAcmVkaGF0\nLmNvbT6JAjkEEwECACMFAlsy23UCGwMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIX\ngAAKCRD3b2bD1AgnknqOD/9fB2ASuG2aJIiap4kK58R+RmOVM4qgclAnaG57+vjI\nnKvyfV3NH/keplGNRxwqHekfPCqvkpABwhdGEXIE8ILqnPewIMr6PZNZWNJynZ9i\neSMzVuCG7jDoGyQ5/6B0f6xeBtTeBDiRl7+Alehet1twuGL1BJUYG0QuLgcEzkaE\n/gkuumeVcazLzz7L12D22nMk66GxmgXfqS5zcbqOAuZwaA6VgSEgFdV2X2JU79zS\nBQJXv7NKc+nDXFG7M7EHjY3Rma3HXkDbkT8bzh9tJV7Z7TlpT829pStWQyoxKCVq\nsEX8WsSapTKA3P9YkYCwLShgZu4HKRFvHMaIasSIZWzLu+RZH/4yyHOhj0QB7XMY\neHQ6fGSbtJ+K6SrpHOOsKQNAJ0hVbSrnA1cr5+2SDfel1RfYt0W9FA6DoH/S5gAR\ndzT1u44QVwwp3U+eFpHphFy//uzxNMtCjjdkpzhYYhOCLNkDrlRPb+bcoL/6ePSr\n016PA7eEnuC305YU1Ml2WcCn7wQV8x90o33klJmEkWtXh3X39vYtI4nCPIvZn1eP\nVy+F+wWt4vN2b8oOdlzc2paOembbCo2B+Wapv5Y9peBvlbsDSgqtJABfK8KQq/jK\nYl3h5elIa1I3uNfczeHOnf1enLOUOlq630yeM/yHizz99G1g+z/guMh5+x/OHraW\niLkCDQRbMtt1ARAA1lNsWklhS9LoBdolTVtg65FfdFJr47pzKRGYIoGLbcJ155ND\nG+P8UrM06E/ah06EEWuvu2YyyYAz1iYGsCwHAXtbEJh+1tF0iOVx2vnZPgtIGE9V\nP95V5ZvWvB3bdke1z8HadDA+/Ve7fbwXXLa/z9QhSQgsJ8NS8KYnDDjI4EvQtv0i\nPVLY8+u8z6VyiV9RJyn8UEZEJdbFDF9AZAT8103w8SEo/cvIoUbVKZLGcXdAIjCa\ny04u6jsrMp9UGHZX7+srT+9YHDzQixei4IdmxUcqtiNR2/bFHpHCu1pzYjXj968D\n8Ng2txBXDgs16BF/9l++GWKz2dOSH0jdS6sFJ/Dmg7oYnJ2xKSJEmcnV8Z0M1n4w\nXR1t/KeKZe3aR+RXCAEVC5dQ3GbRW2+WboJ6ldgFcVcOv6iOSWP9TrLzFPOpCsIr\nnHE+cMBmPHq3dUm7KeYXQ6wWWmtXlw6widf7cBcGFeELpuU9klzqdKze8qo2oMkf\nrfxIq8zdciPxZXb/75dGWs6dLHQmDpo4MdQVskw5vvwHicMpUpGpxkX7X1XAfdQf\nyIHLGT4ZXuMLIMUPdzJE0Vwt/RtJrZ+feLSv/+0CkkpGHORYroGwIBrJ2RikgcV2\nbc98V/27Kz2ngUCEwnmlhIcrY4IGAAZzUAl0GLHSevPbAREu4fDW4Y+ztOsAEQEA\nAYkCHwQYAQIACQUCWzLbdQIbDAAKCRD3b2bD1AgnkusfD/9U4sPtZfMw6cII167A\nXRZOO195G7oiAnBUw5AW6EK0SAHVZcuW0LMMXnGe9f4UsEUgCNwo5mvLWPxzKqFq\n6/G3kEZVFwZ0qrlLoJPeHNbOcfkeZ9NgD/OhzQmdylM0IwGM9DMrm2YS4EVsmm2b\n53qKIfIyysp1yAGcTnBwBbZ85osNBl2KRDIPhMs0bnmGB7IAvwlSb+xm6vWKECkO\nlwQDO5Kg8YZ8+Z3pn/oS688t/fPXvWLZYUqwR63oWfIaPJI7Ahv2jJmgw1ofL81r\n2CE3T/OydtUeGLzqWJAB8sbUgT3ug0cjtxsHuroQBSYBND3XDb/EQh5GeVVnGKKH\ngESLFAoweoNjDSXrlIu1gFjCDHF4CqBRmNYKrNQjLmhCrSfwkytXESJwlLzFKY8P\nK1yZyTpDC9YK0G7qgrk7EHmH9JAZTQ5V65pp0vR9KvqTU5ewkQDIljD2f3FIqo2B\nSKNCQE+N6NjWaTeNlU75m+yZocKObSPg0zS8FAuSJetNtzXA7ouqk34OoIMQj4gq\nUnh/i1FcZAd4U6Dtr9aRZ6PeLlm6MJ/h582L6fJLNEu136UWDtJj5eBYEzX13l+d\nSC4PEHx7ZZRwQKptl9NkinLZGJztg175paUu8C34sAv+SQnM20c0pdOXAq9GKKhi\nvt61kpkXoRGxjTlc6h+69aidSg==\n=ls8J\n-----END PGP PUBLIC KEY BLOCK-----\n" - }, - { - "name": "appstream-p2", - "baseurl": "https://rpmrepo.osbuild.org/v1/psi/el8/el8-x86_64-appstream-8.4.0.n-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBErgSTsBEACh2A4b0O9t+vzC9VrVtL1AKvUWi9OPCjkvR7Xd8DtJxeeMZ5eF\n0HtzIG58qDRybwUe89FZprB1ffuUKzdE+HcL3FbNWSSOXVjZIersdXyH3NvnLLLF\n0DNRB2ix3bXG9Rh/RXpFsNxDp2CEMdUvbYCzE79K1EnUTVh1L0Of023FtPSZXX0c\nu7Pb5DI5lX5YeoXO6RoodrIGYJsVBQWnrWw4xNTconUfNPk0EGZtEnzvH2zyPoJh\nXGF+Ncu9XwbalnYde10OCvSWAZ5zTCpoLMTvQjWpbCdWXJzCm6G+/hx9upke546H\n5IjtYm4dTIVTnc3wvDiODgBKRzOl9rEOCIgOuGtDxRxcQkjrC+xvg5Vkqn7vBUyW\n9pHedOU+PoF3DGOM+dqv+eNKBvh9YF9ugFAQBkcG7viZgvGEMGGUpzNgN7XnS1gj\n/DPo9mZESOYnKceve2tIC87p2hqjrxOHuI7fkZYeNIcAoa83rBltFXaBDYhWAKS1\nPcXS1/7JzP0ky7d0L6Xbu/If5kqWQpKwUInXtySRkuraVfuK3Bpa+X1XecWi24JY\nHVtlNX025xx1ewVzGNCTlWn1skQN2OOoQTV4C8/qFpTW6DTWYurd4+fE0OJFJZQF\nbuhfXYwmRlVOgN5i77NTIJZJQfYFj38c/Iv5vZBPokO6mffrOTv3MHWVgQARAQAB\ntDNSZWQgSGF0LCBJbmMuIChyZWxlYXNlIGtleSAyKSA8c2VjdXJpdHlAcmVkaGF0\nLmNvbT6JAjYEEwECACAFAkrgSTsCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAK\nCRAZni+R/UMdUWzpD/9s5SFR/ZF3yjY5VLUFLMXIKUztNN3oc45fyLdTI3+UClKC\n2tEruzYjqNHhqAEXa2sN1fMrsuKec61Ll2NfvJjkLKDvgVIh7kM7aslNYVOP6BTf\nC/JJ7/ufz3UZmyViH/WDl+AYdgk3JqCIO5w5ryrC9IyBzYv2m0HqYbWfphY3uHw5\nun3ndLJcu8+BGP5F+ONQEGl+DRH58Il9Jp3HwbRa7dvkPgEhfFR+1hI+Btta2C7E\n0/2NKzCxZw7Lx3PBRcU92YKyaEihfy/aQKZCAuyfKiMvsmzs+4poIX7I9NQCJpyE\nIGfINoZ7VxqHwRn/d5mw2MZTJjbzSf+Um9YJyA0iEEyD6qjriWQRbuxpQXmlAJbh\n8okZ4gbVFv1F8MzK+4R8VvWJ0XxgtikSo72fHjwha7MAjqFnOq6eo6fEC/75g3NL\nGht5VdpGuHk0vbdENHMC8wS99e5qXGNDued3hlTavDMlEAHl34q2H9nakTGRF5Ki\nJUfNh3DVRGhg8cMIti21njiRh7gyFI2OccATY7bBSr79JhuNwelHuxLrCFpY7V25\nOFktl15jZJaMxuQBqYdBgSay2G0U6D1+7VsWufpzd/Abx1/c3oi9ZaJvW22kAggq\ndzdA27UUYjWvx42w9menJwh/0jeQcTecIUd0d0rFcw/c1pvgMMl/Q73yzKgKYw==\n=zbHE\n-----END PGP PUBLIC KEY BLOCK-----\n-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBFsy23UBEACUKSphFEIEvNpy68VeW4Dt6qv+mU6am9a2AAl10JANLj1oqWX+\noYk3en1S6cVe2qehSL5DGVa3HMUZkP3dtbD4SgzXzxPodebPcr4+0QNWigkUisri\nXGL5SCEcOP30zDhZvg+4mpO2jMi7Kc1DLPzBBkgppcX91wa0L1pQzBcvYMPyV/Dh\nKbQHR75WdkP6OA2JXdfC94nxYq+2e0iPqC1hCP3Elh+YnSkOkrawDPmoB1g4+ft/\nxsiVGVy/W0ekXmgvYEHt6si6Y8NwXgnTMqxeSXQ9YUgVIbTpsxHQKGy76T5lMlWX\n4LCOmEVomBJg1SqF6yi9Vu8TeNThaDqT4/DddYInd0OO69s0kGIXalVgGYiW2HOD\nx2q5R1VGCoJxXomz+EbOXY+HpKPOHAjU0DB9MxbU3S248LQ69nIB5uxysy0PSco1\nsdZ8sxRNQ9Dw6on0Nowx5m6Thefzs5iK3dnPGBqHTT43DHbnWc2scjQFG+eZhe98\nEll/kb6vpBoY4bG9/wCG9qu7jj9Z+BceCNKeHllbezVLCU/Hswivr7h2dnaEFvPD\nO4GqiWiwOF06XaBMVgxA8p2HRw0KtXqOpZk+o+sUvdPjsBw42BB96A1yFX4jgFNA\nPyZYnEUdP6OOv9HSjnl7k/iEkvHq/jGYMMojixlvXpGXhnt5jNyc4GSUJQARAQAB\ntDNSZWQgSGF0LCBJbmMuIChhdXhpbGlhcnkga2V5KSA8c2VjdXJpdHlAcmVkaGF0\nLmNvbT6JAjkEEwECACMFAlsy23UCGwMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIX\ngAAKCRD3b2bD1AgnknqOD/9fB2ASuG2aJIiap4kK58R+RmOVM4qgclAnaG57+vjI\nnKvyfV3NH/keplGNRxwqHekfPCqvkpABwhdGEXIE8ILqnPewIMr6PZNZWNJynZ9i\neSMzVuCG7jDoGyQ5/6B0f6xeBtTeBDiRl7+Alehet1twuGL1BJUYG0QuLgcEzkaE\n/gkuumeVcazLzz7L12D22nMk66GxmgXfqS5zcbqOAuZwaA6VgSEgFdV2X2JU79zS\nBQJXv7NKc+nDXFG7M7EHjY3Rma3HXkDbkT8bzh9tJV7Z7TlpT829pStWQyoxKCVq\nsEX8WsSapTKA3P9YkYCwLShgZu4HKRFvHMaIasSIZWzLu+RZH/4yyHOhj0QB7XMY\neHQ6fGSbtJ+K6SrpHOOsKQNAJ0hVbSrnA1cr5+2SDfel1RfYt0W9FA6DoH/S5gAR\ndzT1u44QVwwp3U+eFpHphFy//uzxNMtCjjdkpzhYYhOCLNkDrlRPb+bcoL/6ePSr\n016PA7eEnuC305YU1Ml2WcCn7wQV8x90o33klJmEkWtXh3X39vYtI4nCPIvZn1eP\nVy+F+wWt4vN2b8oOdlzc2paOembbCo2B+Wapv5Y9peBvlbsDSgqtJABfK8KQq/jK\nYl3h5elIa1I3uNfczeHOnf1enLOUOlq630yeM/yHizz99G1g+z/guMh5+x/OHraW\niLkCDQRbMtt1ARAA1lNsWklhS9LoBdolTVtg65FfdFJr47pzKRGYIoGLbcJ155ND\nG+P8UrM06E/ah06EEWuvu2YyyYAz1iYGsCwHAXtbEJh+1tF0iOVx2vnZPgtIGE9V\nP95V5ZvWvB3bdke1z8HadDA+/Ve7fbwXXLa/z9QhSQgsJ8NS8KYnDDjI4EvQtv0i\nPVLY8+u8z6VyiV9RJyn8UEZEJdbFDF9AZAT8103w8SEo/cvIoUbVKZLGcXdAIjCa\ny04u6jsrMp9UGHZX7+srT+9YHDzQixei4IdmxUcqtiNR2/bFHpHCu1pzYjXj968D\n8Ng2txBXDgs16BF/9l++GWKz2dOSH0jdS6sFJ/Dmg7oYnJ2xKSJEmcnV8Z0M1n4w\nXR1t/KeKZe3aR+RXCAEVC5dQ3GbRW2+WboJ6ldgFcVcOv6iOSWP9TrLzFPOpCsIr\nnHE+cMBmPHq3dUm7KeYXQ6wWWmtXlw6widf7cBcGFeELpuU9klzqdKze8qo2oMkf\nrfxIq8zdciPxZXb/75dGWs6dLHQmDpo4MdQVskw5vvwHicMpUpGpxkX7X1XAfdQf\nyIHLGT4ZXuMLIMUPdzJE0Vwt/RtJrZ+feLSv/+0CkkpGHORYroGwIBrJ2RikgcV2\nbc98V/27Kz2ngUCEwnmlhIcrY4IGAAZzUAl0GLHSevPbAREu4fDW4Y+ztOsAEQEA\nAYkCHwQYAQIACQUCWzLbdQIbDAAKCRD3b2bD1AgnkusfD/9U4sPtZfMw6cII167A\nXRZOO195G7oiAnBUw5AW6EK0SAHVZcuW0LMMXnGe9f4UsEUgCNwo5mvLWPxzKqFq\n6/G3kEZVFwZ0qrlLoJPeHNbOcfkeZ9NgD/OhzQmdylM0IwGM9DMrm2YS4EVsmm2b\n53qKIfIyysp1yAGcTnBwBbZ85osNBl2KRDIPhMs0bnmGB7IAvwlSb+xm6vWKECkO\nlwQDO5Kg8YZ8+Z3pn/oS688t/fPXvWLZYUqwR63oWfIaPJI7Ahv2jJmgw1ofL81r\n2CE3T/OydtUeGLzqWJAB8sbUgT3ug0cjtxsHuroQBSYBND3XDb/EQh5GeVVnGKKH\ngESLFAoweoNjDSXrlIu1gFjCDHF4CqBRmNYKrNQjLmhCrSfwkytXESJwlLzFKY8P\nK1yZyTpDC9YK0G7qgrk7EHmH9JAZTQ5V65pp0vR9KvqTU5ewkQDIljD2f3FIqo2B\nSKNCQE+N6NjWaTeNlU75m+yZocKObSPg0zS8FAuSJetNtzXA7ouqk34OoIMQj4gq\nUnh/i1FcZAd4U6Dtr9aRZ6PeLlm6MJ/h582L6fJLNEu136UWDtJj5eBYEzX13l+d\nSC4PEHx7ZZRwQKptl9NkinLZGJztg175paUu8C34sAv+SQnM20c0pdOXAq9GKKhi\nvt61kpkXoRGxjTlc6h+69aidSg==\n=ls8J\n-----END PGP PUBLIC KEY BLOCK-----\n" - } - ], - "test_arch2": [ - { - "name": "baseos-p2", - "baseurl": "https://rpmrepo.osbuild.org/v1/psi/el8/el8-aarch64-baseos-8.4.0.n-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBErgSTsBEACh2A4b0O9t+vzC9VrVtL1AKvUWi9OPCjkvR7Xd8DtJxeeMZ5eF\n0HtzIG58qDRybwUe89FZprB1ffuUKzdE+HcL3FbNWSSOXVjZIersdXyH3NvnLLLF\n0DNRB2ix3bXG9Rh/RXpFsNxDp2CEMdUvbYCzE79K1EnUTVh1L0Of023FtPSZXX0c\nu7Pb5DI5lX5YeoXO6RoodrIGYJsVBQWnrWw4xNTconUfNPk0EGZtEnzvH2zyPoJh\nXGF+Ncu9XwbalnYde10OCvSWAZ5zTCpoLMTvQjWpbCdWXJzCm6G+/hx9upke546H\n5IjtYm4dTIVTnc3wvDiODgBKRzOl9rEOCIgOuGtDxRxcQkjrC+xvg5Vkqn7vBUyW\n9pHedOU+PoF3DGOM+dqv+eNKBvh9YF9ugFAQBkcG7viZgvGEMGGUpzNgN7XnS1gj\n/DPo9mZESOYnKceve2tIC87p2hqjrxOHuI7fkZYeNIcAoa83rBltFXaBDYhWAKS1\nPcXS1/7JzP0ky7d0L6Xbu/If5kqWQpKwUInXtySRkuraVfuK3Bpa+X1XecWi24JY\nHVtlNX025xx1ewVzGNCTlWn1skQN2OOoQTV4C8/qFpTW6DTWYurd4+fE0OJFJZQF\nbuhfXYwmRlVOgN5i77NTIJZJQfYFj38c/Iv5vZBPokO6mffrOTv3MHWVgQARAQAB\ntDNSZWQgSGF0LCBJbmMuIChyZWxlYXNlIGtleSAyKSA8c2VjdXJpdHlAcmVkaGF0\nLmNvbT6JAjYEEwECACAFAkrgSTsCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAK\nCRAZni+R/UMdUWzpD/9s5SFR/ZF3yjY5VLUFLMXIKUztNN3oc45fyLdTI3+UClKC\n2tEruzYjqNHhqAEXa2sN1fMrsuKec61Ll2NfvJjkLKDvgVIh7kM7aslNYVOP6BTf\nC/JJ7/ufz3UZmyViH/WDl+AYdgk3JqCIO5w5ryrC9IyBzYv2m0HqYbWfphY3uHw5\nun3ndLJcu8+BGP5F+ONQEGl+DRH58Il9Jp3HwbRa7dvkPgEhfFR+1hI+Btta2C7E\n0/2NKzCxZw7Lx3PBRcU92YKyaEihfy/aQKZCAuyfKiMvsmzs+4poIX7I9NQCJpyE\nIGfINoZ7VxqHwRn/d5mw2MZTJjbzSf+Um9YJyA0iEEyD6qjriWQRbuxpQXmlAJbh\n8okZ4gbVFv1F8MzK+4R8VvWJ0XxgtikSo72fHjwha7MAjqFnOq6eo6fEC/75g3NL\nGht5VdpGuHk0vbdENHMC8wS99e5qXGNDued3hlTavDMlEAHl34q2H9nakTGRF5Ki\nJUfNh3DVRGhg8cMIti21njiRh7gyFI2OccATY7bBSr79JhuNwelHuxLrCFpY7V25\nOFktl15jZJaMxuQBqYdBgSay2G0U6D1+7VsWufpzd/Abx1/c3oi9ZaJvW22kAggq\ndzdA27UUYjWvx42w9menJwh/0jeQcTecIUd0d0rFcw/c1pvgMMl/Q73yzKgKYw==\n=zbHE\n-----END PGP PUBLIC KEY BLOCK-----\n-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBFsy23UBEACUKSphFEIEvNpy68VeW4Dt6qv+mU6am9a2AAl10JANLj1oqWX+\noYk3en1S6cVe2qehSL5DGVa3HMUZkP3dtbD4SgzXzxPodebPcr4+0QNWigkUisri\nXGL5SCEcOP30zDhZvg+4mpO2jMi7Kc1DLPzBBkgppcX91wa0L1pQzBcvYMPyV/Dh\nKbQHR75WdkP6OA2JXdfC94nxYq+2e0iPqC1hCP3Elh+YnSkOkrawDPmoB1g4+ft/\nxsiVGVy/W0ekXmgvYEHt6si6Y8NwXgnTMqxeSXQ9YUgVIbTpsxHQKGy76T5lMlWX\n4LCOmEVomBJg1SqF6yi9Vu8TeNThaDqT4/DddYInd0OO69s0kGIXalVgGYiW2HOD\nx2q5R1VGCoJxXomz+EbOXY+HpKPOHAjU0DB9MxbU3S248LQ69nIB5uxysy0PSco1\nsdZ8sxRNQ9Dw6on0Nowx5m6Thefzs5iK3dnPGBqHTT43DHbnWc2scjQFG+eZhe98\nEll/kb6vpBoY4bG9/wCG9qu7jj9Z+BceCNKeHllbezVLCU/Hswivr7h2dnaEFvPD\nO4GqiWiwOF06XaBMVgxA8p2HRw0KtXqOpZk+o+sUvdPjsBw42BB96A1yFX4jgFNA\nPyZYnEUdP6OOv9HSjnl7k/iEkvHq/jGYMMojixlvXpGXhnt5jNyc4GSUJQARAQAB\ntDNSZWQgSGF0LCBJbmMuIChhdXhpbGlhcnkga2V5KSA8c2VjdXJpdHlAcmVkaGF0\nLmNvbT6JAjkEEwECACMFAlsy23UCGwMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIX\ngAAKCRD3b2bD1AgnknqOD/9fB2ASuG2aJIiap4kK58R+RmOVM4qgclAnaG57+vjI\nnKvyfV3NH/keplGNRxwqHekfPCqvkpABwhdGEXIE8ILqnPewIMr6PZNZWNJynZ9i\neSMzVuCG7jDoGyQ5/6B0f6xeBtTeBDiRl7+Alehet1twuGL1BJUYG0QuLgcEzkaE\n/gkuumeVcazLzz7L12D22nMk66GxmgXfqS5zcbqOAuZwaA6VgSEgFdV2X2JU79zS\nBQJXv7NKc+nDXFG7M7EHjY3Rma3HXkDbkT8bzh9tJV7Z7TlpT829pStWQyoxKCVq\nsEX8WsSapTKA3P9YkYCwLShgZu4HKRFvHMaIasSIZWzLu+RZH/4yyHOhj0QB7XMY\neHQ6fGSbtJ+K6SrpHOOsKQNAJ0hVbSrnA1cr5+2SDfel1RfYt0W9FA6DoH/S5gAR\ndzT1u44QVwwp3U+eFpHphFy//uzxNMtCjjdkpzhYYhOCLNkDrlRPb+bcoL/6ePSr\n016PA7eEnuC305YU1Ml2WcCn7wQV8x90o33klJmEkWtXh3X39vYtI4nCPIvZn1eP\nVy+F+wWt4vN2b8oOdlzc2paOembbCo2B+Wapv5Y9peBvlbsDSgqtJABfK8KQq/jK\nYl3h5elIa1I3uNfczeHOnf1enLOUOlq630yeM/yHizz99G1g+z/guMh5+x/OHraW\niLkCDQRbMtt1ARAA1lNsWklhS9LoBdolTVtg65FfdFJr47pzKRGYIoGLbcJ155ND\nG+P8UrM06E/ah06EEWuvu2YyyYAz1iYGsCwHAXtbEJh+1tF0iOVx2vnZPgtIGE9V\nP95V5ZvWvB3bdke1z8HadDA+/Ve7fbwXXLa/z9QhSQgsJ8NS8KYnDDjI4EvQtv0i\nPVLY8+u8z6VyiV9RJyn8UEZEJdbFDF9AZAT8103w8SEo/cvIoUbVKZLGcXdAIjCa\ny04u6jsrMp9UGHZX7+srT+9YHDzQixei4IdmxUcqtiNR2/bFHpHCu1pzYjXj968D\n8Ng2txBXDgs16BF/9l++GWKz2dOSH0jdS6sFJ/Dmg7oYnJ2xKSJEmcnV8Z0M1n4w\nXR1t/KeKZe3aR+RXCAEVC5dQ3GbRW2+WboJ6ldgFcVcOv6iOSWP9TrLzFPOpCsIr\nnHE+cMBmPHq3dUm7KeYXQ6wWWmtXlw6widf7cBcGFeELpuU9klzqdKze8qo2oMkf\nrfxIq8zdciPxZXb/75dGWs6dLHQmDpo4MdQVskw5vvwHicMpUpGpxkX7X1XAfdQf\nyIHLGT4ZXuMLIMUPdzJE0Vwt/RtJrZ+feLSv/+0CkkpGHORYroGwIBrJ2RikgcV2\nbc98V/27Kz2ngUCEwnmlhIcrY4IGAAZzUAl0GLHSevPbAREu4fDW4Y+ztOsAEQEA\nAYkCHwQYAQIACQUCWzLbdQIbDAAKCRD3b2bD1AgnkusfD/9U4sPtZfMw6cII167A\nXRZOO195G7oiAnBUw5AW6EK0SAHVZcuW0LMMXnGe9f4UsEUgCNwo5mvLWPxzKqFq\n6/G3kEZVFwZ0qrlLoJPeHNbOcfkeZ9NgD/OhzQmdylM0IwGM9DMrm2YS4EVsmm2b\n53qKIfIyysp1yAGcTnBwBbZ85osNBl2KRDIPhMs0bnmGB7IAvwlSb+xm6vWKECkO\nlwQDO5Kg8YZ8+Z3pn/oS688t/fPXvWLZYUqwR63oWfIaPJI7Ahv2jJmgw1ofL81r\n2CE3T/OydtUeGLzqWJAB8sbUgT3ug0cjtxsHuroQBSYBND3XDb/EQh5GeVVnGKKH\ngESLFAoweoNjDSXrlIu1gFjCDHF4CqBRmNYKrNQjLmhCrSfwkytXESJwlLzFKY8P\nK1yZyTpDC9YK0G7qgrk7EHmH9JAZTQ5V65pp0vR9KvqTU5ewkQDIljD2f3FIqo2B\nSKNCQE+N6NjWaTeNlU75m+yZocKObSPg0zS8FAuSJetNtzXA7ouqk34OoIMQj4gq\nUnh/i1FcZAd4U6Dtr9aRZ6PeLlm6MJ/h582L6fJLNEu136UWDtJj5eBYEzX13l+d\nSC4PEHx7ZZRwQKptl9NkinLZGJztg175paUu8C34sAv+SQnM20c0pdOXAq9GKKhi\nvt61kpkXoRGxjTlc6h+69aidSg==\n=ls8J\n-----END PGP PUBLIC KEY BLOCK-----\n" - }, - { - "name": "appstream-p2", - "baseurl": "https://rpmrepo.osbuild.org/v1/psi/el8/el8-aarch64-appstream-8.4.0.n-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBErgSTsBEACh2A4b0O9t+vzC9VrVtL1AKvUWi9OPCjkvR7Xd8DtJxeeMZ5eF\n0HtzIG58qDRybwUe89FZprB1ffuUKzdE+HcL3FbNWSSOXVjZIersdXyH3NvnLLLF\n0DNRB2ix3bXG9Rh/RXpFsNxDp2CEMdUvbYCzE79K1EnUTVh1L0Of023FtPSZXX0c\nu7Pb5DI5lX5YeoXO6RoodrIGYJsVBQWnrWw4xNTconUfNPk0EGZtEnzvH2zyPoJh\nXGF+Ncu9XwbalnYde10OCvSWAZ5zTCpoLMTvQjWpbCdWXJzCm6G+/hx9upke546H\n5IjtYm4dTIVTnc3wvDiODgBKRzOl9rEOCIgOuGtDxRxcQkjrC+xvg5Vkqn7vBUyW\n9pHedOU+PoF3DGOM+dqv+eNKBvh9YF9ugFAQBkcG7viZgvGEMGGUpzNgN7XnS1gj\n/DPo9mZESOYnKceve2tIC87p2hqjrxOHuI7fkZYeNIcAoa83rBltFXaBDYhWAKS1\nPcXS1/7JzP0ky7d0L6Xbu/If5kqWQpKwUInXtySRkuraVfuK3Bpa+X1XecWi24JY\nHVtlNX025xx1ewVzGNCTlWn1skQN2OOoQTV4C8/qFpTW6DTWYurd4+fE0OJFJZQF\nbuhfXYwmRlVOgN5i77NTIJZJQfYFj38c/Iv5vZBPokO6mffrOTv3MHWVgQARAQAB\ntDNSZWQgSGF0LCBJbmMuIChyZWxlYXNlIGtleSAyKSA8c2VjdXJpdHlAcmVkaGF0\nLmNvbT6JAjYEEwECACAFAkrgSTsCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAK\nCRAZni+R/UMdUWzpD/9s5SFR/ZF3yjY5VLUFLMXIKUztNN3oc45fyLdTI3+UClKC\n2tEruzYjqNHhqAEXa2sN1fMrsuKec61Ll2NfvJjkLKDvgVIh7kM7aslNYVOP6BTf\nC/JJ7/ufz3UZmyViH/WDl+AYdgk3JqCIO5w5ryrC9IyBzYv2m0HqYbWfphY3uHw5\nun3ndLJcu8+BGP5F+ONQEGl+DRH58Il9Jp3HwbRa7dvkPgEhfFR+1hI+Btta2C7E\n0/2NKzCxZw7Lx3PBRcU92YKyaEihfy/aQKZCAuyfKiMvsmzs+4poIX7I9NQCJpyE\nIGfINoZ7VxqHwRn/d5mw2MZTJjbzSf+Um9YJyA0iEEyD6qjriWQRbuxpQXmlAJbh\n8okZ4gbVFv1F8MzK+4R8VvWJ0XxgtikSo72fHjwha7MAjqFnOq6eo6fEC/75g3NL\nGht5VdpGuHk0vbdENHMC8wS99e5qXGNDued3hlTavDMlEAHl34q2H9nakTGRF5Ki\nJUfNh3DVRGhg8cMIti21njiRh7gyFI2OccATY7bBSr79JhuNwelHuxLrCFpY7V25\nOFktl15jZJaMxuQBqYdBgSay2G0U6D1+7VsWufpzd/Abx1/c3oi9ZaJvW22kAggq\ndzdA27UUYjWvx42w9menJwh/0jeQcTecIUd0d0rFcw/c1pvgMMl/Q73yzKgKYw==\n=zbHE\n-----END PGP PUBLIC KEY BLOCK-----\n-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBFsy23UBEACUKSphFEIEvNpy68VeW4Dt6qv+mU6am9a2AAl10JANLj1oqWX+\noYk3en1S6cVe2qehSL5DGVa3HMUZkP3dtbD4SgzXzxPodebPcr4+0QNWigkUisri\nXGL5SCEcOP30zDhZvg+4mpO2jMi7Kc1DLPzBBkgppcX91wa0L1pQzBcvYMPyV/Dh\nKbQHR75WdkP6OA2JXdfC94nxYq+2e0iPqC1hCP3Elh+YnSkOkrawDPmoB1g4+ft/\nxsiVGVy/W0ekXmgvYEHt6si6Y8NwXgnTMqxeSXQ9YUgVIbTpsxHQKGy76T5lMlWX\n4LCOmEVomBJg1SqF6yi9Vu8TeNThaDqT4/DddYInd0OO69s0kGIXalVgGYiW2HOD\nx2q5R1VGCoJxXomz+EbOXY+HpKPOHAjU0DB9MxbU3S248LQ69nIB5uxysy0PSco1\nsdZ8sxRNQ9Dw6on0Nowx5m6Thefzs5iK3dnPGBqHTT43DHbnWc2scjQFG+eZhe98\nEll/kb6vpBoY4bG9/wCG9qu7jj9Z+BceCNKeHllbezVLCU/Hswivr7h2dnaEFvPD\nO4GqiWiwOF06XaBMVgxA8p2HRw0KtXqOpZk+o+sUvdPjsBw42BB96A1yFX4jgFNA\nPyZYnEUdP6OOv9HSjnl7k/iEkvHq/jGYMMojixlvXpGXhnt5jNyc4GSUJQARAQAB\ntDNSZWQgSGF0LCBJbmMuIChhdXhpbGlhcnkga2V5KSA8c2VjdXJpdHlAcmVkaGF0\nLmNvbT6JAjkEEwECACMFAlsy23UCGwMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIX\ngAAKCRD3b2bD1AgnknqOD/9fB2ASuG2aJIiap4kK58R+RmOVM4qgclAnaG57+vjI\nnKvyfV3NH/keplGNRxwqHekfPCqvkpABwhdGEXIE8ILqnPewIMr6PZNZWNJynZ9i\neSMzVuCG7jDoGyQ5/6B0f6xeBtTeBDiRl7+Alehet1twuGL1BJUYG0QuLgcEzkaE\n/gkuumeVcazLzz7L12D22nMk66GxmgXfqS5zcbqOAuZwaA6VgSEgFdV2X2JU79zS\nBQJXv7NKc+nDXFG7M7EHjY3Rma3HXkDbkT8bzh9tJV7Z7TlpT829pStWQyoxKCVq\nsEX8WsSapTKA3P9YkYCwLShgZu4HKRFvHMaIasSIZWzLu+RZH/4yyHOhj0QB7XMY\neHQ6fGSbtJ+K6SrpHOOsKQNAJ0hVbSrnA1cr5+2SDfel1RfYt0W9FA6DoH/S5gAR\ndzT1u44QVwwp3U+eFpHphFy//uzxNMtCjjdkpzhYYhOCLNkDrlRPb+bcoL/6ePSr\n016PA7eEnuC305YU1Ml2WcCn7wQV8x90o33klJmEkWtXh3X39vYtI4nCPIvZn1eP\nVy+F+wWt4vN2b8oOdlzc2paOembbCo2B+Wapv5Y9peBvlbsDSgqtJABfK8KQq/jK\nYl3h5elIa1I3uNfczeHOnf1enLOUOlq630yeM/yHizz99G1g+z/guMh5+x/OHraW\niLkCDQRbMtt1ARAA1lNsWklhS9LoBdolTVtg65FfdFJr47pzKRGYIoGLbcJ155ND\nG+P8UrM06E/ah06EEWuvu2YyyYAz1iYGsCwHAXtbEJh+1tF0iOVx2vnZPgtIGE9V\nP95V5ZvWvB3bdke1z8HadDA+/Ve7fbwXXLa/z9QhSQgsJ8NS8KYnDDjI4EvQtv0i\nPVLY8+u8z6VyiV9RJyn8UEZEJdbFDF9AZAT8103w8SEo/cvIoUbVKZLGcXdAIjCa\ny04u6jsrMp9UGHZX7+srT+9YHDzQixei4IdmxUcqtiNR2/bFHpHCu1pzYjXj968D\n8Ng2txBXDgs16BF/9l++GWKz2dOSH0jdS6sFJ/Dmg7oYnJ2xKSJEmcnV8Z0M1n4w\nXR1t/KeKZe3aR+RXCAEVC5dQ3GbRW2+WboJ6ldgFcVcOv6iOSWP9TrLzFPOpCsIr\nnHE+cMBmPHq3dUm7KeYXQ6wWWmtXlw6widf7cBcGFeELpuU9klzqdKze8qo2oMkf\nrfxIq8zdciPxZXb/75dGWs6dLHQmDpo4MdQVskw5vvwHicMpUpGpxkX7X1XAfdQf\nyIHLGT4ZXuMLIMUPdzJE0Vwt/RtJrZ+feLSv/+0CkkpGHORYroGwIBrJ2RikgcV2\nbc98V/27Kz2ngUCEwnmlhIcrY4IGAAZzUAl0GLHSevPbAREu4fDW4Y+ztOsAEQEA\nAYkCHwQYAQIACQUCWzLbdQIbDAAKCRD3b2bD1AgnkusfD/9U4sPtZfMw6cII167A\nXRZOO195G7oiAnBUw5AW6EK0SAHVZcuW0LMMXnGe9f4UsEUgCNwo5mvLWPxzKqFq\n6/G3kEZVFwZ0qrlLoJPeHNbOcfkeZ9NgD/OhzQmdylM0IwGM9DMrm2YS4EVsmm2b\n53qKIfIyysp1yAGcTnBwBbZ85osNBl2KRDIPhMs0bnmGB7IAvwlSb+xm6vWKECkO\nlwQDO5Kg8YZ8+Z3pn/oS688t/fPXvWLZYUqwR63oWfIaPJI7Ahv2jJmgw1ofL81r\n2CE3T/OydtUeGLzqWJAB8sbUgT3ug0cjtxsHuroQBSYBND3XDb/EQh5GeVVnGKKH\ngESLFAoweoNjDSXrlIu1gFjCDHF4CqBRmNYKrNQjLmhCrSfwkytXESJwlLzFKY8P\nK1yZyTpDC9YK0G7qgrk7EHmH9JAZTQ5V65pp0vR9KvqTU5ewkQDIljD2f3FIqo2B\nSKNCQE+N6NjWaTeNlU75m+yZocKObSPg0zS8FAuSJetNtzXA7ouqk34OoIMQj4gq\nUnh/i1FcZAd4U6Dtr9aRZ6PeLlm6MJ/h582L6fJLNEu136UWDtJj5eBYEzX13l+d\nSC4PEHx7ZZRwQKptl9NkinLZGJztg175paUu8C34sAv+SQnM20c0pdOXAq9GKKhi\nvt61kpkXoRGxjTlc6h+69aidSg==\n=ls8J\n-----END PGP PUBLIC KEY BLOCK-----\n" - }, - { - "name": "google-compute-engine", - "baseurl": "https://packages.cloud.google.com/yum/repos/google-compute-engine-el8-x86_64-stable", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQENBGA9EFkBCAC1ilzST0wns+uwZyEA5IVtYeyAuXTaQUEAd70SqIlQpDd4EyVi\nx3SCanQIu8dG9Zq3+x28WBb2OuXP9oc06ybOWdu2m7N5PY0BUT4COA36JV/YrxmN\ns+5/M+YnDHppv63jgRIOkzXzXNo6SwTsl2xG9fKB3TS0IMvBkWdw5PGrBM5GghRc\necgoSAAwRbWJXORHGKVwlV6tOxQZ/xqA08hPJneMfsMFPOXsitgGRHoXjlUWLVeJ\n70mmIYsC/pBglIwCzmdD8Ee39MrlSXbuXVQiz38iHfnvXYpLEmgNXKzI0DH9tKg8\n323kALzqaJlLFOLJm/uVJXRUEfKS3LhVZQMzABEBAAG0UVJhcHR1cmUgQXV0b21h\ndGljIFNpZ25pbmcgS2V5IChjbG91ZC1yYXB0dXJlLXNpZ25pbmcta2V5LTIwMjEt\nMDMtMDEtMDhfMDFfMDkucHViKYkBKAQTAQgAHAUCYD0QWQkQ/uqRaTB+oHECGwMF\nCQPDCrACGQEAAHtlCACxSWMp3yRcLmsHhxGDt59nhSNXhouWiNePSMe5vETQA/lh\nip9Zx/NPRCa4q5jpIDBlEYOg67YanztcjSWGSI35Xblq43H4uLSxh4PtKzZMo+Uj\n8n2VNHOZXBdGcsODcU3ynF64r7eTQevUe2aU0KN2o656O3HrE4itOVKYwnnkmNsk\nG45b9b7DJnsQ6WPszUc8lNhsa2gBI6vfLl68vjj7PlWw030BM/RoMEPpoOApohHo\nsfnNhxJmE1AxwBkMEzyo2kZhPZGh85LDnDbAvjSFKqYSPReKmRFjLlo3DPVHZ/de\nQn6noHbgUChLo21FefhlZO6tysrb283MWMIyY/YSuQENBGA9EFkBCADcdO/Aw1qu\ndZORZCNLz3vTiQSFcUFYyScfJJnwUsg8fy0kgg9olFY0GK5icT6n/shc1RlIpuqr\nOQYBZgtK3dSZfOAXE2N20HUvC+nrKKuXXX+jcM/X1kHxwX5tG6fB1fyNH0p/Qqsz\nEfYRHJu0Y4PonTYIslITnEzlN4hUN6/mx1+mWPl4P4R7/h6+p7Q2jtaClEtddF0e\neOf16Ma5S8fff80uZCLJoVu3lOXCT22oCf7qmH2XddmqGisUScqwmbmuv30tdQed\nn+8njKo2pfpVF1Oa67CWRXdKTknuZybxI9Ipcivy8CISL2Do0uzij7SR7keVf7G1\nQ3K3iJ0wn6mDABEBAAGJAR8EGAEIABMFAmA9EFkJEP7qkWkwfqBxAhsMAAA/3Af9\nFJ2hEp2144fzgtNWHOVFv27hsrO7wYFZwoic9lHSl4iEw8mJc/3kEXdg9Vf9m1zb\nG/kZ6slmzpfv7zDAdN3h3HT0B1yrb3xXzRX0zhOYAbQSUnc6DemhDZoDWt/wVceK\nfzvebB9VTDzRBUVzxCduvY6ij0p2APZpnTrznvCPoCHkfzBMC3Zyk1FueiPTPoP1\n9M0BProMy8qDVSkFr0uX3PM54hQN6mGRQg5HVVBxUNaMnn2yOQcxbQ/T/dKlojdp\nRmvpGyYjfrvyExE8owYn8L7ly2N76GcY6kiN1CmTnCgdrbU0SPacm7XbxTYlQHwJ\nCEa9Hf4/nuiBaxwXKuc/y5kBDQRfyX5eAQgA0z1F3ZDbtOe1/j90k1cQsyaVNjJ/\nrVGpinUnVWpmxnmBSDXKfxBsDRoXW9GtQWx7NUlmGW88IeHevqd5OAAc1TDvkaTL\nv2gcfROWjp+XPBsx42f1RGoXqiy4UlHEgswoUmXDeY89IUxoZgBmr4jLekTM0n2y\nIWT49ZA8wYhndEMHf6zj5ya+LWj67kd3nAY4R7YtfwTBnf5Y9Be80Jwo6ez66oKR\nDwU/I6PcF9sLzsl7MEiPxrH2xYmjiXw52Hp4GhIPLBfrt1jrNGdtHEq+pEu+ih6U\n32tyY2LHx7fDQ8PMOHtx/D8EMzYkT/bV3jAEikM93pjI/3pOh8Y4oWPahQARAQAB\ntLpnTGludXggUmFwdHVyZSBBdXRvbWF0aWMgU2lnbmluZyBLZXkgKC8vZGVwb3Qv\nZ29vZ2xlMy9wcm9kdWN0aW9uL2JvcmcvY2xvdWQtcmFwdHVyZS9rZXlzL2Nsb3Vk\nLXJhcHR1cmUtcHVia2V5cy9jbG91ZC1yYXB0dXJlLXNpZ25pbmcta2V5LTIwMjAt\nMTItMDMtMTZfMDhfMDUucHViKSA8Z2xpbnV4LXRlYW1AZ29vZ2xlLmNvbT6JASgE\nEwEIABwFAl/Jfl4JEItXxcKDb0vrAhsDBQkDwwqwAhkBAABBeggAmnpK6OmlCSXd\n5lba7SzjnsFfHrdY3qeXsJqTq3sP6Wo0VQXiG1dWsFZ9P/BHHpxXo5j+lhXHQlqL\ng1SEv0JkRUFfTemFzfD4sGpa0Vd20yhQR5MGtXBB+AGnwhqNHA7yW/DdyZzP0Zm9\nSkhiq+2V6ZpC7WFaq+h4M5frJ65R9F8LJea90sr6gYL0WE0CmaSqpgRHdbnYnlaC\n0hffPJCnjQ4xWvkNUo2Txlvl7pIBPJAVG0g8fGPKugrM4d1VWPuSVHqopkYCdgA2\nNv95RLQGTrZsHAZYWNHD1laoGteBO5ExkligulvejX8vSuy+GKafJ0zBK7rNfNWq\nsMDXzKp6Z7kBDQRfyX5eAQgAw0ofinQXjYyHJVVZ0SrdEE+efd8heFlWbf04Dbmh\nGebypJ6KFVSKvnCSH2P95VKqvE3uHRI6HbRcinuV7noKOqo87PE2BXQgB16V0aFK\nJU9eJvqpCfK4Uq6TdE8SI1iWyXZtzZa4E2puUSicN0ocqTVMcqJZx3pV8asigwpM\nQUg5kesXHX7d8HUJeSJCAMMXup8sJklLaZ3Ri0SXSa2iYmlhdiAYxTYN70xGI+Hq\nHoWXeF67xMi1azGymeZun9aOkFEbs0q1B/SU/4r2agpoT6aLApV119G24vStGf/r\nlcpOr++prNzudKyKtC9GHoTPBvvqphjuNtftKgi5HQ+f4wARAQABiQEfBBgBCAAT\nBQJfyX5eCRCLV8XCg29L6wIbDAAAGxoIAMO5YUlhJWaRldUiNm9itujwfd31SNbU\nGFd+1iBJQibGoxfv2Q3ySdnep3LkEpXh+VkXHHOIWXysMrAP3qaqwp8HO8irE6Ge\nLMPMbCRdVLUORDbZHQK1YgSR0uGNlWeQxFJq+RIIRrWRYfWumi6HjFTP562Qi7LQ\n1aDyhKS6JB7v4HmwsH0/5/VNXaJRSKL4OnigApecTsfq83AFae0eD+du4337nc93\nSjHS4T67LRtMOWG8nzz8FjDj6fpFBeOXmHUe5CipNPVayTZBBidCkEOopqkdU59J\nMruHL5H6pwlBdK65+wnQai0gr9UEYYK+kwoUH+8p1rD8+YBnVY4d7SM=\n=UVi6\n-----END PGP PUBLIC KEY BLOCK-----\n-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: GnuPG v1\n\nmQENBFWKtqgBCADmKQWYQF9YoPxLEQZ5XA6DFVg9ZHG4HIuehsSJETMPQ+W9K5c5\nUs5assCZBjG/k5i62SmWb09eHtWsbbEgexURBWJ7IxA8kM3kpTo7bx+LqySDsSC3\n/8JRkiyibVV0dDNv/EzRQsGDxmk5Xl8SbQJ/C2ECSUT2ok225f079m2VJsUGHG+5\nRpyHHgoMaRNedYP8ksYBPSD6sA3Xqpsh/0cF4sm8QtmsxkBmCCIjBa0B0LybDtdX\nXIq5kPJsIrC2zvERIPm1ez/9FyGmZKEFnBGeFC45z5U//pHdB1z03dYKGrKdDpID\n17kNbC5wl24k/IeYyTY9IutMXvuNbVSXaVtRABEBAAG0Okdvb2dsZSBDbG91ZCBQ\nYWNrYWdlcyBSUE0gU2lnbmluZyBLZXkgPGdjLXRlYW1AZ29vZ2xlLmNvbT6JATgE\nEwECACIFAlWKtqgCGy8GCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEPCcOUw+\nG6jV+QwH/0wRH+XovIwLGfkg6kYLEvNPvOIYNQWnrT6zZ+XcV47WkJ+i5SR+QpUI\nudMSWVf4nkv+XVHruxydafRIeocaXY0E8EuIHGBSB2KR3HxG6JbgUiWlCVRNt4Qd\n6udC6Ep7maKEIpO40M8UHRuKrp4iLGIhPm3ELGO6uc8rks8qOBMH4ozU+3PB9a0b\nGnPBEsZdOBI1phyftLyyuEvG8PeUYD+uzSx8jp9xbMg66gQRMP9XGzcCkD+b8w1o\n7v3J3juKKpgvx5Lqwvwv2ywqn/Wr5d5OBCHEw8KtU/tfxycz/oo6XUIshgEbS/+P\n6yKDuYhRp6qxrYXjmAszIT25cftb4d4=\n=/PbX\n-----END PGP PUBLIC KEY BLOCK-----", - "image_type_tags": ["test_type2"] - }, - { - "name": "google-cloud-sdk", - "baseurl": "https://packages.cloud.google.com/yum/repos/cloud-sdk-el8-x86_64", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQENBGA9EFkBCAC1ilzST0wns+uwZyEA5IVtYeyAuXTaQUEAd70SqIlQpDd4EyVi\nx3SCanQIu8dG9Zq3+x28WBb2OuXP9oc06ybOWdu2m7N5PY0BUT4COA36JV/YrxmN\ns+5/M+YnDHppv63jgRIOkzXzXNo6SwTsl2xG9fKB3TS0IMvBkWdw5PGrBM5GghRc\necgoSAAwRbWJXORHGKVwlV6tOxQZ/xqA08hPJneMfsMFPOXsitgGRHoXjlUWLVeJ\n70mmIYsC/pBglIwCzmdD8Ee39MrlSXbuXVQiz38iHfnvXYpLEmgNXKzI0DH9tKg8\n323kALzqaJlLFOLJm/uVJXRUEfKS3LhVZQMzABEBAAG0UVJhcHR1cmUgQXV0b21h\ndGljIFNpZ25pbmcgS2V5IChjbG91ZC1yYXB0dXJlLXNpZ25pbmcta2V5LTIwMjEt\nMDMtMDEtMDhfMDFfMDkucHViKYkBKAQTAQgAHAUCYD0QWQkQ/uqRaTB+oHECGwMF\nCQPDCrACGQEAAHtlCACxSWMp3yRcLmsHhxGDt59nhSNXhouWiNePSMe5vETQA/lh\nip9Zx/NPRCa4q5jpIDBlEYOg67YanztcjSWGSI35Xblq43H4uLSxh4PtKzZMo+Uj\n8n2VNHOZXBdGcsODcU3ynF64r7eTQevUe2aU0KN2o656O3HrE4itOVKYwnnkmNsk\nG45b9b7DJnsQ6WPszUc8lNhsa2gBI6vfLl68vjj7PlWw030BM/RoMEPpoOApohHo\nsfnNhxJmE1AxwBkMEzyo2kZhPZGh85LDnDbAvjSFKqYSPReKmRFjLlo3DPVHZ/de\nQn6noHbgUChLo21FefhlZO6tysrb283MWMIyY/YSuQENBGA9EFkBCADcdO/Aw1qu\ndZORZCNLz3vTiQSFcUFYyScfJJnwUsg8fy0kgg9olFY0GK5icT6n/shc1RlIpuqr\nOQYBZgtK3dSZfOAXE2N20HUvC+nrKKuXXX+jcM/X1kHxwX5tG6fB1fyNH0p/Qqsz\nEfYRHJu0Y4PonTYIslITnEzlN4hUN6/mx1+mWPl4P4R7/h6+p7Q2jtaClEtddF0e\neOf16Ma5S8fff80uZCLJoVu3lOXCT22oCf7qmH2XddmqGisUScqwmbmuv30tdQed\nn+8njKo2pfpVF1Oa67CWRXdKTknuZybxI9Ipcivy8CISL2Do0uzij7SR7keVf7G1\nQ3K3iJ0wn6mDABEBAAGJAR8EGAEIABMFAmA9EFkJEP7qkWkwfqBxAhsMAAA/3Af9\nFJ2hEp2144fzgtNWHOVFv27hsrO7wYFZwoic9lHSl4iEw8mJc/3kEXdg9Vf9m1zb\nG/kZ6slmzpfv7zDAdN3h3HT0B1yrb3xXzRX0zhOYAbQSUnc6DemhDZoDWt/wVceK\nfzvebB9VTDzRBUVzxCduvY6ij0p2APZpnTrznvCPoCHkfzBMC3Zyk1FueiPTPoP1\n9M0BProMy8qDVSkFr0uX3PM54hQN6mGRQg5HVVBxUNaMnn2yOQcxbQ/T/dKlojdp\nRmvpGyYjfrvyExE8owYn8L7ly2N76GcY6kiN1CmTnCgdrbU0SPacm7XbxTYlQHwJ\nCEa9Hf4/nuiBaxwXKuc/y5kBDQRfyX5eAQgA0z1F3ZDbtOe1/j90k1cQsyaVNjJ/\nrVGpinUnVWpmxnmBSDXKfxBsDRoXW9GtQWx7NUlmGW88IeHevqd5OAAc1TDvkaTL\nv2gcfROWjp+XPBsx42f1RGoXqiy4UlHEgswoUmXDeY89IUxoZgBmr4jLekTM0n2y\nIWT49ZA8wYhndEMHf6zj5ya+LWj67kd3nAY4R7YtfwTBnf5Y9Be80Jwo6ez66oKR\nDwU/I6PcF9sLzsl7MEiPxrH2xYmjiXw52Hp4GhIPLBfrt1jrNGdtHEq+pEu+ih6U\n32tyY2LHx7fDQ8PMOHtx/D8EMzYkT/bV3jAEikM93pjI/3pOh8Y4oWPahQARAQAB\ntLpnTGludXggUmFwdHVyZSBBdXRvbWF0aWMgU2lnbmluZyBLZXkgKC8vZGVwb3Qv\nZ29vZ2xlMy9wcm9kdWN0aW9uL2JvcmcvY2xvdWQtcmFwdHVyZS9rZXlzL2Nsb3Vk\nLXJhcHR1cmUtcHVia2V5cy9jbG91ZC1yYXB0dXJlLXNpZ25pbmcta2V5LTIwMjAt\nMTItMDMtMTZfMDhfMDUucHViKSA8Z2xpbnV4LXRlYW1AZ29vZ2xlLmNvbT6JASgE\nEwEIABwFAl/Jfl4JEItXxcKDb0vrAhsDBQkDwwqwAhkBAABBeggAmnpK6OmlCSXd\n5lba7SzjnsFfHrdY3qeXsJqTq3sP6Wo0VQXiG1dWsFZ9P/BHHpxXo5j+lhXHQlqL\ng1SEv0JkRUFfTemFzfD4sGpa0Vd20yhQR5MGtXBB+AGnwhqNHA7yW/DdyZzP0Zm9\nSkhiq+2V6ZpC7WFaq+h4M5frJ65R9F8LJea90sr6gYL0WE0CmaSqpgRHdbnYnlaC\n0hffPJCnjQ4xWvkNUo2Txlvl7pIBPJAVG0g8fGPKugrM4d1VWPuSVHqopkYCdgA2\nNv95RLQGTrZsHAZYWNHD1laoGteBO5ExkligulvejX8vSuy+GKafJ0zBK7rNfNWq\nsMDXzKp6Z7kBDQRfyX5eAQgAw0ofinQXjYyHJVVZ0SrdEE+efd8heFlWbf04Dbmh\nGebypJ6KFVSKvnCSH2P95VKqvE3uHRI6HbRcinuV7noKOqo87PE2BXQgB16V0aFK\nJU9eJvqpCfK4Uq6TdE8SI1iWyXZtzZa4E2puUSicN0ocqTVMcqJZx3pV8asigwpM\nQUg5kesXHX7d8HUJeSJCAMMXup8sJklLaZ3Ri0SXSa2iYmlhdiAYxTYN70xGI+Hq\nHoWXeF67xMi1azGymeZun9aOkFEbs0q1B/SU/4r2agpoT6aLApV119G24vStGf/r\nlcpOr++prNzudKyKtC9GHoTPBvvqphjuNtftKgi5HQ+f4wARAQABiQEfBBgBCAAT\nBQJfyX5eCRCLV8XCg29L6wIbDAAAGxoIAMO5YUlhJWaRldUiNm9itujwfd31SNbU\nGFd+1iBJQibGoxfv2Q3ySdnep3LkEpXh+VkXHHOIWXysMrAP3qaqwp8HO8irE6Ge\nLMPMbCRdVLUORDbZHQK1YgSR0uGNlWeQxFJq+RIIRrWRYfWumi6HjFTP562Qi7LQ\n1aDyhKS6JB7v4HmwsH0/5/VNXaJRSKL4OnigApecTsfq83AFae0eD+du4337nc93\nSjHS4T67LRtMOWG8nzz8FjDj6fpFBeOXmHUe5CipNPVayTZBBidCkEOopqkdU59J\nMruHL5H6pwlBdK65+wnQai0gr9UEYYK+kwoUH+8p1rD8+YBnVY4d7SM=\n=UVi6\n-----END PGP PUBLIC KEY BLOCK-----\n-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: GnuPG v1\n\nmQENBFWKtqgBCADmKQWYQF9YoPxLEQZ5XA6DFVg9ZHG4HIuehsSJETMPQ+W9K5c5\nUs5assCZBjG/k5i62SmWb09eHtWsbbEgexURBWJ7IxA8kM3kpTo7bx+LqySDsSC3\n/8JRkiyibVV0dDNv/EzRQsGDxmk5Xl8SbQJ/C2ECSUT2ok225f079m2VJsUGHG+5\nRpyHHgoMaRNedYP8ksYBPSD6sA3Xqpsh/0cF4sm8QtmsxkBmCCIjBa0B0LybDtdX\nXIq5kPJsIrC2zvERIPm1ez/9FyGmZKEFnBGeFC45z5U//pHdB1z03dYKGrKdDpID\n17kNbC5wl24k/IeYyTY9IutMXvuNbVSXaVtRABEBAAG0Okdvb2dsZSBDbG91ZCBQ\nYWNrYWdlcyBSUE0gU2lnbmluZyBLZXkgPGdjLXRlYW1AZ29vZ2xlLmNvbT6JATgE\nEwECACIFAlWKtqgCGy8GCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEPCcOUw+\nG6jV+QwH/0wRH+XovIwLGfkg6kYLEvNPvOIYNQWnrT6zZ+XcV47WkJ+i5SR+QpUI\nudMSWVf4nkv+XVHruxydafRIeocaXY0E8EuIHGBSB2KR3HxG6JbgUiWlCVRNt4Qd\n6udC6Ep7maKEIpO40M8UHRuKrp4iLGIhPm3ELGO6uc8rks8qOBMH4ozU+3PB9a0b\nGnPBEsZdOBI1phyftLyyuEvG8PeUYD+uzSx8jp9xbMg66gQRMP9XGzcCkD+b8w1o\n7v3J3juKKpgvx5Lqwvwv2ywqn/Wr5d5OBCHEw8KtU/tfxycz/oo6XUIshgEbS/+P\n6yKDuYhRp6qxrYXjmAszIT25cftb4d4=\n=/PbX\n-----END PGP PUBLIC KEY BLOCK-----", - "image_type_tags": ["test_type2"] - } - ] -} diff --git a/internal/rpmmd/test/confpaths/priority2/repositories/test-distro.json b/internal/rpmmd/test/confpaths/priority2/repositories/test-distro.json deleted file mode 100644 index d67105aac..000000000 --- a/internal/rpmmd/test/confpaths/priority2/repositories/test-distro.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "test_arch": [ - { - "name": "fedora-p2", - "baseurl": "https://rpmrepo.osbuild.org/v1/anon/f33/f33-x86_64-fedora-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "updates-p2", - "baseurl": "https://rpmrepo.osbuild.org/v1/anon/f33/f33-x86_64-fedora-modular-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "fedora-modular-p2", - "baseurl": "https://rpmrepo.osbuild.org/v1/anon/f33/f33-x86_64-updates-released-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "updates-modular-p2", - "baseurl": "https://rpmrepo.osbuild.org/v1/anon/f33/f33-x86_64-updates-released-modular-20201108/", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - } - ], - "test_arch2": [ - { - "name": "fedora-p2", - "metalink": "https://mirrors.fedoraproject.org/metalink?repo=fedora-33&arch=aarch64", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "updates-p2", - "metalink": "https://mirrors.fedoraproject.org/metalink?repo=updates-released-f33&arch=aarch64", - "metadata_expire": "6h", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "fedora-modular-p2", - "metalink": "https://mirrors.fedoraproject.org/metalink?repo=fedora-modular-33&arch=aarch64", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - }, - { - "name": "updates-modular-p2", - "metalink": "https://mirrors.fedoraproject.org/metalink?repo=updates-released-modular-f33&arch=aarch64", - "metadata_expire": "6h", - "gpgkey": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQINBF4wBvsBEADQmcGbVUbDRUoXADReRmOOEMeydHghtKC9uRs9YNpGYZIB+bie\nbGYZmflQayfh/wEpO2W/IZfGpHPL42V7SbyvqMjwNls/fnXsCtf4LRofNK8Qd9fN\nkYargc9R7BEz/mwXKMiRQVx+DzkmqGWy2gq4iD0/mCyf5FdJCE40fOWoIGJXaOI1\nTz1vWqKwLS5T0dfmi9U4Tp/XsKOZGvN8oi5h0KmqFk7LEZr1MXarhi2Va86sgxsF\nQcZEKfu5tgD0r00vXzikoSjn3qA5JW5FW07F1pGP4bF5f9J3CZbQyOjTSWMmmfTm\n2d2BURWzaDiJN9twY2yjzkoOMuPdXXvovg7KxLcQerKT+FbKbq8DySJX2rnOA77k\nUG4c9BGf/L1uBkAT8dpHLk6Uf5BfmypxUkydSWT1xfTDnw1MqxO0MsLlAHOR3J7c\noW9kLcOLuCQn1hBEwfZv7VSWBkGXSmKfp0LLIxAFgRtv+Dh+rcMMRdJgKr1V3FU+\nrZ1+ZAfYiBpQJFPjv70vx+rGEgS801D3PJxBZUEy4Ic4ZYaKNhK9x9PRQuWcIBuW\n6eTe/6lKWZeyxCumLLdiS75mF2oTcBaWeoc3QxrPRV15eDKeYJMbhnUai/7lSrhs\nEWCkKR1RivgF4slYmtNE5ZPGZ/d61zjwn2xi4xNJVs8q9WRPMpHp0vCyMwARAQAB\ntDFGZWRvcmEgKDMzKSA8ZmVkb3JhLTMzLXByaW1hcnlAZmVkb3JhcHJvamVjdC5v\ncmc+iQI4BBMBAgAiBQJeMAb7AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAK\nCRBJ/XdJlXD/MZm2D/9kriL43vd3+0DNMeA82n2v9mSR2PQqKny39xNlYPyy/1yZ\nP/KXoa4NYSCA971LSd7lv4n/h5bEKgGHxZfttfOzOnWMVSSTfjRyM/df/NNzTUEV\n7ORA5GW18g8PEtS7uRxVBf3cLvWu5q+8jmqES5HqTAdGVcuIFQeBXFN8Gy1Jinuz\nAH8rJSdkUeZ0cehWbERq80BWM9dhad5dW+/+Gv0foFBvP15viwhWqajr8V0B8es+\n2/tHI0k86FAujV5i0rrXl5UOoLilO57QQNDZH/qW9GsHwVI+2yecLstpUNLq+EZC\nGqTZCYoxYRpl0gAMbDLztSL/8Bc0tJrCRG3tavJotFYlgUK60XnXlQzRkh9rgsfT\nEXbQifWdQMMogzjCJr0hzJ+V1d0iozdUxB2ZEgTjukOvatkB77DY1FPZRkSFIQs+\nfdcjazDIBLIxwJu5QwvTNW8lOLnJ46g4sf1WJoUdNTbR0BaC7HHj1inVWi0p7IuN\n66EPGzJOSjLK+vW+J0ncPDEgLCV74RF/0nR5fVTdrmiopPrzFuguHf9S9gYI3Zun\nYl8FJUu4kRO6JPPTicUXWX+8XZmE94aK14RCJL23nOSi8T1eW8JLW43dCBRO8QUE\nAso1t2pypm/1zZexJdOV8yGME3g5l2W6PLgpz58DBECgqc/kda+VWgEAp7rO2A==\n=EPL3\n-----END PGP PUBLIC KEY BLOCK-----\n", - "check_gpg": true - } - ] -} diff --git a/internal/rpmmd/test/repository_test.go b/internal/rpmmd/test/repository_test.go deleted file mode 100644 index 8ee312f61..000000000 --- a/internal/rpmmd/test/repository_test.go +++ /dev/null @@ -1,296 +0,0 @@ -package rpmmdtests - -import ( - "encoding/json" - "fmt" - "path/filepath" - "reflect" - "testing" - - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/stretchr/testify/assert" -) - -func getConfPaths(t *testing.T) []string { - confPaths := []string{ - "./confpaths/priority1", - "./confpaths/priority2", - } - var absConfPaths []string - - for _, path := range confPaths { - absPath, err := filepath.Abs(path) - assert.Nil(t, err) - absConfPaths = append(absConfPaths, absPath) - } - - return absConfPaths -} - -func TestLoadRepositoriesExisting(t *testing.T) { - confPaths := getConfPaths(t) - type args struct { - distro string - } - tests := []struct { - name string - args args - want map[string][]string - }{ - { - name: "duplicate distro definition, load first encounter", - args: args{ - distro: test_distro.TestDistroName, - }, - want: map[string][]string{ - test_distro.TestArchName: {"fedora-p1", "updates-p1", "fedora-modular-p1", "updates-modular-p1"}, - test_distro.TestArch2Name: {"fedora-p1", "updates-p1", "fedora-modular-p1", "updates-modular-p1"}, - }, - }, - { - name: "single distro definition", - args: args{ - distro: test_distro.TestDistro2Name, - }, - want: map[string][]string{ - test_distro.TestArchName: {"baseos-p2", "appstream-p2"}, - test_distro.TestArch2Name: {"baseos-p2", "appstream-p2", "google-compute-engine", "google-cloud-sdk"}, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := rpmmd.LoadRepositories(confPaths, tt.args.distro) - assert.Nil(t, err) - - for wantArch, wantRepos := range tt.want { - gotArchRepos, exists := got[wantArch] - assert.True(t, exists, "Expected '%s' arch in repos definition for '%s', but it does not exist", wantArch, tt.args.distro) - - var gotNames []string - for _, r := range gotArchRepos { - gotNames = append(gotNames, r.Name) - } - - if !reflect.DeepEqual(gotNames, wantRepos) { - t.Errorf("LoadRepositories() for %s/%s =\n got: %#v\n want: %#v", tt.args.distro, wantArch, gotNames, wantRepos) - } - } - - }) - } -} - -func TestLoadRepositoriesNonExisting(t *testing.T) { - confPaths := getConfPaths(t) - repos, err := rpmmd.LoadRepositories(confPaths, "my-imaginary-distro") - assert.Nil(t, repos) - assert.NotNil(t, err) -} - -func Test_LoadAllRepositories(t *testing.T) { - confPaths := getConfPaths(t) - - distroReposMap, err := rpmmd.LoadAllRepositories(confPaths) - assert.NotNil(t, distroReposMap) - assert.Nil(t, err) - assert.Equal(t, len(distroReposMap), 2) - - // test-distro - testDistroRepos, exists := distroReposMap[test_distro.TestDistroName] - assert.True(t, exists) - assert.Equal(t, len(testDistroRepos), 2) - - // test-distro - arches - for _, arch := range []string{test_distro.TestArchName, test_distro.TestArch2Name} { - testDistroArchRepos, exists := testDistroRepos[arch] - assert.True(t, exists) - assert.Equal(t, len(testDistroArchRepos), 4) - - var repoNames []string - for _, r := range testDistroArchRepos { - repoNames = append(repoNames, r.Name) - } - - wantRepos := []string{"fedora-p1", "updates-p1", "fedora-modular-p1", "updates-modular-p1"} - - if !reflect.DeepEqual(repoNames, wantRepos) { - t.Errorf("LoadAllRepositories() for %s/%s =\n got: %#v\n want: %#v", test_distro.TestDistroName, arch, repoNames, wantRepos) - } - } - - // test-distro-2 - testDistro2Repos, exists := distroReposMap[test_distro.TestDistro2Name] - assert.True(t, exists) - assert.Equal(t, len(testDistro2Repos), 2) - - // test-distro-2 - arches - wantRepos := map[string][]string{ - test_distro.TestArchName: {"baseos-p2", "appstream-p2"}, - test_distro.TestArch2Name: {"baseos-p2", "appstream-p2", "google-compute-engine", "google-cloud-sdk"}, - } - for _, arch := range []string{test_distro.TestArchName, test_distro.TestArch2Name} { - testDistro2ArchRepos, exists := testDistro2Repos[arch] - assert.True(t, exists) - assert.Equal(t, len(testDistro2ArchRepos), len(wantRepos[arch])) - - var repoNames []string - for _, r := range testDistro2ArchRepos { - repoNames = append(repoNames, r.Name) - } - - if !reflect.DeepEqual(repoNames, wantRepos[arch]) { - t.Errorf("LoadAllRepositories() for %s/%s =\n got: %#v\n want: %#v", test_distro.TestDistro2Name, arch, repoNames, wantRepos[arch]) - } - } -} - -func TestPackageSetResolveConflictExclude(t *testing.T) { - tests := []struct { - got rpmmd.PackageSet - want rpmmd.PackageSet - }{ - { - got: rpmmd.PackageSet{ - Include: []string{"kernel", "microcode_ctl", "dnf"}, - Exclude: []string{"microcode_ctl"}, - }, - want: rpmmd.PackageSet{ - Include: []string{"kernel", "dnf"}, - Exclude: []string{"microcode_ctl"}, - }, - }, - { - got: rpmmd.PackageSet{ - Include: []string{"kernel", "dnf"}, - Exclude: []string{"microcode_ctl"}, - }, - want: rpmmd.PackageSet{ - Include: []string{"kernel", "dnf"}, - Exclude: []string{"microcode_ctl"}, - }, - }, - { - got: rpmmd.PackageSet{ - Include: []string{"kernel", "microcode_ctl", "dnf"}, - Exclude: []string{}, - }, - want: rpmmd.PackageSet{ - Include: []string{"kernel", "microcode_ctl", "dnf"}, - Exclude: []string{}, - }, - }, - } - for idx, tt := range tests { - t.Run(fmt.Sprintf("%d", idx), func(t *testing.T) { - if !reflect.DeepEqual(tt.got.ResolveConflictsExclude(), tt.want) { - t.Errorf("ResolveConflictExclude() returned unexpected result got: %#v\n want: %#v", tt.got.ResolveConflictsExclude(), tt.want) - } - }) - } -} - -func TestOldWorkerRepositoryCompatUnmarshal(t *testing.T) { - testCases := []struct { - repoJSON []byte - repo rpmmd.RepoConfig - }{ - { - repoJSON: []byte(`{"name":"fedora","baseurl":"http://example.com/fedora"}`), - repo: rpmmd.RepoConfig{ - Name: "fedora", - BaseURLs: []string{"http://example.com/fedora"}, - }, - }, - { - repoJSON: []byte(`{"name":"multiple","baseurl":"http://example.com/one,http://example.com/two"}`), - repo: rpmmd.RepoConfig{ - Name: "multiple", - BaseURLs: []string{"http://example.com/one", "http://example.com/two"}, - }, - }, - { - repoJSON: []byte(`{"id":"all","name":"all","baseurls":["http://example.com/all"],"metalink":"http://example.com/metalink","mirrorlist":"http://example.com/mirrorlist","gpgkeys":["key1","key2"],"check_gpg":true,"check_repo_gpg":true,"ignore_ssl":true,"priority":10,"metadata_expire":"test","rhsm":true,"enabled":true,"image_type_tags":["one","two"],"package_sets":["1","2"],"baseurl":"http://example.com/all"}`), - repo: rpmmd.RepoConfig{ - Id: "all", - Name: "all", - BaseURLs: []string{"http://example.com/all"}, - Metalink: "http://example.com/metalink", - MirrorList: "http://example.com/mirrorlist", - GPGKeys: []string{"key1", "key2"}, - CheckGPG: common.ToPtr(true), - CheckRepoGPG: common.ToPtr(true), - IgnoreSSL: common.ToPtr(true), - Priority: common.ToPtr(10), - MetadataExpire: "test", - RHSM: true, - Enabled: common.ToPtr(true), - ImageTypeTags: []string{"one", "two"}, - PackageSets: []string{"1", "2"}, - }, - }, - } - - for _, tc := range testCases { - t.Run(tc.repo.Name, func(t *testing.T) { - var repo rpmmd.RepoConfig - err := json.Unmarshal(tc.repoJSON, &repo) - assert.Nil(t, err) - assert.Equal(t, tc.repo, repo) - }) - } -} - -func TestOldWorkerRepositoryCompatMarshal(t *testing.T) { - testCases := []struct { - repoJSON []byte - repo rpmmd.RepoConfig - }{ - { - repoJSON: []byte(`{"id":"fedora","name":"fedora","baseurls":["http://example.com/fedora"],"baseurl":"http://example.com/fedora"}`), - repo: rpmmd.RepoConfig{ - Id: "fedora", - Name: "fedora", - BaseURLs: []string{"http://example.com/fedora"}, - }, - }, - { - repoJSON: []byte(`{"id":"multiple","name":"multiple","baseurls":["http://example.com/one","http://example.com/two"],"baseurl":"http://example.com/one,http://example.com/two"}`), - repo: rpmmd.RepoConfig{ - Id: "multiple", - Name: "multiple", - BaseURLs: []string{"http://example.com/one", "http://example.com/two"}, - }, - }, - { - repoJSON: []byte(`{"id":"all","name":"all","baseurls":["http://example.com/all"],"metalink":"http://example.com/metalink","mirrorlist":"http://example.com/mirrorlist","gpgkeys":["key1","key2"],"check_gpg":true,"check_repo_gpg":true,"priority":10,"ignore_ssl":true,"metadata_expire":"test","rhsm":true,"enabled":true,"image_type_tags":["one","two"],"package_sets":["1","2"],"baseurl":"http://example.com/all"}`), - repo: rpmmd.RepoConfig{ - Id: "all", - Name: "all", - BaseURLs: []string{"http://example.com/all"}, - Metalink: "http://example.com/metalink", - MirrorList: "http://example.com/mirrorlist", - GPGKeys: []string{"key1", "key2"}, - CheckGPG: common.ToPtr(true), - CheckRepoGPG: common.ToPtr(true), - Priority: common.ToPtr(10), - IgnoreSSL: common.ToPtr(true), - MetadataExpire: "test", - RHSM: true, - Enabled: common.ToPtr(true), - ImageTypeTags: []string{"one", "two"}, - PackageSets: []string{"1", "2"}, - }, - }, - } - - for _, tc := range testCases { - t.Run(tc.repo.Name, func(t *testing.T) { - gotJson, err := json.Marshal(tc.repo) - assert.Nil(t, err) - assert.Equal(t, tc.repoJSON, gotJson) - }) - } -} diff --git a/internal/store/compose.go b/internal/store/compose.go index e3b53dfd8..5b5a1d00f 100644 --- a/internal/store/compose.go +++ b/internal/store/compose.go @@ -4,11 +4,11 @@ import ( "time" "github.com/google/uuid" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/target" ) diff --git a/internal/store/fixtures.go b/internal/store/fixtures.go index 1336174a0..9e6e92b51 100644 --- a/internal/store/fixtures.go +++ b/internal/store/fixtures.go @@ -5,11 +5,11 @@ import ( "time" "github.com/google/uuid" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/test_distro" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/target" ) diff --git a/internal/store/json.go b/internal/store/json.go index 08e0485c7..3e1377998 100644 --- a/internal/store/json.go +++ b/internal/store/json.go @@ -8,12 +8,12 @@ import ( "time" "github.com/google/uuid" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/target" ) diff --git a/internal/store/json_test.go b/internal/store/json_test.go index 72df8dab8..bf5696fd3 100644 --- a/internal/store/json_test.go +++ b/internal/store/json_test.go @@ -13,14 +13,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/fedora" + "github.com/osbuild/images/pkg/distro/test_distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/fedora" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/target" ) diff --git a/internal/store/store.go b/internal/store/store.go index 248dbeb6f..c1525e16a 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -17,14 +17,14 @@ import ( "sync" "time" - "github.com/osbuild/osbuild-composer/internal/distro" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/manifest" "github.com/osbuild/osbuild-composer/internal/jsondb" - "github.com/osbuild/osbuild-composer/internal/manifest" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distroregistry" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/target" "github.com/google/uuid" diff --git a/internal/store/store_test.go b/internal/store/store_test.go index 735c22ff0..7f3127dc4 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -7,13 +7,13 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/suite" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/test_distro" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/target" ) @@ -52,7 +52,8 @@ func (suite *storeTest) SetupSuite() { suite.myDistro = test_distro.New() suite.myArch, _ = suite.myDistro.GetArch(test_distro.TestArchName) suite.myImageType, _ = suite.myArch.GetImageType(test_distro.TestImageTypeName) - manifest, _, _ := suite.myImageType.Manifest(&suite.myBP, suite.myImageOptions, suite.myRepoConfig, 0) + ibp := blueprint.Convert(suite.myBP) + manifest, _, _ := suite.myImageType.Manifest(&ibp, suite.myImageOptions, suite.myRepoConfig, 0) suite.myManifest, _ = manifest.Serialize(nil, nil, nil) suite.mySourceConfig = SourceConfig{ Name: "testSourceConfig", diff --git a/internal/test/helpers.go b/internal/test/helpers.go index 9a60c0ffa..a34dec347 100644 --- a/internal/test/helpers.go +++ b/internal/test/helpers.go @@ -18,8 +18,8 @@ import ( "github.com/BurntSushi/toml" "github.com/google/go-cmp/cmp" "github.com/google/uuid" + "github.com/osbuild/images/pkg/distro" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/upload/koji/koji.go b/internal/upload/koji/koji.go index e1832a893..67465aeee 100644 --- a/internal/upload/koji/koji.go +++ b/internal/upload/koji/koji.go @@ -25,7 +25,7 @@ import ( "github.com/sirupsen/logrus" "github.com/ubccr/kerby/khttp" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/rpmmd" ) type Koji struct { diff --git a/internal/weldr/api.go b/internal/weldr/api.go index c7ad202da..c30f8f055 100644 --- a/internal/weldr/api.go +++ b/internal/weldr/api.go @@ -31,17 +31,17 @@ import ( "github.com/julienschmidt/httprouter" "github.com/osbuild/osbuild-composer/pkg/jobqueue" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rhsm/facts" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" "github.com/osbuild/osbuild-composer/internal/dnfjson" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" "github.com/osbuild/osbuild-composer/internal/reporegistry" - "github.com/osbuild/osbuild-composer/internal/rhsm/facts" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/store" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/worker" @@ -2503,7 +2503,8 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request return } - manifest, warnings, err := imageType.Manifest(bp, options, imageRepos, seed) + ibp := blueprint.Convert(*bp) + manifest, warnings, err := imageType.Manifest(&ibp, options, imageRepos, seed) if err != nil { errors := responseError{ ID: "ManifestCreationFailed", diff --git a/internal/weldr/api_test.go b/internal/weldr/api_test.go index 2f636ea7b..fa94bae5f 100644 --- a/internal/weldr/api_test.go +++ b/internal/weldr/api_test.go @@ -17,18 +17,18 @@ import ( "time" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/test_distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/ostree/mock_ostree_repo" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" "github.com/osbuild/osbuild-composer/internal/dnfjson" dnfjson_mock "github.com/osbuild/osbuild-composer/internal/mocks/dnfjson" rpmmd_mock "github.com/osbuild/osbuild-composer/internal/mocks/rpmmd" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/ostree/mock_ostree_repo" "github.com/osbuild/osbuild-composer/internal/reporegistry" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/store" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/test" diff --git a/internal/weldr/compose_test.go b/internal/weldr/compose_test.go index 68534b9ba..628c6956f 100644 --- a/internal/weldr/compose_test.go +++ b/internal/weldr/compose_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/test_distro" rpmmd_mock "github.com/osbuild/osbuild-composer/internal/mocks/rpmmd" "github.com/osbuild/osbuild-composer/internal/worker" "github.com/osbuild/osbuild-composer/internal/worker/clienterrors" diff --git a/internal/weldr/json.go b/internal/weldr/json.go index c7149b400..81268549d 100644 --- a/internal/weldr/json.go +++ b/internal/weldr/json.go @@ -5,9 +5,9 @@ package weldr import ( "github.com/google/uuid" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/blueprint" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/store" ) diff --git a/internal/weldr/upload.go b/internal/weldr/upload.go index 01ad9422a..99ee19dcf 100644 --- a/internal/weldr/upload.go +++ b/internal/weldr/upload.go @@ -9,8 +9,8 @@ import ( "time" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/osbuild/images/pkg/distro" "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" "github.com/sirupsen/logrus" "github.com/google/uuid" diff --git a/internal/worker/json.go b/internal/worker/json.go index 2f0683f00..04824d0ff 100644 --- a/internal/worker/json.go +++ b/internal/worker/json.go @@ -4,10 +4,10 @@ import ( "encoding/json" "fmt" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/worker/clienterrors" ) diff --git a/internal/worker/json_test.go b/internal/worker/json_test.go index e1c04d4a2..310e1839f 100644 --- a/internal/worker/json_test.go +++ b/internal/worker/json_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/osbuild/osbuild-composer/internal/distro" + "github.com/osbuild/images/pkg/distro" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/worker/clienterrors" "github.com/stretchr/testify/assert" diff --git a/internal/worker/server_test.go b/internal/worker/server_test.go index 455426fe8..f11473772 100644 --- a/internal/worker/server_test.go +++ b/internal/worker/server_test.go @@ -16,13 +16,13 @@ import ( "github.com/osbuild/osbuild-composer/pkg/jobqueue" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/test_distro" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/test_distro" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/jobqueue/fsjobqueue" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/osbuild" "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/test" "github.com/osbuild/osbuild-composer/internal/worker" diff --git a/internal/workload/workload.go b/internal/workload/workload.go index b147e3f77..24aa570f0 100644 --- a/internal/workload/workload.go +++ b/internal/workload/workload.go @@ -1,6 +1,6 @@ package workload -import "github.com/osbuild/osbuild-composer/internal/rpmmd" +import "github.com/osbuild/images/pkg/rpmmd" type Workload interface { GetPackages() []string diff --git a/vendor/github.com/osbuild/images/LICENSE b/vendor/github.com/osbuild/images/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/vendor/github.com/osbuild/images/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/osbuild/images/internal/common/constants.go b/vendor/github.com/osbuild/images/internal/common/constants.go new file mode 100644 index 000000000..7c570a708 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/common/constants.go @@ -0,0 +1,38 @@ +package common + +import "fmt" + +const ( + KiloByte = 1000 // kB + KibiByte = 1024 // KiB + MegaByte = 1000 * 1000 // MB + MebiByte = 1024 * 1024 // MiB + GigaByte = 1000 * 1000 * 1000 // GB + GibiByte = 1024 * 1024 * 1024 // GiB + TeraByte = 1000 * 1000 * 1000 * 1000 // TB + TebiByte = 1024 * 1024 * 1024 * 1024 // TiB +) + +// These constants are set during buildtime using additional +// compiler flags. Not all of them are necessarily defined +// because RPMs can be build from a tarball and spec file without +// being in a git repository. On the other hand when building +// composer inside of a container, there is no RPM layer so in +// that case the RPM version doesn't exist at all. +var ( + // Git revision from which this code was built + GitRev = "undefined" + + // RPM Version + RpmVersion = "undefined" +) + +func BuildVersion() string { + if GitRev != "undefined" { + return fmt.Sprintf("git-rev:%s", GitRev) + } else if RpmVersion != "undefined" { + return fmt.Sprintf("NEVRA:%s", RpmVersion) + } else { + return "devel" + } +} diff --git a/vendor/github.com/osbuild/images/internal/common/distro.go b/vendor/github.com/osbuild/images/internal/common/distro.go new file mode 100644 index 000000000..9f8500719 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/common/distro.go @@ -0,0 +1,83 @@ +package common + +import ( + "bufio" + "errors" + "io" + "os" + "strings" +) + +func GetHostDistroName() (string, bool, bool, error) { + f, err := os.Open("/etc/os-release") + if err != nil { + return "", false, false, err + } + defer f.Close() + osrelease, err := readOSRelease(f) + if err != nil { + return "", false, false, err + } + + isStream := osrelease["NAME"] == "CentOS Stream" + + version := strings.Split(osrelease["VERSION_ID"], ".") + name := osrelease["ID"] + "-" + strings.Join(version, "") + + // TODO: We should probably index these things by the full CPE + beta := strings.Contains(osrelease["CPE_NAME"], "beta") + return name, beta, isStream, nil +} + +func readOSRelease(r io.Reader) (map[string]string, error) { + osrelease := make(map[string]string) + scanner := bufio.NewScanner(r) + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + if len(line) == 0 { + continue + } + + parts := strings.SplitN(line, "=", 2) + if len(parts) != 2 { + return nil, errors.New("readOSRelease: invalid input") + } + + key := strings.TrimSpace(parts[0]) + // drop all surrounding whitespace and double-quotes + value := strings.Trim(strings.TrimSpace(parts[1]), "\"") + osrelease[key] = value + } + + return osrelease, nil +} + +// Returns true if the version represented by the first argument is +// semantically older than the second. +// Meant to be used for comparing distro versions for differences between minor +// releases. +// Evaluates to false if a and b are equal. +// Assumes any missing components are 0, so 8 < 8.1. +func VersionLessThan(a, b string) bool { + aParts := strings.Split(a, ".") + bParts := strings.Split(b, ".") + + // pad shortest argument with zeroes + for len(aParts) < len(bParts) { + aParts = append(aParts, "0") + } + for len(bParts) < len(aParts) { + bParts = append(bParts, "0") + } + + for idx := 0; idx < len(aParts); idx++ { + if aParts[idx] < bParts[idx] { + return true + } else if aParts[idx] > bParts[idx] { + return false + } + } + + // equal + return false +} diff --git a/vendor/github.com/osbuild/images/internal/common/echo_logrus.go b/vendor/github.com/osbuild/images/internal/common/echo_logrus.go new file mode 100644 index 000000000..6871f8713 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/common/echo_logrus.go @@ -0,0 +1,175 @@ +package common + +import ( + "encoding/json" + "io" + + "github.com/labstack/gommon/log" + "github.com/sirupsen/logrus" +) + +// EchoLogrusLogger extend logrus.Logger +type EchoLogrusLogger struct { + *logrus.Logger +} + +var commonLogger = &EchoLogrusLogger{ + Logger: logrus.StandardLogger(), +} + +func Logger() *EchoLogrusLogger { + return commonLogger +} + +func toEchoLevel(level logrus.Level) log.Lvl { + switch level { + case logrus.DebugLevel: + return log.DEBUG + case logrus.InfoLevel: + return log.INFO + case logrus.WarnLevel: + return log.WARN + case logrus.ErrorLevel: + return log.ERROR + } + + return log.OFF +} + +func (l *EchoLogrusLogger) Output() io.Writer { + return l.Out +} + +func (l *EchoLogrusLogger) SetOutput(w io.Writer) { + // disable operations that would change behavior of global logrus logger. +} + +func (l *EchoLogrusLogger) Level() log.Lvl { + return toEchoLevel(l.Logger.Level) +} + +func (l *EchoLogrusLogger) SetLevel(v log.Lvl) { + // disable operations that would change behavior of global logrus logger. +} + +func (l *EchoLogrusLogger) SetHeader(h string) { +} + +func (l *EchoLogrusLogger) Prefix() string { + return "" +} + +func (l *EchoLogrusLogger) SetPrefix(p string) { +} + +func (l *EchoLogrusLogger) Print(i ...interface{}) { + l.Logger.Print(i...) +} + +func (l *EchoLogrusLogger) Printf(format string, args ...interface{}) { + l.Logger.Printf(format, args...) +} + +func (l *EchoLogrusLogger) Printj(j log.JSON) { + b, err := json.Marshal(j) + if err != nil { + panic(err) + } + l.Logger.Println(string(b)) +} + +func (l *EchoLogrusLogger) Debug(i ...interface{}) { + l.Logger.Debug(i...) +} + +func (l *EchoLogrusLogger) Debugf(format string, args ...interface{}) { + l.Logger.Debugf(format, args...) +} + +func (l *EchoLogrusLogger) Debugj(j log.JSON) { + b, err := json.Marshal(j) + if err != nil { + panic(err) + } + l.Logger.Debugln(string(b)) +} + +func (l *EchoLogrusLogger) Info(i ...interface{}) { + l.Logger.Info(i...) +} + +func (l *EchoLogrusLogger) Infof(format string, args ...interface{}) { + l.Logger.Infof(format, args...) +} + +func (l *EchoLogrusLogger) Infoj(j log.JSON) { + b, err := json.Marshal(j) + if err != nil { + panic(err) + } + l.Logger.Infoln(string(b)) +} + +func (l *EchoLogrusLogger) Warn(i ...interface{}) { + l.Logger.Warn(i...) +} + +func (l *EchoLogrusLogger) Warnf(format string, args ...interface{}) { + l.Logger.Warnf(format, args...) +} + +func (l *EchoLogrusLogger) Warnj(j log.JSON) { + b, err := json.Marshal(j) + if err != nil { + panic(err) + } + l.Logger.Warnln(string(b)) +} + +func (l *EchoLogrusLogger) Error(i ...interface{}) { + l.Logger.Error(i...) +} + +func (l *EchoLogrusLogger) Errorf(format string, args ...interface{}) { + l.Logger.Errorf(format, args...) +} + +func (l *EchoLogrusLogger) Errorj(j log.JSON) { + b, err := json.Marshal(j) + if err != nil { + panic(err) + } + l.Logger.Errorln(string(b)) +} + +func (l *EchoLogrusLogger) Fatal(i ...interface{}) { + l.Logger.Fatal(i...) +} + +func (l *EchoLogrusLogger) Fatalf(format string, args ...interface{}) { + l.Logger.Fatalf(format, args...) +} + +func (l *EchoLogrusLogger) Fatalj(j log.JSON) { + b, err := json.Marshal(j) + if err != nil { + panic(err) + } + l.Logger.Fatalln(string(b)) +} + +func (l *EchoLogrusLogger) Panic(i ...interface{}) { + l.Logger.Panic(i...) +} + +func (l *EchoLogrusLogger) Panicf(format string, args ...interface{}) { + l.Logger.Panicf(format, args...) +} + +func (l *EchoLogrusLogger) Panicj(j log.JSON) { + b, err := json.Marshal(j) + if err != nil { + panic(err) + } + l.Logger.Panicln(string(b)) +} diff --git a/vendor/github.com/osbuild/images/internal/common/helpers.go b/vendor/github.com/osbuild/images/internal/common/helpers.go new file mode 100644 index 000000000..729e05189 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/common/helpers.go @@ -0,0 +1,103 @@ +package common + +import ( + "fmt" + "io" + "regexp" + "runtime" + "sort" + "strconv" + "strings" +) + +var RuntimeGOARCH = runtime.GOARCH + +func CurrentArch() string { + if RuntimeGOARCH == "amd64" { + return "x86_64" + } else if RuntimeGOARCH == "arm64" { + return "aarch64" + } else if RuntimeGOARCH == "ppc64le" { + return "ppc64le" + } else if RuntimeGOARCH == "s390x" { + return "s390x" + } else { + panic("unsupported architecture") + } +} + +func PanicOnError(err error) { + if err != nil { + panic(err) + } +} + +// IsStringInSortedSlice returns true if the string is present, false if not +// slice must be sorted +func IsStringInSortedSlice(slice []string, s string) bool { + i := sort.SearchStrings(slice, s) + if i < len(slice) && slice[i] == s { + return true + } + return false +} + +// DataSizeToUint64 converts a size specified as a string in KB/KiB/MB/etc. to +// a number of bytes represented by uint64. +func DataSizeToUint64(size string) (uint64, error) { + // Pre-process the input + size = strings.TrimSpace(size) + + // Get the number from the string + plain_number := regexp.MustCompile(`[[:digit:]]+`) + number_as_str := plain_number.FindString(size) + if number_as_str == "" { + return 0, fmt.Errorf("the size string doesn't contain any number: %s", size) + } + + // Parse the number into integer + return_size, err := strconv.ParseUint(number_as_str, 10, 64) + if err != nil { + return 0, fmt.Errorf("failed to parse size as integer: %s", number_as_str) + } + + // List of all supported units (from kB to TB and KiB to TiB) + supported_units := []struct { + re *regexp.Regexp + multiple uint64 + }{ + {regexp.MustCompile(`^\s*[[:digit:]]+\s*kB$`), KiloByte}, + {regexp.MustCompile(`^\s*[[:digit:]]+\s*KiB$`), KibiByte}, + {regexp.MustCompile(`^\s*[[:digit:]]+\s*MB$`), MegaByte}, + {regexp.MustCompile(`^\s*[[:digit:]]+\s*MiB$`), MebiByte}, + {regexp.MustCompile(`^\s*[[:digit:]]+\s*GB$`), GigaByte}, + {regexp.MustCompile(`^\s*[[:digit:]]+\s*GiB$`), GibiByte}, + {regexp.MustCompile(`^\s*[[:digit:]]+\s*TB$`), TeraByte}, + {regexp.MustCompile(`^\s*[[:digit:]]+\s*TiB$`), TebiByte}, + {regexp.MustCompile(`^\s*[[:digit:]]+$`), 1}, + } + + for _, unit := range supported_units { + if unit.re.MatchString(size) { + return_size *= unit.multiple + return return_size, nil + } + } + + // In case the strign didn't match any of the above regexes, return nil + // even if a number was found. This is to prevent users from submitting + // unknown units. + return 0, fmt.Errorf("unknown data size units in string: %s", size) +} + +// NopSeekCloser returns an io.ReadSeekCloser with a no-op Close method +// wrapping the provided io.ReadSeeker r. +func NopSeekCloser(r io.ReadSeeker) io.ReadSeekCloser { + return nopSeekCloser{r} +} + +type nopSeekCloser struct { + io.ReadSeeker +} + +func (nopSeekCloser) Close() error { return nil } diff --git a/vendor/github.com/osbuild/images/internal/common/operation_id.go b/vendor/github.com/osbuild/images/internal/common/operation_id.go new file mode 100644 index 000000000..1c522e78e --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/common/operation_id.go @@ -0,0 +1,22 @@ +package common + +import ( + "github.com/labstack/echo/v4" + "github.com/segmentio/ksuid" +) + +const OperationIDKey string = "operationID" + +// Adds a time-sortable globally unique identifier to an echo.Context if not already set +func OperationIDMiddleware(next echo.HandlerFunc) echo.HandlerFunc { + return func(c echo.Context) error { + if c.Get(OperationIDKey) == nil { + c.Set(OperationIDKey, GenerateOperationID()) + } + return next(c) + } +} + +func GenerateOperationID() string { + return ksuid.New().String() +} diff --git a/vendor/github.com/osbuild/images/internal/common/pointers.go b/vendor/github.com/osbuild/images/internal/common/pointers.go new file mode 100644 index 000000000..58be2aab1 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/common/pointers.go @@ -0,0 +1,5 @@ +package common + +func ToPtr[T any](x T) *T { + return &x +} diff --git a/vendor/github.com/osbuild/images/internal/common/states.go b/vendor/github.com/osbuild/images/internal/common/states.go new file mode 100644 index 000000000..dbc4cb9de --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/common/states.go @@ -0,0 +1,71 @@ +package common + +import ( + "encoding/json" +) + +func getStateMapping() []string { + return []string{"WAITING", "RUNNING", "FINISHED", "FAILED"} +} + +type ImageBuildState int + +const ( + IBWaiting ImageBuildState = iota + IBRunning + IBFinished + IBFailed +) + +// CustomJsonConversionError is thrown when parsing strings into enumerations +type CustomJsonConversionError struct { + reason string +} + +// Error returns the error as a string +func (err *CustomJsonConversionError) Error() string { + return err.reason +} + +// CustomTypeError is thrown when parsing strings into enumerations +type CustomTypeError struct { + reason string +} + +// Error returns the error as a string +func (err *CustomTypeError) Error() string { + return err.reason +} + +// ToString converts ImageBuildState into a human readable string +func (ibs ImageBuildState) ToString() string { + return getStateMapping()[int(ibs)] +} + +func unmarshalStateHelper(data []byte, mapping []string) (int, error) { + var stringInput string + err := json.Unmarshal(data, &stringInput) + if err != nil { + return 0, err + } + for n, str := range mapping { + if str == stringInput { + return n, nil + } + } + return 0, &CustomJsonConversionError{"invalid image build status:" + stringInput} +} + +// UnmarshalJSON converts a JSON string into an ImageBuildState +func (ibs *ImageBuildState) UnmarshalJSON(data []byte) error { + val, err := unmarshalStateHelper(data, getStateMapping()) + if err != nil { + return err + } + *ibs = ImageBuildState(val) + return nil +} + +func (ibs ImageBuildState) MarshalJSON() ([]byte, error) { + return json.Marshal(getStateMapping()[ibs]) +} diff --git a/vendor/github.com/osbuild/images/internal/dnfjson/cache.go b/vendor/github.com/osbuild/images/internal/dnfjson/cache.go new file mode 100644 index 000000000..4deca4458 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/dnfjson/cache.go @@ -0,0 +1,325 @@ +package dnfjson + +import ( + "fmt" + "io/fs" + "os" + "path/filepath" + "sort" + "sync" + "time" + + "github.com/osbuild/images/pkg/rpmmd" + + "github.com/gobwas/glob" +) + +// CleanupOldCacheDirs will remove cache directories for unsupported distros +// eg. Once support for a fedora release stops and it is removed, this will +// delete its directory under root. +// +// A happy side effect of this is that it will delete old cache directories +// and files from before the switch to per-distro cache directories. +// +// NOTE: This does not return any errors. This is because the most common one +// will be a nonexistant directory which will be created later, during initial +// cache creation. Any other errors like permission issues will be caught by +// later use of the cache. eg. touchRepo +func CleanupOldCacheDirs(root string, distros []string) { + dirs, _ := os.ReadDir(root) + + for _, e := range dirs { + if strSliceContains(distros, e.Name()) { + // known distro + continue + } + if e.IsDir() { + // Remove the directory and everything under it + _ = os.RemoveAll(filepath.Join(root, e.Name())) + } else { + _ = os.Remove(filepath.Join(root, e.Name())) + } + } +} + +// strSliceContains returns true if the elem string is in the slc array +func strSliceContains(slc []string, elem string) bool { + for _, s := range slc { + if elem == s { + return true + } + } + return false +} + +// global cache locker +var cacheLocks sync.Map + +// A collection of directory paths, their total size, and their most recent +// modification time. +type pathInfo struct { + paths []string + size uint64 + mtime time.Time +} + +type rpmCache struct { + // root path for the cache + root string + + // individual repository cache data + repoElements map[string]pathInfo + + // list of known repository IDs, sorted by mtime + repoRecency []string + + // total cache size + size uint64 + + // max cache size + maxSize uint64 + + // locker for this cache directory + locker *sync.RWMutex +} + +func newRPMCache(path string, maxSize uint64) *rpmCache { + absPath, err := filepath.Abs(path) // convert to abs if it's not already + if err != nil { + panic(err) // can only happen if the CWD does not exist and the path isn't already absolute + } + path = absPath + locker := new(sync.RWMutex) + if l, loaded := cacheLocks.LoadOrStore(path, locker); loaded { + // value existed and was loaded + locker = l.(*sync.RWMutex) + } + r := &rpmCache{ + root: path, + repoElements: make(map[string]pathInfo), + size: 0, + maxSize: maxSize, + locker: locker, + } + // collect existing cache paths and timestamps + r.updateInfo() + return r +} + +// updateInfo updates the repoPaths and repoRecency fields of the rpmCache. +// +// NOTE: This does not return any errors. This is because the most common one +// will be a nonexistant directory which will be created later, during initial +// cache creation. Any other errors like permission issues will be caught by +// later use of the cache. eg. touchRepo +func (r *rpmCache) updateInfo() { + dirs, _ := os.ReadDir(r.root) + for _, d := range dirs { + r.updateCacheDirInfo(filepath.Join(r.root, d.Name())) + } +} + +func (r *rpmCache) updateCacheDirInfo(path string) { + // See updateInfo NOTE on error handling + cacheEntries, _ := os.ReadDir(path) + + // each repository has multiple cache entries (3 on average), so using the + // number of cacheEntries to allocate the map and ID slice is a high upper + // bound, but guarantees we wont need to grow and reallocate either. + repos := make(map[string]pathInfo, len(cacheEntries)) + repoIDs := make([]string, 0, len(cacheEntries)) + + var totalSize uint64 + + // Collect the paths grouped by their repo ID + // We assume the first 64 characters of a file or directory name are the + // repository ID because we use a sha256 sum of the repository config to + // create the ID (64 hex chars) + for _, entry := range cacheEntries { + eInfo, err := entry.Info() + if err != nil { + // skip it + continue + } + + fname := entry.Name() + if len(fname) < 64 { + // unknown file in cache; ignore + continue + } + repoID := fname[:64] + repo, ok := repos[repoID] + if !ok { + // new repo ID + repoIDs = append(repoIDs, repoID) + } + mtime := eInfo.ModTime() + ePath := filepath.Join(path, entry.Name()) + + // calculate and add entry size + size, err := dirSize(ePath) + if err != nil { + // skip it + continue + } + repo.size += size + totalSize += size + + // add path + repo.paths = append(repo.paths, ePath) + + // if for some reason the mtimes of the various entries of a single + // repository are out of sync, use the most recent one + if repo.mtime.Before(mtime) { + repo.mtime = mtime + } + + // update the collection + repos[repoID] = repo + } + sortFunc := func(idx, jdx int) bool { + ir := repos[repoIDs[idx]] + jr := repos[repoIDs[jdx]] + return ir.mtime.Before(jr.mtime) + } + + // sort IDs by mtime (oldest first) + sort.Slice(repoIDs, sortFunc) + + r.size = totalSize + r.repoElements = repos + r.repoRecency = repoIDs +} + +func (r *rpmCache) shrink() error { + r.locker.Lock() + defer r.locker.Unlock() + + // start deleting until we drop below r.maxSize + nDeleted := 0 + for idx := 0; idx < len(r.repoRecency) && r.size >= r.maxSize; idx++ { + repoID := r.repoRecency[idx] + nDeleted++ + repo, ok := r.repoElements[repoID] + if !ok { + // cache inconsistency? + // ignore and let the ID be removed from the recency list + continue + } + for _, gPath := range repo.paths { + if err := os.RemoveAll(gPath); err != nil { + return err + } + } + r.size -= repo.size + delete(r.repoElements, repoID) + } + + // update recency list + r.repoRecency = r.repoRecency[nDeleted:] + return nil +} + +// Update file atime and mtime on the filesystem to time t for all files in the +// root of the cache that match the repo ID. This should be called whenever a +// repository is used. +// This function does not update the internal cache info. A call to +// updateInfo() should be made after touching one or more repositories. +func (r *rpmCache) touchRepo(repoID string, t time.Time) error { + repoGlob, err := glob.Compile(fmt.Sprintf("%s*", repoID)) + if err != nil { + return err + } + + distroDirs, err := os.ReadDir(r.root) + if err != nil { + return err + } + for _, d := range distroDirs { + // we only touch the top-level directories and files of the cache + cacheEntries, err := os.ReadDir(filepath.Join(r.root, d.Name())) + if err != nil { + return err + } + + for _, cacheEntry := range cacheEntries { + if repoGlob.Match(cacheEntry.Name()) { + path := filepath.Join(r.root, d.Name(), cacheEntry.Name()) + if err := os.Chtimes(path, t, t); err != nil { + return err + } + } + } + } + return nil +} + +func dirSize(path string) (uint64, error) { + var size uint64 + sizer := func(path string, info fs.FileInfo, err error) error { + if err != nil { + return err + } + size += uint64(info.Size()) + return nil + } + err := filepath.Walk(path, sizer) + return size, err +} + +// dnfResults holds the results of a dnfjson request +// expire is the time the request was made, used to expire the entry +type dnfResults struct { + expire time.Time + pkgs rpmmd.PackageList +} + +// dnfCache is a cache of results from dnf-json requests +type dnfCache struct { + results map[string]dnfResults + timeout time.Duration + *sync.RWMutex +} + +// NewDNFCache returns a pointer to an initialized dnfCache struct +func NewDNFCache(timeout time.Duration) *dnfCache { + return &dnfCache{ + results: make(map[string]dnfResults), + timeout: timeout, + RWMutex: new(sync.RWMutex), + } +} + +// CleanCache deletes unused cache entries +// This prevents the cache from growing for longer than the timeout interval +func (d *dnfCache) CleanCache() { + d.Lock() + defer d.Unlock() + + // Delete expired resultCache entries + for k := range d.results { + if time.Since(d.results[k].expire) > d.timeout { + delete(d.results, k) + } + } +} + +// Get returns the package list and true if cached +// or an empty list and false if not cached or if cache is timed out +func (d *dnfCache) Get(hash string) (rpmmd.PackageList, bool) { + d.RLock() + defer d.RUnlock() + + result, ok := d.results[hash] + if !ok || time.Since(result.expire) >= d.timeout { + return rpmmd.PackageList{}, false + } + return result.pkgs, true +} + +// Store saves the package list in the cache +func (d *dnfCache) Store(hash string, pkgs rpmmd.PackageList) { + d.Lock() + defer d.Unlock() + d.results[hash] = dnfResults{expire: time.Now(), pkgs: pkgs} +} diff --git a/vendor/github.com/osbuild/images/internal/dnfjson/dnfjson.go b/vendor/github.com/osbuild/images/internal/dnfjson/dnfjson.go new file mode 100644 index 000000000..27a804d92 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/dnfjson/dnfjson.go @@ -0,0 +1,651 @@ +// Package dnfjson is an interface to the dnf-json Python script that is +// packaged with the osbuild-composer project. The core component of this +// package is the Solver type. The Solver can be configured with +// distribution-specific values (platform ID, architecture, and version +// information) and provides methods for dependency resolution (Depsolve) and +// retrieving a full list of repository package metadata (FetchMetadata). +// +// Alternatively, a BaseSolver can be created which represents an un-configured +// Solver. This type can't be used for depsolving, but can be used to create +// configured Solver instances sharing the same cache directory. +// +// This package relies on the types defined in rpmmd to describe RPM package +// metadata. +package dnfjson + +import ( + "bytes" + "crypto/sha256" + "encoding/json" + "fmt" + "os" + "os/exec" + "path/filepath" + "sort" + "strings" + "time" + + "github.com/osbuild/images/pkg/rhsm" + "github.com/osbuild/images/pkg/rpmmd" +) + +// BaseSolver defines the basic solver configuration without platform +// information. It can be used to create configured Solver instances with the +// NewWithConfig() method. A BaseSolver maintains the global repository cache +// directory. +type BaseSolver struct { + // Cache information + cache *rpmCache + + // Path to the dnf-json binary and optional args (default: "/usr/libexec/osbuild-composer/dnf-json") + dnfJsonCmd []string + + resultCache *dnfCache +} + +// Create a new unconfigured BaseSolver (without platform information). It can +// be used to create configured Solver instances with the NewWithConfig() +// method. +func NewBaseSolver(cacheDir string) *BaseSolver { + return &BaseSolver{ + cache: newRPMCache(cacheDir, 1024*1024*1024), // 1 GiB + dnfJsonCmd: []string{"/usr/libexec/osbuild-composer/dnf-json"}, + resultCache: NewDNFCache(60 * time.Second), + } +} + +// SetMaxCacheSize sets the maximum size for the global repository metadata +// cache. This is the maximum size of the cache after a CleanCache() +// call. Cache cleanup is never performed automatically. +func (s *BaseSolver) SetMaxCacheSize(size uint64) { + s.cache.maxSize = size +} + +// SetDNFJSONPath sets the path to the dnf-json binary and optionally any command line arguments. +func (s *BaseSolver) SetDNFJSONPath(cmd string, args ...string) { + s.dnfJsonCmd = append([]string{cmd}, args...) +} + +// NewWithConfig initialises a Solver with the platform information and the +// BaseSolver's subscription info, cache directory, and dnf-json path. +// Also loads system subscription information. +func (bs *BaseSolver) NewWithConfig(modulePlatformID, releaseVer, arch, distro string) *Solver { + s := new(Solver) + s.BaseSolver = *bs + s.modulePlatformID = modulePlatformID + s.arch = arch + s.releaseVer = releaseVer + s.distro = distro + subs, _ := rhsm.LoadSystemSubscriptions() + s.subscriptions = subs + return s +} + +// CleanCache deletes the least recently used repository metadata caches until +// the total size of the cache falls below the configured maximum size (see +// SetMaxCacheSize()). +func (bs *BaseSolver) CleanCache() error { + bs.resultCache.CleanCache() + return bs.cache.shrink() +} + +// Solver is configured with system information in order to resolve +// dependencies for RPM packages using DNF. +type Solver struct { + BaseSolver + + // Platform ID, e.g., "platform:el8" + modulePlatformID string + + // System architecture + arch string + + // Release version of the distro. This is used in repo files on the host + // system and required for subscription support. + releaseVer string + + // Full distribution string, eg. fedora-38, used to create separate dnf cache directories + // for each distribution. + distro string + + subscriptions *rhsm.Subscriptions +} + +// Create a new Solver with the given configuration. Initialising a Solver also loads system subscription information. +func NewSolver(modulePlatformID, releaseVer, arch, distro, cacheDir string) *Solver { + s := NewBaseSolver(cacheDir) + return s.NewWithConfig(modulePlatformID, releaseVer, arch, distro) +} + +// GetCacheDir returns a distro specific rpm cache directory +// It ensures that the distro name is below the root cache directory, and if there is +// a problem it returns the root cache intead of an error. +func (s *Solver) GetCacheDir() string { + b := filepath.Base(s.distro) + if b == "." || b == "/" { + return s.cache.root + } + + return filepath.Join(s.cache.root, s.distro) +} + +// Depsolve the list of required package sets with explicit excludes using +// their associated repositories. Each package set is depsolved as a separate +// transactions in a chain. It returns a list of all packages (with solved +// dependencies) that will be installed into the system. +func (s *Solver) Depsolve(pkgSets []rpmmd.PackageSet) ([]rpmmd.PackageSpec, error) { + req, repoMap, err := s.makeDepsolveRequest(pkgSets) + if err != nil { + return nil, err + } + + // get non-exclusive read lock + s.cache.locker.RLock() + defer s.cache.locker.RUnlock() + + output, err := run(s.dnfJsonCmd, req) + if err != nil { + return nil, err + } + // touch repos to now + now := time.Now().Local() + for _, r := range repoMap { + // ignore errors + _ = s.cache.touchRepo(r.Hash(), now) + } + s.cache.updateInfo() + + var result packageSpecs + if err := json.Unmarshal(output, &result); err != nil { + return nil, err + } + + return result.toRPMMD(repoMap), nil +} + +// FetchMetadata returns the list of all the available packages in repos and +// their info. +func (s *Solver) FetchMetadata(repos []rpmmd.RepoConfig) (rpmmd.PackageList, error) { + req, err := s.makeDumpRequest(repos) + if err != nil { + return nil, err + } + + // get non-exclusive read lock + s.cache.locker.RLock() + defer s.cache.locker.RUnlock() + + // Is this cached? + if pkgs, ok := s.resultCache.Get(req.Hash()); ok { + return pkgs, nil + } + + result, err := run(s.dnfJsonCmd, req) + if err != nil { + return nil, err + } + + // touch repos to now + now := time.Now().Local() + for _, r := range repos { + // ignore errors + _ = s.cache.touchRepo(r.Hash(), now) + } + s.cache.updateInfo() + + var pkgs rpmmd.PackageList + if err := json.Unmarshal(result, &pkgs); err != nil { + return nil, err + } + + sortID := func(pkg rpmmd.Package) string { + return fmt.Sprintf("%s-%s-%s", pkg.Name, pkg.Version, pkg.Release) + } + sort.Slice(pkgs, func(i, j int) bool { + return sortID(pkgs[i]) < sortID(pkgs[j]) + }) + + // Cache the results + s.resultCache.Store(req.Hash(), pkgs) + return pkgs, nil +} + +// SearchMetadata searches for packages and returns a list of the info for matches. +func (s *Solver) SearchMetadata(repos []rpmmd.RepoConfig, packages []string) (rpmmd.PackageList, error) { + req, err := s.makeSearchRequest(repos, packages) + if err != nil { + return nil, err + } + + // get non-exclusive read lock + s.cache.locker.RLock() + defer s.cache.locker.RUnlock() + + // Is this cached? + if pkgs, ok := s.resultCache.Get(req.Hash()); ok { + return pkgs, nil + } + + result, err := run(s.dnfJsonCmd, req) + if err != nil { + return nil, err + } + + // touch repos to now + now := time.Now().Local() + for _, r := range repos { + // ignore errors + _ = s.cache.touchRepo(r.Hash(), now) + } + s.cache.updateInfo() + + var pkgs rpmmd.PackageList + if err := json.Unmarshal(result, &pkgs); err != nil { + return nil, err + } + + sortID := func(pkg rpmmd.Package) string { + return fmt.Sprintf("%s-%s-%s", pkg.Name, pkg.Version, pkg.Release) + } + sort.Slice(pkgs, func(i, j int) bool { + return sortID(pkgs[i]) < sortID(pkgs[j]) + }) + + // Cache the results + s.resultCache.Store(req.Hash(), pkgs) + return pkgs, nil +} + +func (s *Solver) reposFromRPMMD(rpmRepos []rpmmd.RepoConfig) ([]repoConfig, error) { + dnfRepos := make([]repoConfig, len(rpmRepos)) + for idx, rr := range rpmRepos { + dr := repoConfig{ + ID: rr.Hash(), + Name: rr.Name, + BaseURLs: rr.BaseURLs, + Metalink: rr.Metalink, + MirrorList: rr.MirrorList, + GPGKeys: rr.GPGKeys, + MetadataExpire: rr.MetadataExpire, + repoHash: rr.Hash(), + } + + if rr.CheckGPG != nil { + dr.CheckGPG = *rr.CheckGPG + } + + if rr.CheckRepoGPG != nil { + dr.CheckRepoGPG = *rr.CheckRepoGPG + } + + if rr.IgnoreSSL != nil { + dr.IgnoreSSL = *rr.IgnoreSSL + } + + if rr.RHSM { + if s.subscriptions == nil { + return nil, fmt.Errorf("This system does not have any valid subscriptions. Subscribe it before specifying rhsm: true in sources.") + } + secrets, err := s.subscriptions.GetSecretsForBaseurl(rr.BaseURLs, s.arch, s.releaseVer) + if err != nil { + return nil, fmt.Errorf("RHSM secrets not found on the host for this baseurl: %s", rr.BaseURLs) + } + dr.SSLCACert = secrets.SSLCACert + dr.SSLClientKey = secrets.SSLClientKey + dr.SSLClientCert = secrets.SSLClientCert + } + dnfRepos[idx] = dr + } + return dnfRepos, nil +} + +// Repository configuration for resolving dependencies for a set of packages. A +// Solver needs at least one RPM repository configured to be able to depsolve. +type repoConfig struct { + ID string `json:"id"` + Name string `json:"name,omitempty"` + BaseURLs []string `json:"baseurl,omitempty"` + Metalink string `json:"metalink,omitempty"` + MirrorList string `json:"mirrorlist,omitempty"` + GPGKeys []string `json:"gpgkeys,omitempty"` + CheckGPG bool `json:"gpgcheck"` + CheckRepoGPG bool `json:"check_repogpg"` + IgnoreSSL bool `json:"ignoressl"` + SSLCACert string `json:"sslcacert,omitempty"` + SSLClientKey string `json:"sslclientkey,omitempty"` + SSLClientCert string `json:"sslclientcert,omitempty"` + MetadataExpire string `json:"metadata_expire,omitempty"` + // set the repo hass from `rpmmd.RepoConfig.Hash()` function + // rather than re-calculating it + repoHash string +} + +// use the hash calculated by the `rpmmd.RepoConfig.Hash()` +// function rather than re-implementing the same code +func (r *repoConfig) Hash() string { + return r.repoHash +} + +// Helper function for creating a depsolve request payload. +// The request defines a sequence of transactions, each depsolving one of the +// elements of `pkgSets` in the order they appear. The `repoConfigs` are used +// as the base repositories for all transactions. The extra repository configs +// in `pkgsetsRepos` are used for each of the `pkgSets` with matching index. +// The length of `pkgsetsRepos` must match the length of `pkgSets` or be empty +// (nil or empty slice). +// +// NOTE: Due to implementation limitations of DNF and dnf-json, each package set +// in the chain must use all of the repositories used by its predecessor. +// An error is returned if this requirement is not met. +func (s *Solver) makeDepsolveRequest(pkgSets []rpmmd.PackageSet) (*Request, map[string]rpmmd.RepoConfig, error) { + + // dedupe repository configurations but maintain order + // the order in which repositories are added to the request affects the + // order of the dependencies in the result + repos := make([]rpmmd.RepoConfig, 0) + rpmRepoMap := make(map[string]rpmmd.RepoConfig) + + for _, ps := range pkgSets { + for _, repo := range ps.Repositories { + id := repo.Hash() + if _, ok := rpmRepoMap[id]; !ok { + rpmRepoMap[id] = repo + repos = append(repos, repo) + } + } + } + + transactions := make([]transactionArgs, len(pkgSets)) + for dsIdx, pkgSet := range pkgSets { + transactions[dsIdx] = transactionArgs{ + PackageSpecs: pkgSet.Include, + ExcludeSpecs: pkgSet.Exclude, + } + + for _, jobRepo := range pkgSet.Repositories { + transactions[dsIdx].RepoIDs = append(transactions[dsIdx].RepoIDs, jobRepo.Hash()) + } + + // If more than one transaction, ensure that the transaction uses + // all of the repos from its predecessor + if dsIdx > 0 { + prevRepoIDs := transactions[dsIdx-1].RepoIDs + if len(transactions[dsIdx].RepoIDs) < len(prevRepoIDs) { + return nil, nil, fmt.Errorf("chained packageSet %d does not use all of the repos used by its predecessor", dsIdx) + } + + for idx, repoID := range prevRepoIDs { + if repoID != transactions[dsIdx].RepoIDs[idx] { + return nil, nil, fmt.Errorf("chained packageSet %d does not use all of the repos used by its predecessor", dsIdx) + } + } + } + } + + dnfRepoMap, err := s.reposFromRPMMD(repos) + if err != nil { + return nil, nil, err + } + args := arguments{ + Repos: dnfRepoMap, + Transactions: transactions, + } + + req := Request{ + Command: "depsolve", + ModulePlatformID: s.modulePlatformID, + Arch: s.arch, + CacheDir: s.GetCacheDir(), + Arguments: args, + } + + return &req, rpmRepoMap, nil +} + +// Helper function for creating a dump request payload +func (s *Solver) makeDumpRequest(repos []rpmmd.RepoConfig) (*Request, error) { + dnfRepos, err := s.reposFromRPMMD(repos) + if err != nil { + return nil, err + } + req := Request{ + Command: "dump", + ModulePlatformID: s.modulePlatformID, + Arch: s.arch, + CacheDir: s.GetCacheDir(), + Arguments: arguments{ + Repos: dnfRepos, + }, + } + return &req, nil +} + +// Helper function for creating a search request payload +func (s *Solver) makeSearchRequest(repos []rpmmd.RepoConfig, packages []string) (*Request, error) { + dnfRepos, err := s.reposFromRPMMD(repos) + if err != nil { + return nil, err + } + req := Request{ + Command: "search", + ModulePlatformID: s.modulePlatformID, + Arch: s.arch, + CacheDir: s.GetCacheDir(), + Arguments: arguments{ + Repos: dnfRepos, + Search: searchArgs{ + Packages: packages, + }, + }, + } + return &req, nil +} + +// convert internal a list of PackageSpecs to the rpmmd equivalent and attach +// key and subscription information based on the repository configs. +func (pkgs packageSpecs) toRPMMD(repos map[string]rpmmd.RepoConfig) []rpmmd.PackageSpec { + rpmDependencies := make([]rpmmd.PackageSpec, len(pkgs)) + for i, dep := range pkgs { + repo, ok := repos[dep.RepoID] + if !ok { + panic("dependency repo ID not found in repositories") + } + dep := pkgs[i] + rpmDependencies[i].Name = dep.Name + rpmDependencies[i].Epoch = dep.Epoch + rpmDependencies[i].Version = dep.Version + rpmDependencies[i].Release = dep.Release + rpmDependencies[i].Arch = dep.Arch + rpmDependencies[i].RemoteLocation = dep.RemoteLocation + rpmDependencies[i].Checksum = dep.Checksum + if repo.CheckGPG != nil { + rpmDependencies[i].CheckGPG = *repo.CheckGPG + } + if repo.IgnoreSSL != nil { + rpmDependencies[i].IgnoreSSL = *repo.IgnoreSSL + } + if repo.RHSM { + rpmDependencies[i].Secrets = "org.osbuild.rhsm" + } + } + return rpmDependencies +} + +// Request command and arguments for dnf-json +type Request struct { + // Command should be either "depsolve" or "dump" + Command string `json:"command"` + + // Platform ID, e.g., "platform:el8" + ModulePlatformID string `json:"module_platform_id"` + + // System architecture + Arch string `json:"arch"` + + // Cache directory for the DNF metadata + CacheDir string `json:"cachedir"` + + // Arguments for the action defined by Command + Arguments arguments `json:"arguments"` +} + +// Hash returns a hash of the unique aspects of the Request +// +//nolint:errcheck +func (r *Request) Hash() string { + h := sha256.New() + + h.Write([]byte(r.Command)) + h.Write([]byte(r.ModulePlatformID)) + h.Write([]byte(r.Arch)) + for _, repo := range r.Arguments.Repos { + h.Write([]byte(repo.Hash())) + } + h.Write([]byte(fmt.Sprintf("%T", r.Arguments.Search.Latest))) + h.Write([]byte(strings.Join(r.Arguments.Search.Packages, ""))) + + return fmt.Sprintf("%x", h.Sum(nil)) +} + +// arguments for a dnf-json request +type arguments struct { + // Repositories to use for depsolving + Repos []repoConfig `json:"repos"` + + // Search terms to use with search command + Search searchArgs `json:"search"` + + // Depsolve package sets and repository mappings for this request + Transactions []transactionArgs `json:"transactions"` +} + +type searchArgs struct { + // Only include latest NEVRA when true + Latest bool `json:"latest"` + + // List of package name globs to search for + // If it has '*' it is passed to dnf glob search, if it has *name* it is passed + // to substr matching, and if it has neither an exact match is expected. + Packages []string `json:"packages"` +} + +type transactionArgs struct { + // Packages to depsolve + PackageSpecs []string `json:"package-specs"` + + // Packages to exclude from results + ExcludeSpecs []string `json:"exclude-specs"` + + // IDs of repositories to use for this depsolve + RepoIDs []string `json:"repo-ids"` +} + +type packageSpecs []PackageSpec + +// Package specification +type PackageSpec struct { + Name string `json:"name"` + Epoch uint `json:"epoch"` + Version string `json:"version,omitempty"` + Release string `json:"release,omitempty"` + Arch string `json:"arch,omitempty"` + RepoID string `json:"repo_id,omitempty"` + Path string `json:"path,omitempty"` + RemoteLocation string `json:"remote_location,omitempty"` + Checksum string `json:"checksum,omitempty"` + Secrets string `json:"secrets,omitempty"` +} + +// dnf-json error structure +type Error struct { + Kind string `json:"kind"` + Reason string `json:"reason"` +} + +func (err Error) Error() string { + return fmt.Sprintf("DNF error occurred: %s: %s", err.Kind, err.Reason) +} + +// parseError parses the response from dnf-json into the Error type and appends +// the name and URL of a repository to all detected repository IDs in the +// message. +func parseError(data []byte, repos []repoConfig) Error { + var e Error + if err := json.Unmarshal(data, &e); err != nil { + // dumping the error into the Reason can get noisy, but it's good for troubleshooting + return Error{ + Kind: "InternalError", + Reason: fmt.Sprintf("Failed to unmarshal dnf-json error output %q: %s", string(data), err.Error()), + } + } + + // append to any instance of a repository ID the URL (or metalink, mirrorlist, etc) + for _, repo := range repos { + idstr := fmt.Sprintf("'%s'", repo.ID) + var nameURL string + if len(repo.BaseURLs) > 0 { + nameURL = strings.Join(repo.BaseURLs, ",") + } else if len(repo.Metalink) > 0 { + nameURL = repo.Metalink + } else if len(repo.MirrorList) > 0 { + nameURL = repo.MirrorList + } + + if len(repo.Name) > 0 { + nameURL = fmt.Sprintf("%s: %s", repo.Name, nameURL) + } + e.Reason = strings.Replace(e.Reason, idstr, fmt.Sprintf("%s [%s]", idstr, nameURL), -1) + } + + return e +} +func ParseError(data []byte) Error { + var e Error + if err := json.Unmarshal(data, &e); err != nil { + // dumping the error into the Reason can get noisy, but it's good for troubleshooting + return Error{ + Kind: "InternalError", + Reason: fmt.Sprintf("Failed to unmarshal dnf-json error output %q: %s", string(data), err.Error()), + } + } + return e +} + +func run(dnfJsonCmd []string, req *Request) ([]byte, error) { + if len(dnfJsonCmd) == 0 { + return nil, fmt.Errorf("dnf-json command undefined") + } + ex := dnfJsonCmd[0] + args := make([]string, len(dnfJsonCmd)-1) + if len(dnfJsonCmd) > 1 { + args = dnfJsonCmd[1:] + } + cmd := exec.Command(ex, args...) + stdin, err := cmd.StdinPipe() + if err != nil { + return nil, err + } + + cmd.Stderr = os.Stderr + stdout := new(bytes.Buffer) + cmd.Stdout = stdout + + err = cmd.Start() + if err != nil { + return nil, err + } + + err = json.NewEncoder(stdin).Encode(req) + if err != nil { + return nil, err + } + stdin.Close() + + err = cmd.Wait() + output := stdout.Bytes() + if runError, ok := err.(*exec.ExitError); ok && runError.ExitCode() != 0 { + return nil, parseError(output, req.Arguments.Repos) + } + + return output, nil +} diff --git a/vendor/github.com/osbuild/images/internal/environment/azure.go b/vendor/github.com/osbuild/images/internal/environment/azure.go new file mode 100644 index 000000000..c5f2d601f --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/environment/azure.go @@ -0,0 +1,13 @@ +package environment + +type Azure struct { + BaseEnvironment +} + +func (p *Azure) GetPackages() []string { + return []string{"WALinuxAgent"} +} + +func (p *Azure) GetServices() []string { + return []string{"waagent"} +} diff --git a/vendor/github.com/osbuild/images/internal/environment/ec2.go b/vendor/github.com/osbuild/images/internal/environment/ec2.go new file mode 100644 index 000000000..ea5d1cc3d --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/environment/ec2.go @@ -0,0 +1,13 @@ +package environment + +type EC2 struct { + BaseEnvironment +} + +func (p *EC2) GetPackages() []string { + return []string{"cloud-init"} +} + +func (p *EC2) GetServices() []string { + return []string{"cloud-init.service"} +} diff --git a/vendor/github.com/osbuild/images/internal/environment/environment.go b/vendor/github.com/osbuild/images/internal/environment/environment.go new file mode 100644 index 000000000..cb0af7a6a --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/environment/environment.go @@ -0,0 +1,25 @@ +package environment + +import "github.com/osbuild/images/pkg/rpmmd" + +type Environment interface { + GetPackages() []string + GetRepos() []rpmmd.RepoConfig + GetServices() []string +} + +type BaseEnvironment struct { + Repos []rpmmd.RepoConfig +} + +func (p BaseEnvironment) GetPackages() []string { + return []string{} +} + +func (p BaseEnvironment) GetRepos() []rpmmd.RepoConfig { + return p.Repos +} + +func (p BaseEnvironment) GetServices() []string { + return []string{} +} diff --git a/vendor/github.com/osbuild/images/internal/environment/gcp.go b/vendor/github.com/osbuild/images/internal/environment/gcp.go new file mode 100644 index 000000000..10523daa9 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/environment/gcp.go @@ -0,0 +1,6 @@ +package environment + +// TODO +type GCP struct { + BaseEnvironment +} diff --git a/vendor/github.com/osbuild/images/internal/environment/openstack.go b/vendor/github.com/osbuild/images/internal/environment/openstack.go new file mode 100644 index 000000000..17e112ae5 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/environment/openstack.go @@ -0,0 +1,6 @@ +package environment + +// TODO +type OpenStack struct { + BaseEnvironment +} diff --git a/vendor/github.com/osbuild/images/internal/environment/vsphere.go b/vendor/github.com/osbuild/images/internal/environment/vsphere.go new file mode 100644 index 000000000..27e78bf25 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/environment/vsphere.go @@ -0,0 +1,6 @@ +package environment + +// TODO +type VSphere struct { + BaseEnvironment +} diff --git a/vendor/github.com/osbuild/images/internal/fdo/fdo.go b/vendor/github.com/osbuild/images/internal/fdo/fdo.go new file mode 100644 index 000000000..c047a6215 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/fdo/fdo.go @@ -0,0 +1,15 @@ +package fdo + +import "github.com/osbuild/images/pkg/blueprint" + +type Options struct { + ManufacturingServerURL string + DiunPubKeyInsecure string + DiunPubKeyHash string + DiunPubKeyRootCerts string +} + +func FromBP(bpFDO blueprint.FDOCustomization) *Options { + fdo := Options(bpFDO) + return &fdo +} diff --git a/vendor/github.com/osbuild/images/internal/fsnode/dir.go b/vendor/github.com/osbuild/images/internal/fsnode/dir.go new file mode 100644 index 000000000..702165ab0 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/fsnode/dir.go @@ -0,0 +1,34 @@ +package fsnode + +import "os" + +type Directory struct { + baseFsNode + ensureParentDirs bool +} + +func (d *Directory) IsDir() bool { + return true +} + +func (d *Directory) EnsureParentDirs() bool { + if d == nil { + return false + } + return d.ensureParentDirs +} + +// NewDirectory creates a new directory with the given path, mode, user and group. +// user and group can be either a string (user name/group name), an int64 (UID/GID) or nil. +func NewDirectory(path string, mode *os.FileMode, user interface{}, group interface{}, ensureParentDirs bool) (*Directory, error) { + baseNode, err := newBaseFsNode(path, mode, user, group) + + if err != nil { + return nil, err + } + + return &Directory{ + baseFsNode: *baseNode, + ensureParentDirs: ensureParentDirs, + }, nil +} diff --git a/vendor/github.com/osbuild/images/internal/fsnode/file.go b/vendor/github.com/osbuild/images/internal/fsnode/file.go new file mode 100644 index 000000000..3c6813ece --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/fsnode/file.go @@ -0,0 +1,36 @@ +package fsnode + +import ( + "os" +) + +type File struct { + baseFsNode + data []byte +} + +func (f *File) IsDir() bool { + return false +} + +func (f *File) Data() []byte { + if f == nil { + return nil + } + return f.data +} + +// NewFile creates a new file with the given path, data, mode, user and group. +// user and group can be either a string (user name/group name), an int64 (UID/GID) or nil. +func NewFile(path string, mode *os.FileMode, user interface{}, group interface{}, data []byte) (*File, error) { + baseNode, err := newBaseFsNode(path, mode, user, group) + + if err != nil { + return nil, err + } + + return &File{ + baseFsNode: *baseNode, + data: data, + }, nil +} diff --git a/vendor/github.com/osbuild/images/internal/fsnode/fsnode.go b/vendor/github.com/osbuild/images/internal/fsnode/fsnode.go new file mode 100644 index 000000000..06e0e2237 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/fsnode/fsnode.go @@ -0,0 +1,133 @@ +package fsnode + +import ( + "fmt" + "os" + "path" + "regexp" +) + +const usernameRegex = `^[A-Za-z0-9_.][A-Za-z0-9_.-]{0,31}$` +const groupnameRegex = `^[A-Za-z0-9_][A-Za-z0-9_-]{0,31}$` + +type FsNode interface { + Path() string + Mode() *os.FileMode + // User can return either a string (user name/group name), an int64 (UID/GID) or nil + User() interface{} + // Group can return either a string (user name/group name), an int64 (UID/GID) or nil + Group() interface{} + IsDir() bool +} + +type baseFsNode struct { + path string + mode *os.FileMode + user interface{} + group interface{} +} + +func (f *baseFsNode) Path() string { + if f == nil { + return "" + } + return f.path +} + +func (f *baseFsNode) Mode() *os.FileMode { + if f == nil { + return nil + } + return f.mode +} + +// User can return either a string (user name) or an int64 (UID) +func (f *baseFsNode) User() interface{} { + if f == nil { + return nil + } + return f.user +} + +// Group can return either a string (group name) or an int64 (GID) +func (f *baseFsNode) Group() interface{} { + if f == nil { + return nil + } + return f.group +} + +func newBaseFsNode(path string, mode *os.FileMode, user interface{}, group interface{}) (*baseFsNode, error) { + node := &baseFsNode{ + path: path, + mode: mode, + user: user, + group: group, + } + + err := node.validate() + if err != nil { + return nil, err + } + return node, nil +} + +func (f *baseFsNode) validate() error { + // Check that the path is valid + if f.path == "" { + return fmt.Errorf("path must not be empty") + } + if f.path[0] != '/' { + return fmt.Errorf("path must be absolute") + } + if f.path[len(f.path)-1] == '/' { + return fmt.Errorf("path must not end with a slash") + } + if f.path != path.Clean(f.path) { + return fmt.Errorf("path must be canonical") + } + + // Check that the mode is valid + if f.mode != nil && *f.mode&os.ModeType != 0 { + return fmt.Errorf("mode must not contain file type bits") + } + + // Check that the user and group are valid + switch user := f.user.(type) { + case string: + nameRegex := regexp.MustCompile(usernameRegex) + if !nameRegex.MatchString(user) { + return fmt.Errorf("user name %q doesn't conform to validating regex (%s)", user, nameRegex.String()) + } + case int64: + if user < 0 { + return fmt.Errorf("user ID must be non-negative") + } + case nil: + // user is not set + default: + return fmt.Errorf("user must be either a string or an int64, got %T", user) + } + + switch group := f.group.(type) { + case string: + nameRegex := regexp.MustCompile(groupnameRegex) + if !nameRegex.MatchString(group) { + return fmt.Errorf("group name %q doesn't conform to validating regex (%s)", group, nameRegex.String()) + } + case int64: + if group < 0 { + return fmt.Errorf("group ID must be non-negative") + } + case nil: + // group is not set + default: + return fmt.Errorf("group must be either a string or an int64, got %T", group) + } + + return nil +} + +func (f *baseFsNode) IsDir() bool { + panic("IsDir() called on baseFsNode") +} diff --git a/vendor/github.com/osbuild/images/internal/ignition/ignition.go b/vendor/github.com/osbuild/images/internal/ignition/ignition.go new file mode 100644 index 000000000..096427518 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/ignition/ignition.go @@ -0,0 +1,31 @@ +package ignition + +import ( + "encoding/base64" + "errors" + + "github.com/osbuild/images/pkg/blueprint" +) + +type FirstBootOptions struct { + ProvisioningURL string +} + +func FirstbootOptionsFromBP(bpIgnitionFirstboot blueprint.FirstBootIgnitionCustomization) *FirstBootOptions { + ignition := FirstBootOptions(bpIgnitionFirstboot) + return &ignition +} + +type EmbeddedOptions struct { + Config string +} + +func EmbeddedOptionsFromBP(bpIgnitionEmbedded blueprint.EmbeddedIgnitionCustomization) (*EmbeddedOptions, error) { + decodedConfig, err := base64.StdEncoding.DecodeString(bpIgnitionEmbedded.Config) + if err != nil { + return nil, errors.New("can't decode Ignition config") + } + return &EmbeddedOptions{ + Config: string(decodedConfig), + }, nil +} diff --git a/vendor/github.com/osbuild/images/internal/mocks/dnfjson/dnfjson.go b/vendor/github.com/osbuild/images/internal/mocks/dnfjson/dnfjson.go new file mode 100644 index 000000000..124a87e6b --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/mocks/dnfjson/dnfjson.go @@ -0,0 +1,225 @@ +// dnfjson_mock provides data and methods for testing the dnfjson package. +package dnfjson_mock + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + "time" + + "github.com/osbuild/images/internal/dnfjson" + "github.com/osbuild/images/pkg/rpmmd" +) + +func generatePackageList() rpmmd.PackageList { + baseTime, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05Z") + + if err != nil { + panic(err) + } + + var packageList rpmmd.PackageList + + for i := 0; i < 22; i++ { + basePackage := rpmmd.Package{ + Name: fmt.Sprintf("package%d", i), + Summary: fmt.Sprintf("pkg%d sum", i), + Description: fmt.Sprintf("pkg%d desc", i), + URL: fmt.Sprintf("https://pkg%d.example.com", i), + Epoch: 0, + Version: fmt.Sprintf("%d.0", i), + Release: fmt.Sprintf("%d.fc30", i), + Arch: "x86_64", + BuildTime: baseTime.AddDate(0, i, 0), + License: "MIT", + } + + secondBuild := basePackage + + secondBuild.Version = fmt.Sprintf("%d.1", i) + secondBuild.BuildTime = basePackage.BuildTime.AddDate(0, 0, 1) + + packageList = append(packageList, basePackage, secondBuild) + } + + return packageList +} + +// generateSearchResults creates results for use with the dnfjson search command +// which is used for listing a subset of modules and projects. +// +// The map key is a comma-separated list of the packages requested +// If no packages are included it returns all 22 packages, same as the mock dump +// +// nonexistingpkg returns an empty list +// badpackage1 returns a fetch error, same as when the package name is unknown +// baddepsolve returns package1, the test then tries to depsolve package1 using BadDepsolve() +// wich will return a depsolve error. +func generateSearchResults() map[string]interface{} { + allPackages := generatePackageList() + + // This includes package16, package2, package20, and package21 + var wildcardResults rpmmd.PackageList + wildcardResults = append(wildcardResults, allPackages[32], allPackages[33]) + wildcardResults = append(wildcardResults, allPackages[4], allPackages[5]) + for i := 40; i < 44; i++ { + wildcardResults = append(wildcardResults, allPackages[i]) + } + + fetchError := dnfjson.Error{ + Kind: "FetchError", + Reason: "There was a problem when fetching packages.", + } + + return map[string]interface{}{ + "": allPackages, + "*": allPackages, + "nonexistingpkg": rpmmd.PackageList{}, + "package1": rpmmd.PackageList{allPackages[2], allPackages[3]}, + "package1,package2": rpmmd.PackageList{allPackages[2], allPackages[3], allPackages[4], allPackages[5]}, + "package2*,package16": wildcardResults, + "package16": rpmmd.PackageList{allPackages[32], allPackages[33]}, + "badpackage1": fetchError, + "baddepsolve": rpmmd.PackageList{allPackages[2], allPackages[3]}, + } +} + +func createBaseDepsolveFixture() []dnfjson.PackageSpec { + return []dnfjson.PackageSpec{ + { + Name: "dep-package3", + Epoch: 7, + Version: "3.0.3", + Release: "1.fc30", + Arch: "x86_64", + RepoID: "REPOID", // added by mock-dnf-json + }, + { + Name: "dep-package1", + Epoch: 0, + Version: "1.33", + Release: "2.fc30", + Arch: "x86_64", + RepoID: "REPOID", // added by mock-dnf-json + }, + { + Name: "dep-package2", + Epoch: 0, + Version: "2.9", + Release: "1.fc30", + Arch: "x86_64", + RepoID: "REPOID", // added by mock-dnf-json + }, + } +} + +// BaseDeps is the expected list of dependencies (as rpmmd.PackageSpec) from +// the Base ResponseGenerator +func BaseDeps() []rpmmd.PackageSpec { + return []rpmmd.PackageSpec{ + { + Name: "dep-package3", + Epoch: 7, + Version: "3.0.3", + Release: "1.fc30", + Arch: "x86_64", + CheckGPG: true, + }, + { + Name: "dep-package1", + Epoch: 0, + Version: "1.33", + Release: "2.fc30", + Arch: "x86_64", + CheckGPG: true, + }, + { + Name: "dep-package2", + Epoch: 0, + Version: "2.9", + Release: "1.fc30", + Arch: "x86_64", + CheckGPG: true, + }, + } +} + +type ResponseGenerator func(string) string + +func Base(tmpdir string) string { + data := map[string]interface{}{ + "depsolve": createBaseDepsolveFixture(), + "dump": generatePackageList(), + "search": generateSearchResults(), + } + path := filepath.Join(tmpdir, "base.json") + write(data, path) + return path +} + +func NonExistingPackage(tmpdir string) string { + deps := dnfjson.Error{ + Kind: "MarkingErrors", + Reason: "Error occurred when marking packages for installation: Problems in request:\nmissing packages: fash", + } + data := map[string]interface{}{ + "depsolve": deps, + } + path := filepath.Join(tmpdir, "notexist.json") + write(data, path) + return path +} + +func BadDepsolve(tmpdir string) string { + deps := dnfjson.Error{ + Kind: "DepsolveError", + Reason: "There was a problem depsolving ['go2rpm']: \n Problem: conflicting requests\n - nothing provides askalono-cli needed by go2rpm-1-4.fc31.noarch", + } + + data := map[string]interface{}{ + "depsolve": deps, + "dump": generatePackageList(), + "search": generateSearchResults(), + } + path := filepath.Join(tmpdir, "baddepsolve.json") + write(data, path) + return path +} + +func BadFetch(tmpdir string) string { + deps := dnfjson.Error{ + Kind: "DepsolveError", + Reason: "There was a problem depsolving ['go2rpm']: \n Problem: conflicting requests\n - nothing provides askalono-cli needed by go2rpm-1-4.fc31.noarch", + } + pkgs := dnfjson.Error{ + Kind: "FetchError", + Reason: "There was a problem when fetching packages.", + } + data := map[string]interface{}{ + "depsolve": deps, + "dump": pkgs, + "search": generateSearchResults(), + } + path := filepath.Join(tmpdir, "badfetch.json") + write(data, path) + return path +} + +func marshal(data interface{}) []byte { + jdata, err := json.Marshal(data) + if err != nil { + panic(err) + } + return jdata +} + +func write(data interface{}, path string) { + fp, err := os.Create(path) + if err != nil { + panic(err) + } + if _, err := fp.Write(marshal(data)); err != nil { + panic(err) + } +} diff --git a/vendor/github.com/osbuild/images/internal/oscap/oscap.go b/vendor/github.com/osbuild/images/internal/oscap/oscap.go new file mode 100644 index 000000000..677723164 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/oscap/oscap.go @@ -0,0 +1,72 @@ +package oscap + +import ( + "strings" +) + +type Profile string + +func (p Profile) String() string { + return string(p) +} + +const ( + AnssiBp28Enhanced Profile = "xccdf_org.ssgproject.content_profile_anssi_bp28_enhanced" + AnssiBp28High Profile = "xccdf_org.ssgproject.content_profile_anssi_bp28_high" + AnssiBp28Intermediary Profile = "xccdf_org.ssgproject.content_profile_anssi_bp28_intermediary" + AnssiBp28Minimal Profile = "xccdf_org.ssgproject.content_profile_anssi_bp28_minimal" + Cis Profile = "xccdf_org.ssgproject.content_profile_cis" + CisServerL1 Profile = "xccdf_org.ssgproject.content_profile_cis_server_l1" + CisWorkstationL1 Profile = "xccdf_org.ssgproject.content_profile_cis_workstation_l1" + CisWorkstationL2 Profile = "xccdf_org.ssgproject.content_profile_cis_workstation_l2" + Cui Profile = "xccdf_org.ssgproject.content_profile_cui" + E8 Profile = "xccdf_org.ssgproject.content_profile_e8" + Hippa Profile = "xccdf_org.ssgproject.content_profile_hipaa" + IsmO Profile = "xccdf_org.ssgproject.content_profile_ism_o" + Ospp Profile = "xccdf_org.ssgproject.content_profile_ospp" + PciDss Profile = "xccdf_org.ssgproject.content_profile_pci-dss" + Standard Profile = "xccdf_org.ssgproject.content_profile_standard" + Stig Profile = "xccdf_org.ssgproject.content_profile_stig" + StigGui Profile = "xccdf_org.ssgproject.content_profile_stig_gui" + + // datastream fallbacks + defaultFedoraDatastream string = "/usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml" + defaultCentos8Datastream string = "/usr/share/xml/scap/ssg/content/ssg-centos8-ds.xml" + defaultCentos9Datastream string = "/usr/share/xml/scap/ssg/content/ssg-cs9-ds.xml" + defaultRHEL8Datastream string = "/usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml" + defaultRHEL9Datastream string = "/usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml" +) + +func DefaultFedoraDatastream() string { + return defaultFedoraDatastream +} + +func DefaultRHEL8Datastream(isRHEL bool) string { + if isRHEL { + return defaultRHEL8Datastream + } + return defaultCentos8Datastream +} + +func DefaultRHEL9Datastream(isRHEL bool) string { + if isRHEL { + return defaultRHEL9Datastream + } + return defaultCentos9Datastream +} + +func IsProfileAllowed(profile string, allowlist []Profile) bool { + for _, a := range allowlist { + if a.String() == profile { + return true + } + // this enables a user to specify + // the full profile or the short + // profile id + if strings.HasSuffix(a.String(), profile) { + return true + } + } + + return false +} diff --git a/vendor/github.com/osbuild/images/internal/pathpolicy/path_policy.go b/vendor/github.com/osbuild/images/internal/pathpolicy/path_policy.go new file mode 100644 index 000000000..423a5751b --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/pathpolicy/path_policy.go @@ -0,0 +1,54 @@ +package pathpolicy + +import ( + "fmt" + "path" +) + +type PathPolicy struct { + Deny bool // explicitly do not allow this entry + Exact bool // require and exact match, no subdirs +} + +type PathPolicies = PathTrie + +// Create a new PathPolicies trie from a map of path to PathPolicy +func NewPathPolicies(entries map[string]PathPolicy) *PathPolicies { + + noType := make(map[string]interface{}, len(entries)) + + for k, v := range entries { + noType[k] = v + } + + return NewPathTrieFromMap(noType) +} + +// Check a given path against the PathPolicies +func (pol *PathPolicies) Check(fsPath string) error { + + // Quickly check we have a path and it is absolute + if fsPath == "" || fsPath[0] != '/' { + return fmt.Errorf("path must be absolute") + } + + // ensure that only clean paths are valid + if fsPath != path.Clean(fsPath) { + return fmt.Errorf("path must be canonical") + } + + node, left := pol.Lookup(fsPath) + policy, ok := node.Payload.(PathPolicy) + if !ok { + panic("programming error: invalid path trie payload") + } + + // 1) path is explicitly not allowed or + // 2) a subpath was match but an explicit match is required + if policy.Deny || (policy.Exact && len(left) > 0) { + return fmt.Errorf("path '%s ' is not allowed", fsPath) + } + + // exact match or recursive path allowed + return nil +} diff --git a/vendor/github.com/osbuild/images/internal/pathpolicy/path_trie.go b/vendor/github.com/osbuild/images/internal/pathpolicy/path_trie.go new file mode 100644 index 000000000..1de1f46a6 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/pathpolicy/path_trie.go @@ -0,0 +1,123 @@ +package pathpolicy + +import ( + "sort" + "strings" +) + +// splits the path into its individual components. Retruns the +// empty list if the path is just the absolute root, i.e. "/". +func pathTrieSplitPath(path string) []string { + path = strings.Trim(path, "/") + if path == "" { + return []string{} + } + + return strings.Split(path, "/") +} + +type PathTrie struct { + Name []string + Paths []*PathTrie + Payload interface{} +} + +// match checks if the given trie is a prefix of path +func (trie *PathTrie) match(path []string) bool { + if len(trie.Name) > len(path) { + return false + } + + for i := range trie.Name { + if path[i] != trie.Name[i] { + return false + } + } + + return true +} + +func (trie *PathTrie) get(path []string) (*PathTrie, []string) { + if len(path) < 1 { + panic("programming error: expected root node") + } + + var node *PathTrie + for i := range trie.Paths { + if trie.Paths[i].match(path) { + node = trie.Paths[i] + break + } + } + + // no subpath match, we are the best match + if node == nil { + return trie, path + } + + // node, or one of its sub-nodes, is a match + prefix := len(node.Name) + + // the node is a perfect match, return it + if len(path) == prefix { + return node, nil + } + + // check if any sub-path's of node match + return node.get(path[prefix:]) +} + +func (trie *PathTrie) add(path []string) *PathTrie { + node := &PathTrie{Name: path} + + if trie.Paths == nil { + trie.Paths = make([]*PathTrie, 0, 1) + } + + trie.Paths = append(trie.Paths, node) + + return node +} + +// Construct a new trie from a map of paths to their payloads. +// Returns the root node of the trie. +func NewPathTrieFromMap(entries map[string]interface{}) *PathTrie { + root := &PathTrie{Name: []string{}} + + keys := make([]string, 0, len(entries)) + for k := range entries { + keys = append(keys, k) + } + + sort.Strings(keys) + + for _, k := range keys { + node, left := root.Lookup(k) + + if len(left) > 0 { + node = node.add(left) + } + + node.Payload = entries[k] + } + + return root +} + +// Lookup returns the node that is the prefix of path and +// the unmatched path segment. Must be called on the root +// trie node. +func (root *PathTrie) Lookup(path string) (*PathTrie, []string) { + + if len(root.Name) != 0 { + panic("programming error: lookup on non-root trie node") + } + + elements := pathTrieSplitPath(path) + + if len(elements) == 0 { + return root, elements + } + + return root.get(elements) +} diff --git a/vendor/github.com/osbuild/images/internal/pathpolicy/policies.go b/vendor/github.com/osbuild/images/internal/pathpolicy/policies.go new file mode 100644 index 000000000..aa4d315c9 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/pathpolicy/policies.go @@ -0,0 +1,31 @@ +package pathpolicy + +// MountpointPolicies is a set of default mountpoint policies used for filesystem customizations +var MountpointPolicies = NewPathPolicies(map[string]PathPolicy{ + "/": {Exact: true}, + "/boot": {Exact: true}, + "/var": {}, + "/opt": {}, + "/srv": {}, + "/usr": {}, + "/app": {}, + "/data": {}, + "/home": {}, + "/tmp": {}, +}) + +// CustomDirectoriesPolicies is a set of default policies for custom directories +var CustomDirectoriesPolicies = NewPathPolicies(map[string]PathPolicy{ + "/": {Deny: true}, + "/etc": {}, +}) + +// CustomFilesPolicies is a set of default policies for custom files +var CustomFilesPolicies = NewPathPolicies(map[string]PathPolicy{ + "/": {Deny: true}, + "/etc": {}, + "/etc/fstab": {Deny: true}, + "/etc/shadow": {Deny: true}, + "/etc/passwd": {Deny: true}, + "/etc/group": {Deny: true}, +}) diff --git a/vendor/github.com/osbuild/images/internal/shell/shell.go b/vendor/github.com/osbuild/images/internal/shell/shell.go new file mode 100644 index 000000000..424eb9014 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/shell/shell.go @@ -0,0 +1,11 @@ +package shell + +type EnvironmentVariable struct { + Key string + Value string +} + +type InitFile struct { + Filename string + Variables []EnvironmentVariable +} diff --git a/vendor/github.com/osbuild/images/internal/users/users.go b/vendor/github.com/osbuild/images/internal/users/users.go new file mode 100644 index 000000000..02f39d089 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/users/users.go @@ -0,0 +1,40 @@ +package users + +import "github.com/osbuild/images/pkg/blueprint" + +type User struct { + Name string + Description *string + Password *string + Key *string + Home *string + Shell *string + Groups []string + UID *int + GID *int +} + +type Group struct { + Name string + GID *int +} + +func UsersFromBP(userCustomizations []blueprint.UserCustomization) []User { + users := make([]User, len(userCustomizations)) + for idx := range userCustomizations { + // currently, they have the same structure, so we convert directly + // this will fail to compile as soon as one of the two changes + users[idx] = User(userCustomizations[idx]) + } + return users +} + +func GroupsFromBP(groupCustomizations []blueprint.GroupCustomization) []Group { + groups := make([]Group, len(groupCustomizations)) + for idx := range groupCustomizations { + // currently, they have the same structure, so we convert directly + // this will fail to compile as soon as one of the two changes + groups[idx] = Group(groupCustomizations[idx]) + } + return groups +} diff --git a/vendor/github.com/osbuild/images/internal/workload/anaconda.go b/vendor/github.com/osbuild/images/internal/workload/anaconda.go new file mode 100644 index 000000000..b4a5e50c0 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/workload/anaconda.go @@ -0,0 +1,7 @@ +package workload + +// TODO: replace the Anaconda pipeline by the OS pipeline with the +// anaconda workload. +type Anaconda struct { + BaseWorkload +} diff --git a/vendor/github.com/osbuild/images/internal/workload/custom.go b/vendor/github.com/osbuild/images/internal/workload/custom.go new file mode 100644 index 000000000..47f5d3ee3 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/workload/custom.go @@ -0,0 +1,22 @@ +package workload + +type Custom struct { + BaseWorkload + Packages []string + Services []string + DisabledServices []string +} + +func (p *Custom) GetPackages() []string { + return p.Packages +} + +func (p *Custom) GetServices() []string { + return p.Services +} + +// TODO: Does this belong here? What kind of workload requires +// services to be disabled? +func (p *Custom) GetDisabledServices() []string { + return p.DisabledServices +} diff --git a/vendor/github.com/osbuild/images/internal/workload/sap.go b/vendor/github.com/osbuild/images/internal/workload/sap.go new file mode 100644 index 000000000..0f066b78c --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/workload/sap.go @@ -0,0 +1,6 @@ +package workload + +// TODO! +type SAP struct { + BaseWorkload +} diff --git a/vendor/github.com/osbuild/images/internal/workload/static_webserver.go b/vendor/github.com/osbuild/images/internal/workload/static_webserver.go new file mode 100644 index 000000000..c06924050 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/workload/static_webserver.go @@ -0,0 +1,7 @@ +package workload + +// TODO: replace the CommitServerTree pipeline by the OS pipeline with the +// StaticWebserver workload. +type StaticWebserver struct { + BaseWorkload +} diff --git a/vendor/github.com/osbuild/images/internal/workload/workload.go b/vendor/github.com/osbuild/images/internal/workload/workload.go new file mode 100644 index 000000000..24aa570f0 --- /dev/null +++ b/vendor/github.com/osbuild/images/internal/workload/workload.go @@ -0,0 +1,30 @@ +package workload + +import "github.com/osbuild/images/pkg/rpmmd" + +type Workload interface { + GetPackages() []string + GetRepos() []rpmmd.RepoConfig + GetServices() []string + GetDisabledServices() []string +} + +type BaseWorkload struct { + Repos []rpmmd.RepoConfig +} + +func (p BaseWorkload) GetPackages() []string { + return []string{} +} + +func (p BaseWorkload) GetRepos() []rpmmd.RepoConfig { + return p.Repos +} + +func (p BaseWorkload) GetServices() []string { + return []string{} +} + +func (p BaseWorkload) GetDisabledServices() []string { + return []string{} +} diff --git a/internal/artifact/artifact.go b/vendor/github.com/osbuild/images/pkg/artifact/artifact.go similarity index 100% rename from internal/artifact/artifact.go rename to vendor/github.com/osbuild/images/pkg/artifact/artifact.go diff --git a/vendor/github.com/osbuild/images/pkg/blueprint/blueprint.go b/vendor/github.com/osbuild/images/pkg/blueprint/blueprint.go new file mode 100644 index 000000000..de3c1930d --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/blueprint/blueprint.go @@ -0,0 +1,184 @@ +// Package blueprint contains primitives for representing weldr blueprints +package blueprint + +import ( + "encoding/json" + "fmt" + + "github.com/osbuild/images/pkg/crypt" + + "github.com/coreos/go-semver/semver" +) + +// A Blueprint is a high-level description of an image. +type Blueprint struct { + Name string `json:"name" toml:"name"` + Description string `json:"description" toml:"description"` + Version string `json:"version,omitempty" toml:"version,omitempty"` + Packages []Package `json:"packages" toml:"packages"` + Modules []Package `json:"modules" toml:"modules"` + Groups []Group `json:"groups" toml:"groups"` + Containers []Container `json:"containers,omitempty" toml:"containers,omitempty"` + Customizations *Customizations `json:"customizations,omitempty" toml:"customizations"` + Distro string `json:"distro" toml:"distro"` +} + +type Change struct { + Commit string `json:"commit" toml:"commit"` + Message string `json:"message" toml:"message"` + Revision *int `json:"revision" toml:"revision"` + Timestamp string `json:"timestamp" toml:"timestamp"` + Blueprint Blueprint `json:"-" toml:"-"` +} + +// A Package specifies an RPM package. +type Package struct { + Name string `json:"name" toml:"name"` + Version string `json:"version,omitempty" toml:"version,omitempty"` +} + +// A group specifies an package group. +type Group struct { + Name string `json:"name" toml:"name"` +} + +type Container struct { + Source string `json:"source" toml:"source"` + Name string `json:"name,omitempty" toml:"name,omitempty"` + + TLSVerify *bool `json:"tls-verify,omitempty" toml:"tls-verify,omitempty"` +} + +// DeepCopy returns a deep copy of the blueprint +// This uses json.Marshal and Unmarshal which are not very efficient +func (b *Blueprint) DeepCopy() Blueprint { + bpJSON, err := json.Marshal(b) + if err != nil { + panic(err) + } + + var bp Blueprint + err = json.Unmarshal(bpJSON, &bp) + if err != nil { + panic(err) + } + return bp +} + +// Initialize ensures that the blueprint has sane defaults for any missing fields +func (b *Blueprint) Initialize() error { + if len(b.Name) == 0 { + return fmt.Errorf("empty blueprint name not allowed") + } + + if b.Packages == nil { + b.Packages = []Package{} + } + if b.Modules == nil { + b.Modules = []Package{} + } + if b.Groups == nil { + b.Groups = []Group{} + } + if b.Containers == nil { + b.Containers = []Container{} + } + if b.Version == "" { + b.Version = "0.0.0" + } + // Return an error if the version is not valid + _, err := semver.NewVersion(b.Version) + if err != nil { + return fmt.Errorf("Invalid 'version', must use Semantic Versioning: %s", err.Error()) + } + + err = b.CryptPasswords() + if err != nil { + return fmt.Errorf("Error hashing passwords: %s", err.Error()) + } + + return nil +} + +// BumpVersion increments the previous blueprint's version +// If the old version string is not vaild semver it will use the new version as-is +// This assumes that the new blueprint's version has already been validated via Initialize +func (b *Blueprint) BumpVersion(old string) { + var ver *semver.Version + ver, err := semver.NewVersion(old) + if err != nil { + return + } + + ver.BumpPatch() + b.Version = ver.String() +} + +// packages, modules, and groups all resolve to rpm packages right now. This +// function returns a combined list of "name-version" strings. +func (b *Blueprint) GetPackages() []string { + return b.GetPackagesEx(true) +} + +func (b *Blueprint) GetPackagesEx(bootable bool) []string { + packages := []string{} + for _, pkg := range b.Packages { + packages = append(packages, pkg.ToNameVersion()) + } + for _, pkg := range b.Modules { + packages = append(packages, pkg.ToNameVersion()) + } + for _, group := range b.Groups { + packages = append(packages, "@"+group.Name) + } + + if bootable { + kc := b.Customizations.GetKernel() + kpkg := Package{Name: kc.Name} + packages = append(packages, kpkg.ToNameVersion()) + } + + return packages +} + +func (p Package) ToNameVersion() string { + // Omit version to prevent all packages with prefix of name to be installed + if p.Version == "*" || p.Version == "" { + return p.Name + } + + return p.Name + "-" + p.Version +} + +// CryptPasswords ensures that all blueprint passwords are hashed +func (b *Blueprint) CryptPasswords() error { + if b.Customizations == nil { + return nil + } + + // Any passwords for users? + for i := range b.Customizations.User { + // Missing or empty password + if b.Customizations.User[i].Password == nil { + continue + } + + // Prevent empty password from being hashed + if len(*b.Customizations.User[i].Password) == 0 { + b.Customizations.User[i].Password = nil + continue + } + + if !crypt.PasswordIsCrypted(*b.Customizations.User[i].Password) { + pw, err := crypt.CryptSHA512(*b.Customizations.User[i].Password) + if err != nil { + return err + } + + // Replace the password with the + b.Customizations.User[i].Password = &pw + } + } + + return nil +} diff --git a/vendor/github.com/osbuild/images/pkg/blueprint/customizations.go b/vendor/github.com/osbuild/images/pkg/blueprint/customizations.go new file mode 100644 index 000000000..2e5b03ed2 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/blueprint/customizations.go @@ -0,0 +1,351 @@ +package blueprint + +import ( + "fmt" + "reflect" + "strings" +) + +type Customizations struct { + Hostname *string `json:"hostname,omitempty" toml:"hostname,omitempty"` + Kernel *KernelCustomization `json:"kernel,omitempty" toml:"kernel,omitempty"` + SSHKey []SSHKeyCustomization `json:"sshkey,omitempty" toml:"sshkey,omitempty"` + User []UserCustomization `json:"user,omitempty" toml:"user,omitempty"` + Group []GroupCustomization `json:"group,omitempty" toml:"group,omitempty"` + Timezone *TimezoneCustomization `json:"timezone,omitempty" toml:"timezone,omitempty"` + Locale *LocaleCustomization `json:"locale,omitempty" toml:"locale,omitempty"` + Firewall *FirewallCustomization `json:"firewall,omitempty" toml:"firewall,omitempty"` + Services *ServicesCustomization `json:"services,omitempty" toml:"services,omitempty"` + Filesystem []FilesystemCustomization `json:"filesystem,omitempty" toml:"filesystem,omitempty"` + InstallationDevice string `json:"installation_device,omitempty" toml:"installation_device,omitempty"` + FDO *FDOCustomization `json:"fdo,omitempty" toml:"fdo,omitempty"` + OpenSCAP *OpenSCAPCustomization `json:"openscap,omitempty" toml:"openscap,omitempty"` + Ignition *IgnitionCustomization `json:"ignition,omitempty" toml:"ignition,omitempty"` + Directories []DirectoryCustomization `json:"directories,omitempty" toml:"directories,omitempty"` + Files []FileCustomization `json:"files,omitempty" toml:"files,omitempty"` + Repositories []RepositoryCustomization `json:"repositories,omitempty" toml:"repositories,omitempty"` +} + +type IgnitionCustomization struct { + Embedded *EmbeddedIgnitionCustomization `json:"embedded,omitempty" toml:"embedded,omitempty"` + FirstBoot *FirstBootIgnitionCustomization `json:"firstboot,omitempty" toml:"firstboot,omitempty"` +} + +type EmbeddedIgnitionCustomization struct { + Config string `json:"config,omitempty" toml:"config,omitempty"` +} + +type FirstBootIgnitionCustomization struct { + ProvisioningURL string `json:"url,omitempty" toml:"url,omitempty"` +} + +type FDOCustomization struct { + ManufacturingServerURL string `json:"manufacturing_server_url,omitempty" toml:"manufacturing_server_url,omitempty"` + DiunPubKeyInsecure string `json:"diun_pub_key_insecure,omitempty" toml:"diun_pub_key_insecure,omitempty"` + // This is the output of: + // echo "sha256:$(openssl x509 -fingerprint -sha256 -noout -in diun_cert.pem | cut -d"=" -f2 | sed 's/://g')" + DiunPubKeyHash string `json:"diun_pub_key_hash,omitempty" toml:"diun_pub_key_hash,omitempty"` + DiunPubKeyRootCerts string `json:"diun_pub_key_root_certs,omitempty" toml:"diun_pub_key_root_certs,omitempty"` +} + +type KernelCustomization struct { + Name string `json:"name,omitempty" toml:"name,omitempty"` + Append string `json:"append" toml:"append"` +} + +type SSHKeyCustomization struct { + User string `json:"user" toml:"user"` + Key string `json:"key" toml:"key"` +} + +type UserCustomization struct { + Name string `json:"name" toml:"name"` + Description *string `json:"description,omitempty" toml:"description,omitempty"` + Password *string `json:"password,omitempty" toml:"password,omitempty"` + Key *string `json:"key,omitempty" toml:"key,omitempty"` + Home *string `json:"home,omitempty" toml:"home,omitempty"` + Shell *string `json:"shell,omitempty" toml:"shell,omitempty"` + Groups []string `json:"groups,omitempty" toml:"groups,omitempty"` + UID *int `json:"uid,omitempty" toml:"uid,omitempty"` + GID *int `json:"gid,omitempty" toml:"gid,omitempty"` +} + +type GroupCustomization struct { + Name string `json:"name" toml:"name"` + GID *int `json:"gid,omitempty" toml:"gid,omitempty"` +} + +type TimezoneCustomization struct { + Timezone *string `json:"timezone,omitempty" toml:"timezone,omitempty"` + NTPServers []string `json:"ntpservers,omitempty" toml:"ntpservers,omitempty"` +} + +type LocaleCustomization struct { + Languages []string `json:"languages,omitempty" toml:"languages,omitempty"` + Keyboard *string `json:"keyboard,omitempty" toml:"keyboard,omitempty"` +} + +type FirewallCustomization struct { + Ports []string `json:"ports,omitempty" toml:"ports,omitempty"` + Services *FirewallServicesCustomization `json:"services,omitempty" toml:"services,omitempty"` + Zones []FirewallZoneCustomization `json:"zones,omitempty" toml:"zones,omitempty"` +} + +type FirewallZoneCustomization struct { + Name *string `json:"name,omitempty" toml:"name,omitempty"` + Sources []string `json:"sources,omitempty" toml:"sources,omitempty"` +} + +type FirewallServicesCustomization struct { + Enabled []string `json:"enabled,omitempty" toml:"enabled,omitempty"` + Disabled []string `json:"disabled,omitempty" toml:"disabled,omitempty"` +} + +type ServicesCustomization struct { + Enabled []string `json:"enabled,omitempty" toml:"enabled,omitempty"` + Disabled []string `json:"disabled,omitempty" toml:"disabled,omitempty"` +} + +type OpenSCAPCustomization struct { + DataStream string `json:"datastream,omitempty" toml:"datastream,omitempty"` + ProfileID string `json:"profile_id,omitempty" toml:"profile_id,omitempty"` +} + +type CustomizationError struct { + Message string +} + +func (e *CustomizationError) Error() string { + return e.Message +} + +// CheckCustomizations returns an error of type `CustomizationError` +// if `c` has any customizations not specified in `allowed` +func (c *Customizations) CheckAllowed(allowed ...string) error { + if c == nil { + return nil + } + + allowMap := make(map[string]bool) + + for _, a := range allowed { + allowMap[a] = true + } + + t := reflect.TypeOf(*c) + v := reflect.ValueOf(*c) + + for i := 0; i < t.NumField(); i++ { + + empty := false + field := v.Field(i) + + switch field.Kind() { + case reflect.String: + if field.String() == "" { + empty = true + } + case reflect.Array, reflect.Slice: + if field.Len() == 0 { + empty = true + } + case reflect.Ptr: + if field.IsNil() { + empty = true + } + default: + panic(fmt.Sprintf("unhandled customization field type %s, %s", v.Kind(), t.Field(i).Name)) + + } + + if !empty && !allowMap[t.Field(i).Name] { + return &CustomizationError{fmt.Sprintf("'%s' is not allowed", t.Field(i).Name)} + } + } + + return nil +} + +func (c *Customizations) GetHostname() *string { + if c == nil { + return nil + } + return c.Hostname +} + +func (c *Customizations) GetPrimaryLocale() (*string, *string) { + if c == nil { + return nil, nil + } + if c.Locale == nil { + return nil, nil + } + if len(c.Locale.Languages) == 0 { + return nil, c.Locale.Keyboard + } + return &c.Locale.Languages[0], c.Locale.Keyboard +} + +func (c *Customizations) GetTimezoneSettings() (*string, []string) { + if c == nil { + return nil, nil + } + if c.Timezone == nil { + return nil, nil + } + return c.Timezone.Timezone, c.Timezone.NTPServers +} + +func (c *Customizations) GetUsers() []UserCustomization { + if c == nil { + return nil + } + + users := []UserCustomization{} + + // prepend sshkey for backwards compat (overridden by users) + if len(c.SSHKey) > 0 { + for _, c := range c.SSHKey { + users = append(users, UserCustomization{ + Name: c.User, + Key: &c.Key, + }) + } + } + + users = append(users, c.User...) + + // sanitize user home directory in blueprint: if it has a trailing slash, + // it might lead to the directory not getting the correct selinux labels + for idx := range users { + u := users[idx] + if u.Home != nil { + homedir := strings.TrimRight(*u.Home, "/") + u.Home = &homedir + users[idx] = u + } + } + return users +} + +func (c *Customizations) GetGroups() []GroupCustomization { + if c == nil { + return nil + } + + return c.Group +} + +func (c *Customizations) GetKernel() *KernelCustomization { + var name string + var append string + if c != nil && c.Kernel != nil { + name = c.Kernel.Name + append = c.Kernel.Append + } + + if name == "" { + name = "kernel" + } + + return &KernelCustomization{ + Name: name, + Append: append, + } +} + +func (c *Customizations) GetFirewall() *FirewallCustomization { + if c == nil { + return nil + } + + return c.Firewall +} + +func (c *Customizations) GetServices() *ServicesCustomization { + if c == nil { + return nil + } + + return c.Services +} + +func (c *Customizations) GetFilesystems() []FilesystemCustomization { + if c == nil { + return nil + } + return c.Filesystem +} + +func (c *Customizations) GetFilesystemsMinSize() uint64 { + if c == nil { + return 0 + } + var agg uint64 + for _, m := range c.Filesystem { + agg += m.MinSize + } + // This ensures that file system customization `size` is a multiple of + // sector size (512) + if agg%512 != 0 { + agg = (agg/512 + 1) * 512 + } + return agg +} + +func (c *Customizations) GetInstallationDevice() string { + if c == nil || c.InstallationDevice == "" { + return "" + } + return c.InstallationDevice +} + +func (c *Customizations) GetFDO() *FDOCustomization { + if c == nil { + return nil + } + return c.FDO +} + +func (c *Customizations) GetOpenSCAP() *OpenSCAPCustomization { + if c == nil { + return nil + } + return c.OpenSCAP +} + +func (c *Customizations) GetIgnition() *IgnitionCustomization { + if c == nil { + return nil + } + return c.Ignition +} + +func (c *Customizations) GetDirectories() []DirectoryCustomization { + if c == nil { + return nil + } + return c.Directories +} + +func (c *Customizations) GetFiles() []FileCustomization { + if c == nil { + return nil + } + return c.Files +} + +func (c *Customizations) GetRepositories() ([]RepositoryCustomization, error) { + if c == nil { + return nil, nil + } + + for idx := range c.Repositories { + err := validateCustomRepository(&c.Repositories[idx]) + if err != nil { + return nil, err + } + } + + return c.Repositories, nil +} diff --git a/vendor/github.com/osbuild/images/pkg/blueprint/filesystem_customizations.go b/vendor/github.com/osbuild/images/pkg/blueprint/filesystem_customizations.go new file mode 100644 index 000000000..3a992b6fe --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/blueprint/filesystem_customizations.go @@ -0,0 +1,89 @@ +package blueprint + +import ( + "encoding/json" + "fmt" + + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/pathpolicy" +) + +type FilesystemCustomization struct { + Mountpoint string `json:"mountpoint,omitempty" toml:"mountpoint,omitempty"` + MinSize uint64 `json:"minsize,omitempty" toml:"size,omitempty"` +} + +func (fsc *FilesystemCustomization) UnmarshalTOML(data interface{}) error { + d, _ := data.(map[string]interface{}) + + switch d["mountpoint"].(type) { + case string: + fsc.Mountpoint = d["mountpoint"].(string) + default: + return fmt.Errorf("TOML unmarshal: mountpoint must be string, got %v of type %T", d["mountpoint"], d["mountpoint"]) + } + + switch d["size"].(type) { + case int64: + fsc.MinSize = uint64(d["size"].(int64)) + case string: + size, err := common.DataSizeToUint64(d["size"].(string)) + if err != nil { + return fmt.Errorf("TOML unmarshal: size is not valid filesystem size (%w)", err) + } + fsc.MinSize = size + default: + return fmt.Errorf("TOML unmarshal: size must be integer or string, got %v of type %T", d["size"], d["size"]) + } + + return nil +} + +func (fsc *FilesystemCustomization) UnmarshalJSON(data []byte) error { + var v interface{} + if err := json.Unmarshal(data, &v); err != nil { + return err + } + d, _ := v.(map[string]interface{}) + + switch d["mountpoint"].(type) { + case string: + fsc.Mountpoint = d["mountpoint"].(string) + default: + return fmt.Errorf("JSON unmarshal: mountpoint must be string, got %v of type %T", d["mountpoint"], d["mountpoint"]) + } + + // The JSON specification only mentions float64 and Go defaults to it: https://go.dev/blog/json + switch d["minsize"].(type) { + case float64: + // Note that it uses different key than the TOML version + fsc.MinSize = uint64(d["minsize"].(float64)) + case string: + size, err := common.DataSizeToUint64(d["minsize"].(string)) + if err != nil { + return fmt.Errorf("JSON unmarshal: size is not valid filesystem size (%w)", err) + } + fsc.MinSize = size + default: + return fmt.Errorf("JSON unmarshal: minsize must be float64 number or string, got %v of type %T", d["minsize"], d["minsize"]) + } + + return nil +} + +// CheckMountpointsPolicy checks if the mountpoints are allowed by the policy +func CheckMountpointsPolicy(mountpoints []FilesystemCustomization, mountpointAllowList *pathpolicy.PathPolicies) error { + invalidMountpoints := []string{} + for _, m := range mountpoints { + err := mountpointAllowList.Check(m.Mountpoint) + if err != nil { + invalidMountpoints = append(invalidMountpoints, m.Mountpoint) + } + } + + if len(invalidMountpoints) > 0 { + return fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints) + } + + return nil +} diff --git a/vendor/github.com/osbuild/images/pkg/blueprint/fsnode_customizations.go b/vendor/github.com/osbuild/images/pkg/blueprint/fsnode_customizations.go new file mode 100644 index 000000000..3e0b458c3 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/blueprint/fsnode_customizations.go @@ -0,0 +1,471 @@ +package blueprint + +import ( + "encoding/json" + "fmt" + "os" + "path" + "regexp" + "sort" + "strconv" + "strings" + + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/fsnode" + "github.com/osbuild/images/internal/pathpolicy" +) + +// validateModeString checks that the given string is a valid mode octal number +func validateModeString(mode string) error { + // Check that the mode string matches the octal format regular expression. + // The leading is optional. + if regexp.MustCompile(`^[0]{0,1}[0-7]{3}$`).MatchString(mode) { + return nil + } + return fmt.Errorf("invalid mode %s: must be an octal number", mode) +} + +// DirectoryCustomization represents a directory to be created in the image +type DirectoryCustomization struct { + // Absolute path to the directory + Path string `json:"path" toml:"path"` + // Owner of the directory specified as a string (user name), int64 (UID) or nil + User interface{} `json:"user,omitempty" toml:"user,omitempty"` + // Owner of the directory specified as a string (group name), int64 (UID) or nil + Group interface{} `json:"group,omitempty" toml:"group,omitempty"` + // Permissions of the directory specified as an octal number + Mode string `json:"mode,omitempty" toml:"mode,omitempty"` + // EnsureParents ensures that all parent directories of the directory exist + EnsureParents bool `json:"ensure_parents,omitempty" toml:"ensure_parents,omitempty"` +} + +// Custom TOML unmarshalling for DirectoryCustomization with validation +func (d *DirectoryCustomization) UnmarshalTOML(data interface{}) error { + var dir DirectoryCustomization + + dataMap, _ := data.(map[string]interface{}) + + switch path := dataMap["path"].(type) { + case string: + dir.Path = path + default: + return fmt.Errorf("UnmarshalTOML: path must be a string") + } + + switch user := dataMap["user"].(type) { + case string: + dir.User = user + case int64: + dir.User = user + case nil: + break + default: + return fmt.Errorf("UnmarshalTOML: user must be a string or an integer, got %T", user) + } + + switch group := dataMap["group"].(type) { + case string: + dir.Group = group + case int64: + dir.Group = group + case nil: + break + default: + return fmt.Errorf("UnmarshalTOML: group must be a string or an integer") + } + + switch mode := dataMap["mode"].(type) { + case string: + dir.Mode = mode + case nil: + break + default: + return fmt.Errorf("UnmarshalTOML: mode must be a string") + } + + switch ensureParents := dataMap["ensure_parents"].(type) { + case bool: + dir.EnsureParents = ensureParents + case nil: + break + default: + return fmt.Errorf("UnmarshalTOML: ensure_parents must be a bool") + } + + // try converting to fsnode.Directory to validate all values + _, err := dir.ToFsNodeDirectory() + if err != nil { + return err + } + + *d = dir + return nil +} + +// Custom JSON unmarshalling for DirectoryCustomization with validation +func (d *DirectoryCustomization) UnmarshalJSON(data []byte) error { + type directoryCustomization DirectoryCustomization + + var dirPrivate directoryCustomization + if err := json.Unmarshal(data, &dirPrivate); err != nil { + return err + } + + dir := DirectoryCustomization(dirPrivate) + if uid, ok := dir.User.(float64); ok { + // check if uid can be converted to int64 + if uid != float64(int64(uid)) { + return fmt.Errorf("invalid user %f: must be an integer", uid) + } + dir.User = int64(uid) + } + if gid, ok := dir.Group.(float64); ok { + // check if gid can be converted to int64 + if gid != float64(int64(gid)) { + return fmt.Errorf("invalid group %f: must be an integer", gid) + } + dir.Group = int64(gid) + } + // try converting to fsnode.Directory to validate all values + _, err := dir.ToFsNodeDirectory() + if err != nil { + return err + } + + *d = dir + return nil +} + +// ToFsNodeDirectory converts the DirectoryCustomization to an fsnode.Directory +func (d DirectoryCustomization) ToFsNodeDirectory() (*fsnode.Directory, error) { + var mode *os.FileMode + if d.Mode != "" { + err := validateModeString(d.Mode) + if err != nil { + return nil, err + } + modeNum, err := strconv.ParseUint(d.Mode, 8, 32) + if err != nil { + return nil, fmt.Errorf("invalid mode %s: %v", d.Mode, err) + } + mode = common.ToPtr(os.FileMode(modeNum)) + } + + return fsnode.NewDirectory(d.Path, mode, d.User, d.Group, d.EnsureParents) +} + +// DirectoryCustomizationsToFsNodeDirectories converts a slice of DirectoryCustomizations +// to a slice of fsnode.Directories +func DirectoryCustomizationsToFsNodeDirectories(dirs []DirectoryCustomization) ([]*fsnode.Directory, error) { + if len(dirs) == 0 { + return nil, nil + } + + var fsDirs []*fsnode.Directory + var errors []error + for _, dir := range dirs { + fsDir, err := dir.ToFsNodeDirectory() + if err != nil { + errors = append(errors, err) + } + fsDirs = append(fsDirs, fsDir) + } + + if len(errors) > 0 { + return nil, fmt.Errorf("invalid directory customizations: %v", errors) + } + + return fsDirs, nil +} + +// FileCustomization represents a file to be created in the image +type FileCustomization struct { + // Absolute path to the file + Path string `json:"path" toml:"path"` + // Owner of the directory specified as a string (user name), int64 (UID) or nil + User interface{} `json:"user,omitempty" toml:"user,omitempty"` + // Owner of the directory specified as a string (group name), int64 (UID) or nil + Group interface{} `json:"group,omitempty" toml:"group,omitempty"` + // Permissions of the file specified as an octal number + Mode string `json:"mode,omitempty" toml:"mode,omitempty"` + // Data is the file content in plain text + Data string `json:"data,omitempty" toml:"data,omitempty"` +} + +// Custom TOML unmarshalling for FileCustomization with validation +func (f *FileCustomization) UnmarshalTOML(data interface{}) error { + var file FileCustomization + + dataMap, _ := data.(map[string]interface{}) + + switch path := dataMap["path"].(type) { + case string: + file.Path = path + default: + return fmt.Errorf("UnmarshalTOML: path must be a string") + } + + switch user := dataMap["user"].(type) { + case string: + file.User = user + case int64: + file.User = user + case nil: + break + default: + return fmt.Errorf("UnmarshalTOML: user must be a string or an integer") + } + + switch group := dataMap["group"].(type) { + case string: + file.Group = group + case int64: + file.Group = group + case nil: + break + default: + return fmt.Errorf("UnmarshalTOML: group must be a string or an integer") + } + + switch mode := dataMap["mode"].(type) { + case string: + file.Mode = mode + case nil: + break + default: + return fmt.Errorf("UnmarshalTOML: mode must be a string") + } + + switch data := dataMap["data"].(type) { + case string: + file.Data = data + case nil: + break + default: + return fmt.Errorf("UnmarshalTOML: data must be a string") + } + + // try converting to fsnode.File to validate all values + _, err := file.ToFsNodeFile() + if err != nil { + return err + } + + *f = file + return nil +} + +// Custom JSON unmarshalling for FileCustomization with validation +func (f *FileCustomization) UnmarshalJSON(data []byte) error { + type fileCustomization FileCustomization + + var filePrivate fileCustomization + if err := json.Unmarshal(data, &filePrivate); err != nil { + return err + } + + file := FileCustomization(filePrivate) + if uid, ok := file.User.(float64); ok { + // check if uid can be converted to int64 + if uid != float64(int64(uid)) { + return fmt.Errorf("invalid user %f: must be an integer", uid) + } + file.User = int64(uid) + } + if gid, ok := file.Group.(float64); ok { + // check if gid can be converted to int64 + if gid != float64(int64(gid)) { + return fmt.Errorf("invalid group %f: must be an integer", gid) + } + file.Group = int64(gid) + } + // try converting to fsnode.File to validate all values + _, err := file.ToFsNodeFile() + if err != nil { + return err + } + + *f = file + return nil +} + +// ToFsNodeFile converts the FileCustomization to an fsnode.File +func (f FileCustomization) ToFsNodeFile() (*fsnode.File, error) { + var data []byte + if f.Data != "" { + data = []byte(f.Data) + } + + var mode *os.FileMode + if f.Mode != "" { + err := validateModeString(f.Mode) + if err != nil { + return nil, err + } + modeNum, err := strconv.ParseUint(f.Mode, 8, 32) + if err != nil { + return nil, fmt.Errorf("invalid mode %s: %v", f.Mode, err) + } + mode = common.ToPtr(os.FileMode(modeNum)) + } + + return fsnode.NewFile(f.Path, mode, f.User, f.Group, data) +} + +// FileCustomizationsToFsNodeFiles converts a slice of FileCustomization to a slice of *fsnode.File +func FileCustomizationsToFsNodeFiles(files []FileCustomization) ([]*fsnode.File, error) { + if len(files) == 0 { + return nil, nil + } + + var fsFiles []*fsnode.File + var errors []error + for _, file := range files { + fsFile, err := file.ToFsNodeFile() + if err != nil { + errors = append(errors, err) + } + fsFiles = append(fsFiles, fsFile) + } + + if len(errors) > 0 { + return nil, fmt.Errorf("invalid file customizations: %v", errors) + } + + return fsFiles, nil +} + +// ValidateDirFileCustomizations validates the given Directory and File customizations. +// If the customizations are invalid, an error is returned. Otherwise, nil is returned. +// +// It currently ensures that: +// - No file path is a prefix of another file or directory path +// - There are no duplicate file or directory paths in the customizations +func ValidateDirFileCustomizations(dirs []DirectoryCustomization, files []FileCustomization) error { + fsNodesMap := make(map[string]interface{}, len(dirs)+len(files)) + nodesPaths := make([]string, 0, len(dirs)+len(files)) + + // First check for duplicate paths + duplicatePaths := make([]string, 0) + for _, dir := range dirs { + if _, ok := fsNodesMap[dir.Path]; ok { + duplicatePaths = append(duplicatePaths, dir.Path) + } + fsNodesMap[dir.Path] = dir + nodesPaths = append(nodesPaths, dir.Path) + } + + for _, file := range files { + if _, ok := fsNodesMap[file.Path]; ok { + duplicatePaths = append(duplicatePaths, file.Path) + } + fsNodesMap[file.Path] = file + nodesPaths = append(nodesPaths, file.Path) + } + + // There is no point in continuing if there are duplicate paths, + // since the fsNodesMap will not be valid. + if len(duplicatePaths) > 0 { + return fmt.Errorf("duplicate files / directory customization paths: %v", duplicatePaths) + } + + invalidFSNodes := make([]string, 0) + checkedPaths := make(map[string]bool) + // Sort the paths so that we always check the longest paths first. This + // ensures that we don't check a parent path before we check the child + // path. Reverse sort the slice based on directory depth. + sort.Slice(nodesPaths, func(i, j int) bool { + return strings.Count(nodesPaths[i], "/") > strings.Count(nodesPaths[j], "/") + }) + + for _, nodePath := range nodesPaths { + // Skip paths that we have already checked + if checkedPaths[nodePath] { + continue + } + + // Check all parent paths of the current path. If any of them have + // already been checked, then we do not need to check them again. + // This is because we always check the longest paths first. If a parent + // path exists in the filesystem nodes map and it is a File, + // then it is an error because it is a parent of a Directory or File. + // Parent paths can be only Directories. + parentPath := nodePath + for { + parentPath = path.Dir(parentPath) + + // "." is returned only when the path is relative and we reached + // the root directory. This should never happen because File + // and Directory customization paths are validated as part of + // the unmarshalling process from JSON and TOML. + if parentPath == "." { + panic("filesystem node has relative path set.") + } + + if parentPath == "/" { + break + } + + if checkedPaths[parentPath] { + break + } + + // If the node is not a Directory, then it is an error because + // it is a parent of a Directory or File. + if node, ok := fsNodesMap[parentPath]; ok { + switch node.(type) { + case DirectoryCustomization: + break + case FileCustomization: + invalidFSNodes = append(invalidFSNodes, nodePath) + default: + panic(fmt.Sprintf("unexpected filesystem node customization type: %T", node)) + } + } + + checkedPaths[parentPath] = true + } + + checkedPaths[nodePath] = true + } + + if len(invalidFSNodes) > 0 { + return fmt.Errorf("the following filesystem nodes are parents of another node and are not directories: %s", invalidFSNodes) + } + + return nil +} + +// CheckFileCustomizationsPolicy checks if the given File customizations are allowed by the path policy. +// If any of the customizations are not allowed by the path policy, an error is returned. Otherwise, nil is returned. +func CheckFileCustomizationsPolicy(files []FileCustomization, pathPolicy *pathpolicy.PathPolicies) error { + var invalidPaths []string + for _, file := range files { + if err := pathPolicy.Check(file.Path); err != nil { + invalidPaths = append(invalidPaths, file.Path) + } + } + + if len(invalidPaths) > 0 { + return fmt.Errorf("the following custom files are not allowed: %+q", invalidPaths) + } + + return nil +} + +// CheckDirectoryCustomizationsPolicy checks if the given Directory customizations are allowed by the path policy. +// If any of the customizations are not allowed by the path policy, an error is returned. Otherwise, nil is returned. +func CheckDirectoryCustomizationsPolicy(dirs []DirectoryCustomization, pathPolicy *pathpolicy.PathPolicies) error { + var invalidPaths []string + for _, dir := range dirs { + if err := pathPolicy.Check(dir.Path); err != nil { + invalidPaths = append(invalidPaths, dir.Path) + } + } + + if len(invalidPaths) > 0 { + return fmt.Errorf("the following custom directories are not allowed: %+q", invalidPaths) + } + + return nil +} diff --git a/vendor/github.com/osbuild/images/pkg/blueprint/repository_customizations.go b/vendor/github.com/osbuild/images/pkg/blueprint/repository_customizations.go new file mode 100644 index 000000000..f534804cd --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/blueprint/repository_customizations.go @@ -0,0 +1,137 @@ +package blueprint + +import ( + "fmt" + "net/url" + "regexp" + "strings" + + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/fsnode" + "github.com/osbuild/images/pkg/rpmmd" +) + +type RepositoryCustomization struct { + Id string `json:"id" toml:"id"` + BaseURLs []string `json:"baseurls,omitempty" toml:"baseurls,omitempty"` + GPGKeys []string `json:"gpgkeys,omitempty" toml:"gpgkeys,omitempty"` + Metalink string `json:"metalink,omitempty" toml:"metalink,omitempty"` + Mirrorlist string `json:"mirrorlist,omitempty" toml:"mirrorlist,omitempty"` + Name string `json:"name,omitempty" toml:"name,omitempty"` + Priority *int `json:"priority,omitempty" toml:"priority,omitempty"` + Enabled *bool `json:"enabled,omitempty" toml:"enabled,omitempty"` + GPGCheck *bool `json:"gpgcheck,omitempty" toml:"gpgcheck,omitempty"` + RepoGPGCheck *bool `json:"repo_gpgcheck,omitempty" toml:"repo_gpgcheck,omitempty"` + SSLVerify *bool `json:"sslverify,omitempty" toml:"sslverify,omitempty"` + Filename string `json:"filename,omitempty" toml:"filename,omitempty"` +} + +const repoFilenameRegex = "^[\\w.-]{1,250}\\.repo$" + +func validateCustomRepository(repo *RepositoryCustomization) error { + if repo.Id == "" { + return fmt.Errorf("Repository ID is required") + } + + filenameRegex := regexp.MustCompile(repoFilenameRegex) + if !filenameRegex.MatchString(repo.getFilename()) { + return fmt.Errorf("Repository filename %q is invalid", repo.getFilename()) + } + + if len(repo.BaseURLs) == 0 && repo.Mirrorlist == "" && repo.Metalink == "" { + return fmt.Errorf("Repository base URL, mirrorlist or metalink is required") + } + + if repo.GPGCheck != nil && *repo.GPGCheck && len(repo.GPGKeys) == 0 { + return fmt.Errorf("Repository gpg check is set to true but no gpg keys are provided") + } + + for _, key := range repo.GPGKeys { + // check for a valid GPG key prefix & contains GPG suffix + keyIsGPGKey := strings.HasPrefix(key, "-----BEGIN PGP PUBLIC KEY BLOCK-----") && strings.Contains(key, "-----END PGP PUBLIC KEY BLOCK-----") + + // check for a valid URL + keyIsURL := false + _, err := url.ParseRequestURI(key) + if err == nil { + keyIsURL = true + } + + if !keyIsGPGKey && !keyIsURL { + return fmt.Errorf("Repository gpg key is not a valid URL or a valid gpg key") + } + } + + return nil +} + +func (rc *RepositoryCustomization) getFilename() string { + if rc.Filename == "" { + return fmt.Sprintf("%s.repo", rc.Id) + } + if !strings.HasSuffix(rc.Filename, ".repo") { + return fmt.Sprintf("%s.repo", rc.Filename) + } + return rc.Filename +} + +func RepoCustomizationsToRepoConfigAndGPGKeyFiles(repos []RepositoryCustomization) (map[string][]rpmmd.RepoConfig, []*fsnode.File, error) { + if len(repos) == 0 { + return nil, nil, nil + } + + repoMap := make(map[string][]rpmmd.RepoConfig, len(repos)) + var gpgKeyFiles []*fsnode.File + for _, repo := range repos { + filename := repo.getFilename() + convertedRepo := repo.customRepoToRepoConfig() + + // convert any inline gpgkeys to fsnode.File and + // replace the gpgkey with the file path + for idx, gpgkey := range repo.GPGKeys { + if _, ok := url.ParseRequestURI(gpgkey); ok != nil { + // create the file path + path := fmt.Sprintf("/etc/pki/rpm-gpg/RPM-GPG-KEY-%s-%d", repo.Id, idx) + // replace the gpgkey with the file path + convertedRepo.GPGKeys[idx] = fmt.Sprintf("file://%s", path) + // create the fsnode for the gpgkey keyFile + keyFile, err := fsnode.NewFile(path, nil, nil, nil, []byte(gpgkey)) + if err != nil { + return nil, nil, err + } + gpgKeyFiles = append(gpgKeyFiles, keyFile) + } + } + + repoMap[filename] = append(repoMap[filename], convertedRepo) + } + + return repoMap, gpgKeyFiles, nil +} + +func (repo RepositoryCustomization) customRepoToRepoConfig() rpmmd.RepoConfig { + urls := make([]string, len(repo.BaseURLs)) + copy(urls, repo.BaseURLs) + + keys := make([]string, len(repo.GPGKeys)) + copy(keys, repo.GPGKeys) + + repoConfig := rpmmd.RepoConfig{ + Id: repo.Id, + BaseURLs: urls, + GPGKeys: keys, + Name: repo.Name, + Metalink: repo.Metalink, + MirrorList: repo.Mirrorlist, + CheckGPG: repo.GPGCheck, + CheckRepoGPG: repo.RepoGPGCheck, + Priority: repo.Priority, + Enabled: repo.Enabled, + } + + if repo.SSLVerify != nil { + repoConfig.IgnoreSSL = common.ToPtr(!*repo.SSLVerify) + } + + return repoConfig +} diff --git a/internal/container/client.go b/vendor/github.com/osbuild/images/pkg/container/client.go similarity index 99% rename from internal/container/client.go rename to vendor/github.com/osbuild/images/pkg/container/client.go index e90fff79c..33c7d9c06 100644 --- a/internal/container/client.go +++ b/vendor/github.com/osbuild/images/pkg/container/client.go @@ -16,7 +16,7 @@ import ( _ "github.com/containers/image/v5/oci/layout" "golang.org/x/sys/unix" - "github.com/osbuild/osbuild-composer/internal/common" + "github.com/osbuild/images/internal/common" "github.com/containers/common/pkg/retry" "github.com/containers/image/v5/copy" diff --git a/internal/container/resolver.go b/vendor/github.com/osbuild/images/pkg/container/resolver.go similarity index 100% rename from internal/container/resolver.go rename to vendor/github.com/osbuild/images/pkg/container/resolver.go diff --git a/internal/container/spec.go b/vendor/github.com/osbuild/images/pkg/container/spec.go similarity index 100% rename from internal/container/spec.go rename to vendor/github.com/osbuild/images/pkg/container/spec.go diff --git a/internal/crypt/crypt.go b/vendor/github.com/osbuild/images/pkg/crypt/crypt.go similarity index 100% rename from internal/crypt/crypt.go rename to vendor/github.com/osbuild/images/pkg/crypt/crypt.go diff --git a/internal/crypt/crypt_impl.go b/vendor/github.com/osbuild/images/pkg/crypt/crypt_impl.go similarity index 95% rename from internal/crypt/crypt_impl.go rename to vendor/github.com/osbuild/images/pkg/crypt/crypt_impl.go index 10ed5f355..04a40cd95 100644 --- a/internal/crypt/crypt_impl.go +++ b/vendor/github.com/osbuild/images/pkg/crypt/crypt_impl.go @@ -4,7 +4,7 @@ // Original sources are under MIT license: // The MIT License (MIT) // -// Copyright (c) 2015 Akshay Moghe +// # Copyright (c) 2015 Akshay Moghe // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -24,7 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // -// Package crypt provides wrappers around functions available in crypt.h +// # Package crypt provides wrappers around functions available in crypt.h // // It wraps around the GNU specific extension (crypt_r) when it is available // (i.e. where GOOS=linux). This makes the go function reentrant (and thus diff --git a/internal/crypt/crypt_impl_macos.go b/vendor/github.com/osbuild/images/pkg/crypt/crypt_impl_macos.go similarity index 100% rename from internal/crypt/crypt_impl_macos.go rename to vendor/github.com/osbuild/images/pkg/crypt/crypt_impl_macos.go diff --git a/internal/disk/btrfs.go b/vendor/github.com/osbuild/images/pkg/disk/btrfs.go similarity index 100% rename from internal/disk/btrfs.go rename to vendor/github.com/osbuild/images/pkg/disk/btrfs.go diff --git a/internal/disk/disk.go b/vendor/github.com/osbuild/images/pkg/disk/disk.go similarity index 100% rename from internal/disk/disk.go rename to vendor/github.com/osbuild/images/pkg/disk/disk.go diff --git a/internal/disk/filesystem.go b/vendor/github.com/osbuild/images/pkg/disk/filesystem.go similarity index 100% rename from internal/disk/filesystem.go rename to vendor/github.com/osbuild/images/pkg/disk/filesystem.go diff --git a/internal/disk/luks.go b/vendor/github.com/osbuild/images/pkg/disk/luks.go similarity index 100% rename from internal/disk/luks.go rename to vendor/github.com/osbuild/images/pkg/disk/luks.go diff --git a/internal/disk/lvm.go b/vendor/github.com/osbuild/images/pkg/disk/lvm.go similarity index 98% rename from internal/disk/lvm.go rename to vendor/github.com/osbuild/images/pkg/disk/lvm.go index 809f5e3f9..13cb561ff 100644 --- a/internal/disk/lvm.go +++ b/vendor/github.com/osbuild/images/pkg/disk/lvm.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/osbuild/osbuild-composer/internal/common" + "github.com/osbuild/images/internal/common" ) // Default physical extent size in bytes: logical volumes diff --git a/internal/disk/partition.go b/vendor/github.com/osbuild/images/pkg/disk/partition.go similarity index 100% rename from internal/disk/partition.go rename to vendor/github.com/osbuild/images/pkg/disk/partition.go diff --git a/internal/disk/partition_table.go b/vendor/github.com/osbuild/images/pkg/disk/partition_table.go similarity index 99% rename from internal/disk/partition_table.go rename to vendor/github.com/osbuild/images/pkg/disk/partition_table.go index a20b0f38a..48b9211f1 100644 --- a/internal/disk/partition_table.go +++ b/vendor/github.com/osbuild/images/pkg/disk/partition_table.go @@ -6,7 +6,7 @@ import ( "path/filepath" "github.com/google/uuid" - "github.com/osbuild/osbuild-composer/internal/blueprint" + "github.com/osbuild/images/pkg/blueprint" ) type PartitionTable struct { diff --git a/internal/distro/distro.go b/vendor/github.com/osbuild/images/pkg/distro/distro.go similarity index 91% rename from internal/distro/distro.go rename to vendor/github.com/osbuild/images/pkg/distro/distro.go index 08dd61ff7..7628a252d 100644 --- a/internal/distro/distro.go +++ b/vendor/github.com/osbuild/images/pkg/distro/distro.go @@ -1,13 +1,13 @@ package distro import ( - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rhsm/facts" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rhsm/facts" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) type BootMode uint64 diff --git a/internal/distro/distro_test_common/distro_test_common.go b/vendor/github.com/osbuild/images/pkg/distro/distro_test_common/distro_test_common.go similarity index 97% rename from internal/distro/distro_test_common/distro_test_common.go rename to vendor/github.com/osbuild/images/pkg/distro/distro_test_common/distro_test_common.go index e536eb4be..1780036b9 100644 --- a/internal/distro/distro_test_common/distro_test_common.go +++ b/vendor/github.com/osbuild/images/pkg/distro/distro_test_common/distro_test_common.go @@ -13,16 +13,16 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" - "github.com/osbuild/osbuild-composer/internal/dnfjson" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rhsm/facts" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/dnfjson" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rhsm/facts" + "github.com/osbuild/images/pkg/rpmmd" ) const RandomTestSeed = 0 diff --git a/internal/distro/fedora/distro.go b/vendor/github.com/osbuild/images/pkg/distro/fedora/distro.go similarity index 98% rename from internal/distro/fedora/distro.go rename to vendor/github.com/osbuild/images/pkg/distro/fedora/distro.go index 5cd685895..5ab1eed0a 100644 --- a/internal/distro/fedora/distro.go +++ b/vendor/github.com/osbuild/images/pkg/distro/fedora/distro.go @@ -6,13 +6,13 @@ import ( "sort" "strconv" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/oscap" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/oscap" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) const ( diff --git a/internal/distro/fedora/images.go b/vendor/github.com/osbuild/images/pkg/distro/fedora/images.go similarity index 95% rename from internal/distro/fedora/images.go rename to vendor/github.com/osbuild/images/pkg/distro/fedora/images.go index 32cf6b407..7470f4102 100644 --- a/internal/distro/fedora/images.go +++ b/vendor/github.com/osbuild/images/pkg/distro/fedora/images.go @@ -5,18 +5,18 @@ import ( "math/rand" "strings" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/image" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/oscap" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/users" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/oscap" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/image" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rpmmd" ) // HELPERS diff --git a/internal/distro/fedora/imagetype.go b/vendor/github.com/osbuild/images/pkg/distro/fedora/imagetype.go similarity index 92% rename from internal/distro/fedora/imagetype.go rename to vendor/github.com/osbuild/images/pkg/distro/fedora/imagetype.go index 8b3438931..11e1002de 100644 --- a/internal/distro/fedora/imagetype.go +++ b/vendor/github.com/osbuild/images/pkg/distro/fedora/imagetype.go @@ -5,20 +5,20 @@ import ( "math/rand" "strings" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/image" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/oscap" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/pathpolicy" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/oscap" + "github.com/osbuild/images/internal/pathpolicy" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/image" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" "golang.org/x/exp/slices" ) diff --git a/internal/distro/fedora/package_sets.go b/vendor/github.com/osbuild/images/pkg/distro/fedora/package_sets.go similarity index 98% rename from internal/distro/fedora/package_sets.go rename to vendor/github.com/osbuild/images/pkg/distro/fedora/package_sets.go index ae267a6df..6918dff72 100644 --- a/internal/distro/fedora/package_sets.go +++ b/vendor/github.com/osbuild/images/pkg/distro/fedora/package_sets.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) func qcow2CommonPackageSet(t *imageType) rpmmd.PackageSet { diff --git a/internal/distro/fedora/partition_tables.go b/vendor/github.com/osbuild/images/pkg/distro/fedora/partition_tables.go similarity index 95% rename from internal/distro/fedora/partition_tables.go rename to vendor/github.com/osbuild/images/pkg/distro/fedora/partition_tables.go index 8b7572294..259920160 100644 --- a/internal/distro/fedora/partition_tables.go +++ b/vendor/github.com/osbuild/images/pkg/distro/fedora/partition_tables.go @@ -1,10 +1,10 @@ package fedora import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/platform" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/platform" ) var defaultBasePartitionTables = distro.BasePartitionTableMap{ diff --git a/internal/distro/image_config.go b/vendor/github.com/osbuild/images/pkg/distro/image_config.go similarity index 95% rename from internal/distro/image_config.go rename to vendor/github.com/osbuild/images/pkg/distro/image_config.go index 1fc72e787..d7cd079a5 100644 --- a/internal/distro/image_config.go +++ b/vendor/github.com/osbuild/images/pkg/distro/image_config.go @@ -4,9 +4,9 @@ import ( "fmt" "reflect" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/shell" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/internal/shell" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/subscription" ) // ImageConfig represents a (default) configuration applied to the image diff --git a/internal/distro/rhel7/azure.go b/vendor/github.com/osbuild/images/pkg/distro/rhel7/azure.go similarity index 96% rename from internal/distro/rhel7/azure.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel7/azure.go index 362c29a0f..5a84edec9 100644 --- a/internal/distro/rhel7/azure.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel7/azure.go @@ -1,13 +1,13 @@ package rhel7 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) var azureRhuiImgType = imageType{ diff --git a/internal/distro/rhel7/distro.go b/vendor/github.com/osbuild/images/pkg/distro/rhel7/distro.go similarity index 94% rename from internal/distro/rhel7/distro.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel7/distro.go index cb8425851..e0fca6a02 100644 --- a/internal/distro/rhel7/distro.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel7/distro.go @@ -6,11 +6,11 @@ import ( "sort" "strings" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/runner" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/runner" ) const ( diff --git a/internal/distro/rhel7/images.go b/vendor/github.com/osbuild/images/pkg/distro/rhel7/images.go similarity index 92% rename from internal/distro/rhel7/images.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel7/images.go index 65971fec1..ae9b158ec 100644 --- a/internal/distro/rhel7/images.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel7/images.go @@ -4,17 +4,17 @@ import ( "fmt" "math/rand" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/image" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/users" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/image" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) func osCustomizations( diff --git a/internal/distro/rhel7/imagetype.go b/vendor/github.com/osbuild/images/pkg/distro/rhel7/imagetype.go similarity index 92% rename from internal/distro/rhel7/imagetype.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel7/imagetype.go index 302914be3..9d4b91d9b 100644 --- a/internal/distro/rhel7/imagetype.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel7/imagetype.go @@ -4,17 +4,17 @@ import ( "fmt" "math/rand" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/image" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/pathpolicy" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/pathpolicy" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/image" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" "golang.org/x/exp/slices" ) diff --git a/internal/distro/rhel7/package_sets.go b/vendor/github.com/osbuild/images/pkg/distro/rhel7/package_sets.go similarity index 83% rename from internal/distro/rhel7/package_sets.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel7/package_sets.go index 8615065d1..d888edb8e 100644 --- a/internal/distro/rhel7/package_sets.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel7/package_sets.go @@ -1,7 +1,7 @@ package rhel7 import ( - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/rpmmd" ) // packages that are only in some (sub)-distributions diff --git a/internal/distro/rhel7/partition_tables.go b/vendor/github.com/osbuild/images/pkg/distro/rhel7/partition_tables.go similarity index 87% rename from internal/distro/rhel7/partition_tables.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel7/partition_tables.go index c26d75de6..13b3c724c 100644 --- a/internal/distro/rhel7/partition_tables.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel7/partition_tables.go @@ -1,10 +1,10 @@ package rhel7 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/platform" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/platform" ) // ////////// Partition table ////////// diff --git a/internal/distro/rhel7/qcow2.go b/vendor/github.com/osbuild/images/pkg/distro/rhel7/qcow2.go similarity index 91% rename from internal/distro/rhel7/qcow2.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel7/qcow2.go index 841fa591b..50c29b56c 100644 --- a/internal/distro/rhel7/qcow2.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel7/qcow2.go @@ -1,11 +1,11 @@ package rhel7 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) var qcow2ImgType = imageType{ diff --git a/internal/distro/rhel8/ami.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/ami.go similarity index 98% rename from internal/distro/rhel8/ami.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/ami.go index 7cdf590a7..04731577f 100644 --- a/internal/distro/rhel8/ami.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/ami.go @@ -1,11 +1,11 @@ package rhel8 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) func amiImgTypeX86_64(rd distribution) imageType { diff --git a/internal/distro/rhel8/arch.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/arch.go similarity index 94% rename from internal/distro/rhel8/arch.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/arch.go index 7ae9991dc..89e253943 100644 --- a/internal/distro/rhel8/arch.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/arch.go @@ -5,8 +5,8 @@ import ( "fmt" "sort" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/platform" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/platform" ) type architecture struct { diff --git a/internal/distro/rhel8/azure.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/azure.go similarity index 97% rename from internal/distro/rhel8/azure.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/azure.go index ded3782ce..20996591b 100644 --- a/internal/distro/rhel8/azure.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/azure.go @@ -1,14 +1,14 @@ package rhel8 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/shell" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/shell" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) const defaultAzureKernelOptions = "ro crashkernel=auto console=tty1 console=ttyS0 earlyprintk=ttyS0 rootdelay=300" diff --git a/internal/distro/rhel8/bare_metal.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/bare_metal.go similarity index 98% rename from internal/distro/rhel8/bare_metal.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/bare_metal.go index f1af31b7a..3df18f478 100644 --- a/internal/distro/rhel8/bare_metal.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/bare_metal.go @@ -3,8 +3,8 @@ package rhel8 import ( "fmt" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) func imageInstaller() imageType { diff --git a/internal/distro/rhel8/distro.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/distro.go similarity index 97% rename from internal/distro/rhel8/distro.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/distro.go index 6cff6ddb8..93ce60918 100644 --- a/internal/distro/rhel8/distro.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/distro.go @@ -6,12 +6,12 @@ import ( "sort" "strings" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/oscap" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/runner" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/oscap" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/runner" ) var ( diff --git a/internal/distro/rhel8/edge.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/edge.go similarity index 97% rename from internal/distro/rhel8/edge.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/edge.go index 35cd85602..b67119dd0 100644 --- a/internal/distro/rhel8/edge.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/edge.go @@ -3,10 +3,10 @@ package rhel8 import ( "fmt" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) func edgeCommitImgType(rd distribution) imageType { diff --git a/internal/distro/rhel8/gce.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/gce.go similarity index 96% rename from internal/distro/rhel8/gce.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/gce.go index 7967e845e..35a2a2f93 100644 --- a/internal/distro/rhel8/gce.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/gce.go @@ -1,11 +1,11 @@ package rhel8 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) const gceKernelOptions = "net.ifnames=0 biosdevname=0 scsi_mod.use_blk_mq=Y crashkernel=auto console=ttyS0,38400n8d" diff --git a/internal/distro/rhel8/images.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/images.go similarity index 95% rename from internal/distro/rhel8/images.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/images.go index b0afc1ff7..eb69f4b8b 100644 --- a/internal/distro/rhel8/images.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/images.go @@ -4,20 +4,20 @@ import ( "fmt" "math/rand" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/fdo" - "github.com/osbuild/osbuild-composer/internal/ignition" - "github.com/osbuild/osbuild-composer/internal/image" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/oscap" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/users" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/fdo" + "github.com/osbuild/images/internal/ignition" + "github.com/osbuild/images/internal/oscap" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/image" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) func osCustomizations( diff --git a/internal/distro/rhel8/imagetype.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/imagetype.go similarity index 94% rename from internal/distro/rhel8/imagetype.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/imagetype.go index 2877e6b04..18cf849ab 100644 --- a/internal/distro/rhel8/imagetype.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/imagetype.go @@ -8,20 +8,20 @@ import ( "golang.org/x/exp/slices" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/image" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/oscap" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/pathpolicy" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/oscap" + "github.com/osbuild/images/internal/pathpolicy" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/image" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) const ( diff --git a/internal/distro/rhel8/package_sets.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/package_sets.go similarity index 92% rename from internal/distro/rhel8/package_sets.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/package_sets.go index 378563e26..daddb8da5 100644 --- a/internal/distro/rhel8/package_sets.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/package_sets.go @@ -5,8 +5,8 @@ package rhel8 import ( "fmt" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) // installer boot package sets, needed for booting and diff --git a/internal/distro/rhel8/partition_tables.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/partition_tables.go similarity index 97% rename from internal/distro/rhel8/partition_tables.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/partition_tables.go index 8e1236ed2..f85ace189 100644 --- a/internal/distro/rhel8/partition_tables.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/partition_tables.go @@ -1,10 +1,10 @@ package rhel8 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/platform" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/platform" ) var defaultBasePartitionTables = distro.BasePartitionTableMap{ diff --git a/internal/distro/rhel8/qcow2.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/qcow2.go similarity index 93% rename from internal/distro/rhel8/qcow2.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/qcow2.go index cb7e619fd..e9c27a9f7 100644 --- a/internal/distro/rhel8/qcow2.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/qcow2.go @@ -1,11 +1,11 @@ package rhel8 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) func qcow2ImgType(rd distribution) imageType { diff --git a/internal/distro/rhel8/sap.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/sap.go similarity index 94% rename from internal/distro/rhel8/sap.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/sap.go index 112596ec5..c55fb9275 100644 --- a/internal/distro/rhel8/sap.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/sap.go @@ -1,10 +1,10 @@ package rhel8 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" ) // sapImageConfig returns the SAP specific ImageConfig data diff --git a/internal/distro/rhel8/vmdk.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/vmdk.go similarity index 93% rename from internal/distro/rhel8/vmdk.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/vmdk.go index 0916b5f73..71a7b4f90 100644 --- a/internal/distro/rhel8/vmdk.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/vmdk.go @@ -1,8 +1,8 @@ package rhel8 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/rpmmd" ) const vmdkKernelOptions = "ro net.ifnames=0" diff --git a/internal/distro/rhel8/workloads.go b/vendor/github.com/osbuild/images/pkg/distro/rhel8/workloads.go similarity index 88% rename from internal/distro/rhel8/workloads.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel8/workloads.go index 5a6940c6e..ad6c7fb83 100644 --- a/internal/distro/rhel8/workloads.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel8/workloads.go @@ -1,6 +1,6 @@ package rhel8 -import "github.com/osbuild/osbuild-composer/internal/workload" +import "github.com/osbuild/images/internal/workload" // rhel8Workload is a RHEL-8-specific implementation of the workload interface // for internal workload variants. diff --git a/internal/distro/rhel9/ami.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/ami.go similarity index 97% rename from internal/distro/rhel9/ami.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/ami.go index 4c9d7c8aa..3fe5f94d7 100644 --- a/internal/distro/rhel9/ami.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/ami.go @@ -1,11 +1,11 @@ package rhel9 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) const amiKernelOptions = "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295" diff --git a/internal/distro/rhel9/arch.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/arch.go similarity index 93% rename from internal/distro/rhel9/arch.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/arch.go index a5da238fe..52e1f4de9 100644 --- a/internal/distro/rhel9/arch.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/arch.go @@ -5,8 +5,8 @@ import ( "fmt" "sort" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/platform" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/platform" ) type architecture struct { diff --git a/internal/distro/rhel9/azure.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/azure.go similarity index 97% rename from internal/distro/rhel9/azure.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/azure.go index 8395db8c5..e88d35c4c 100644 --- a/internal/distro/rhel9/azure.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/azure.go @@ -1,13 +1,13 @@ package rhel9 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) var ( diff --git a/internal/distro/rhel9/bare_metal.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/bare_metal.go similarity index 98% rename from internal/distro/rhel9/bare_metal.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/bare_metal.go index abcf8c326..156174f7b 100644 --- a/internal/distro/rhel9/bare_metal.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/bare_metal.go @@ -3,8 +3,8 @@ package rhel9 import ( "fmt" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) var ( diff --git a/internal/distro/rhel9/distro.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/distro.go similarity index 96% rename from internal/distro/rhel9/distro.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/distro.go index 814cbc76f..692c15c02 100644 --- a/internal/distro/rhel9/distro.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/distro.go @@ -6,12 +6,12 @@ import ( "sort" "strings" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/oscap" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/runner" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/oscap" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/runner" ) var ( diff --git a/internal/distro/rhel9/edge.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/edge.go similarity index 97% rename from internal/distro/rhel9/edge.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/edge.go index d6ec692eb..19a02b490 100644 --- a/internal/distro/rhel9/edge.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/edge.go @@ -3,12 +3,12 @@ package rhel9 import ( "fmt" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) var ( diff --git a/internal/distro/rhel9/gce.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/gce.go similarity index 96% rename from internal/distro/rhel9/gce.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/gce.go index 6a5c3d19f..2b739b749 100644 --- a/internal/distro/rhel9/gce.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/gce.go @@ -1,11 +1,11 @@ package rhel9 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) const gceKernelOptions = "net.ifnames=0 biosdevname=0 scsi_mod.use_blk_mq=Y console=ttyS0,38400n8d" diff --git a/internal/distro/rhel9/images.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/images.go similarity index 96% rename from internal/distro/rhel9/images.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/images.go index 5186ace2f..438ed039a 100644 --- a/internal/distro/rhel9/images.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/images.go @@ -4,20 +4,20 @@ import ( "fmt" "math/rand" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/fdo" - "github.com/osbuild/osbuild-composer/internal/ignition" - "github.com/osbuild/osbuild-composer/internal/image" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/oscap" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/users" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/fdo" + "github.com/osbuild/images/internal/ignition" + "github.com/osbuild/images/internal/oscap" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/image" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rpmmd" ) func osCustomizations( diff --git a/internal/distro/rhel9/imagetype.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/imagetype.go similarity index 94% rename from internal/distro/rhel9/imagetype.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/imagetype.go index 36e409bc0..a0f092de3 100644 --- a/internal/distro/rhel9/imagetype.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/imagetype.go @@ -8,20 +8,20 @@ import ( "golang.org/x/exp/slices" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/image" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/oscap" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/pathpolicy" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/oscap" + "github.com/osbuild/images/internal/pathpolicy" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/image" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) const ( diff --git a/internal/distro/rhel9/package_sets.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/package_sets.go similarity index 97% rename from internal/distro/rhel9/package_sets.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/package_sets.go index 4011974e4..e9f8a6a40 100644 --- a/internal/distro/rhel9/package_sets.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/package_sets.go @@ -5,8 +5,8 @@ package rhel9 import ( "fmt" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) // BUILD PACKAGE SETS diff --git a/internal/distro/rhel9/partition_tables.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/partition_tables.go similarity index 94% rename from internal/distro/rhel9/partition_tables.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/partition_tables.go index af1b42408..a4d726567 100644 --- a/internal/distro/rhel9/partition_tables.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/partition_tables.go @@ -1,10 +1,10 @@ package rhel9 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/platform" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/platform" ) var defaultBasePartitionTables = distro.BasePartitionTableMap{ diff --git a/internal/distro/rhel9/qcow2.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/qcow2.go similarity index 92% rename from internal/distro/rhel9/qcow2.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/qcow2.go index 03e96e9bb..892aeb23f 100644 --- a/internal/distro/rhel9/qcow2.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/qcow2.go @@ -1,12 +1,12 @@ package rhel9 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/subscription" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) var ( diff --git a/internal/distro/rhel9/sap.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/sap.go similarity index 95% rename from internal/distro/rhel9/sap.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/sap.go index c78b91fe1..d27206f83 100644 --- a/internal/distro/rhel9/sap.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/sap.go @@ -1,9 +1,9 @@ package rhel9 import ( - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/rpmmd" ) // sapImageConfig returns the SAP specific ImageConfig data diff --git a/internal/distro/rhel9/vmdk.go b/vendor/github.com/osbuild/images/pkg/distro/rhel9/vmdk.go similarity index 90% rename from internal/distro/rhel9/vmdk.go rename to vendor/github.com/osbuild/images/pkg/distro/rhel9/vmdk.go index d6400a313..10e597219 100644 --- a/internal/distro/rhel9/vmdk.go +++ b/vendor/github.com/osbuild/images/pkg/distro/rhel9/vmdk.go @@ -1,10 +1,10 @@ package rhel9 import ( - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) const vmdkKernelOptions = "ro net.ifnames=0" diff --git a/internal/distro/test_distro/distro.go b/vendor/github.com/osbuild/images/pkg/distro/test_distro/distro.go similarity index 95% rename from internal/distro/test_distro/distro.go rename to vendor/github.com/osbuild/images/pkg/distro/test_distro/distro.go index 681a82486..1d1a28cd2 100644 --- a/internal/distro/test_distro/distro.go +++ b/vendor/github.com/osbuild/images/pkg/distro/test_distro/distro.go @@ -6,14 +6,14 @@ import ( "fmt" "sort" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distroregistry" - "github.com/osbuild/osbuild-composer/internal/manifest" - dnfjson_mock "github.com/osbuild/osbuild-composer/internal/mocks/dnfjson" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + dnfjson_mock "github.com/osbuild/images/internal/mocks/dnfjson" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distroregistry" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rpmmd" ) const ( diff --git a/internal/distroregistry/distroregistry.go b/vendor/github.com/osbuild/images/pkg/distroregistry/distroregistry.go similarity index 90% rename from internal/distroregistry/distroregistry.go rename to vendor/github.com/osbuild/images/pkg/distroregistry/distroregistry.go index b2b43a37c..b58feda37 100644 --- a/internal/distroregistry/distroregistry.go +++ b/vendor/github.com/osbuild/images/pkg/distroregistry/distroregistry.go @@ -5,12 +5,12 @@ import ( "sort" "strings" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/distro" - "github.com/osbuild/osbuild-composer/internal/distro/fedora" - "github.com/osbuild/osbuild-composer/internal/distro/rhel7" - "github.com/osbuild/osbuild-composer/internal/distro/rhel8" - "github.com/osbuild/osbuild-composer/internal/distro/rhel9" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/distro" + "github.com/osbuild/images/pkg/distro/fedora" + "github.com/osbuild/images/pkg/distro/rhel7" + "github.com/osbuild/images/pkg/distro/rhel8" + "github.com/osbuild/images/pkg/distro/rhel9" ) // When adding support for a new distribution, add it here. diff --git a/internal/image/anaconda_live_installer.go b/vendor/github.com/osbuild/images/pkg/image/anaconda_live_installer.go similarity index 85% rename from internal/image/anaconda_live_installer.go rename to vendor/github.com/osbuild/images/pkg/image/anaconda_live_installer.go index e44d76385..2516b16af 100644 --- a/internal/image/anaconda_live_installer.go +++ b/vendor/github.com/osbuild/images/pkg/image/anaconda_live_installer.go @@ -4,15 +4,15 @@ import ( "fmt" "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) type AnacondaLiveInstaller struct { diff --git a/internal/image/anaconda_ostree_installer.go b/vendor/github.com/osbuild/images/pkg/image/anaconda_ostree_installer.go similarity index 88% rename from internal/image/anaconda_ostree_installer.go rename to vendor/github.com/osbuild/images/pkg/image/anaconda_ostree_installer.go index 0ba310927..9a9e75856 100644 --- a/internal/image/anaconda_ostree_installer.go +++ b/vendor/github.com/osbuild/images/pkg/image/anaconda_ostree_installer.go @@ -4,15 +4,15 @@ import ( "fmt" "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" - "github.com/osbuild/osbuild-composer/internal/users" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) type AnacondaOSTreeInstaller struct { diff --git a/internal/image/anaconda_tar_installer.go b/vendor/github.com/osbuild/images/pkg/image/anaconda_tar_installer.go similarity index 89% rename from internal/image/anaconda_tar_installer.go rename to vendor/github.com/osbuild/images/pkg/image/anaconda_tar_installer.go index e315537a0..5a0e2dd1d 100644 --- a/internal/image/anaconda_tar_installer.go +++ b/vendor/github.com/osbuild/images/pkg/image/anaconda_tar_installer.go @@ -5,16 +5,16 @@ import ( "math/rand" "path/filepath" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" - "github.com/osbuild/osbuild-composer/internal/users" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) const kspath = "/osbuild.ks" diff --git a/internal/image/archive.go b/vendor/github.com/osbuild/images/pkg/image/archive.go similarity index 70% rename from internal/image/archive.go rename to vendor/github.com/osbuild/images/pkg/image/archive.go index 9ba2e38a0..593aaff8a 100644 --- a/internal/image/archive.go +++ b/vendor/github.com/osbuild/images/pkg/image/archive.go @@ -3,13 +3,13 @@ package image import ( "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) type Archive struct { diff --git a/internal/image/container.go b/vendor/github.com/osbuild/images/pkg/image/container.go similarity index 71% rename from internal/image/container.go rename to vendor/github.com/osbuild/images/pkg/image/container.go index af53a3b7e..edce4a9a2 100644 --- a/internal/image/container.go +++ b/vendor/github.com/osbuild/images/pkg/image/container.go @@ -3,13 +3,13 @@ package image import ( "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) type BaseContainer struct { diff --git a/internal/image/image.go b/vendor/github.com/osbuild/images/pkg/image/image.go similarity index 62% rename from internal/image/image.go rename to vendor/github.com/osbuild/images/pkg/image/image.go index ddd16c04c..7693a2400 100644 --- a/internal/image/image.go +++ b/vendor/github.com/osbuild/images/pkg/image/image.go @@ -3,10 +3,10 @@ package image import ( "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) type ImageKind interface { diff --git a/internal/image/live.go b/vendor/github.com/osbuild/images/pkg/image/live.go similarity index 87% rename from internal/image/live.go rename to vendor/github.com/osbuild/images/pkg/image/live.go index a4a8f794e..8583aa2fa 100644 --- a/internal/image/live.go +++ b/vendor/github.com/osbuild/images/pkg/image/live.go @@ -4,16 +4,16 @@ import ( "fmt" "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) type LiveImage struct { diff --git a/internal/image/ostree_archive.go b/vendor/github.com/osbuild/images/pkg/image/ostree_archive.go similarity index 76% rename from internal/image/ostree_archive.go rename to vendor/github.com/osbuild/images/pkg/image/ostree_archive.go index d8ccb3615..ba888d76d 100644 --- a/internal/image/ostree_archive.go +++ b/vendor/github.com/osbuild/images/pkg/image/ostree_archive.go @@ -3,14 +3,14 @@ package image import ( "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) type OSTreeArchive struct { diff --git a/internal/image/ostree_container.go b/vendor/github.com/osbuild/images/pkg/image/ostree_container.go similarity index 81% rename from internal/image/ostree_container.go rename to vendor/github.com/osbuild/images/pkg/image/ostree_container.go index d9365e6f1..99d6dadca 100644 --- a/internal/image/ostree_container.go +++ b/vendor/github.com/osbuild/images/pkg/image/ostree_container.go @@ -3,14 +3,14 @@ package image import ( "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) type OSTreeContainer struct { diff --git a/internal/image/ostree_raw.go b/vendor/github.com/osbuild/images/pkg/image/ostree_raw.go similarity index 82% rename from internal/image/ostree_raw.go rename to vendor/github.com/osbuild/images/pkg/image/ostree_raw.go index 1b7bc6503..4059ab181 100644 --- a/internal/image/ostree_raw.go +++ b/vendor/github.com/osbuild/images/pkg/image/ostree_raw.go @@ -4,16 +4,16 @@ import ( "fmt" "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/fsnode" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" - "github.com/osbuild/osbuild-composer/internal/users" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/fsnode" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) type OSTreeRawImage struct { diff --git a/internal/image/ostree_simplified_installer.go b/vendor/github.com/osbuild/images/pkg/image/ostree_simplified_installer.go similarity index 87% rename from internal/image/ostree_simplified_installer.go rename to vendor/github.com/osbuild/images/pkg/image/ostree_simplified_installer.go index 9a8d90068..f7d714b0a 100644 --- a/internal/image/ostree_simplified_installer.go +++ b/vendor/github.com/osbuild/images/pkg/image/ostree_simplified_installer.go @@ -4,17 +4,17 @@ import ( "fmt" "math/rand" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/fdo" - "github.com/osbuild/osbuild-composer/internal/ignition" - "github.com/osbuild/osbuild-composer/internal/manifest" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/fdo" + "github.com/osbuild/images/internal/ignition" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/manifest" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) type OSTreeSimplifiedInstaller struct { diff --git a/internal/manifest/anaconda_installer.go b/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer.go similarity index 96% rename from internal/manifest/anaconda_installer.go rename to vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer.go index f08099b14..d15575383 100644 --- a/internal/manifest/anaconda_installer.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer.go @@ -4,13 +4,13 @@ import ( "fmt" "os" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/fsnode" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/users" + "github.com/osbuild/images/internal/fsnode" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) type AnacondaInstallerType int diff --git a/internal/manifest/anaconda_installer_iso_tree.go b/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer_iso_tree.go similarity index 96% rename from internal/manifest/anaconda_installer_iso_tree.go rename to vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer_iso_tree.go index a00472b9e..9f7c25ebe 100644 --- a/internal/manifest/anaconda_installer_iso_tree.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/anaconda_installer_iso_tree.go @@ -4,12 +4,12 @@ import ( "fmt" "path" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/users" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rpmmd" ) // An AnacondaInstallerISOTree represents a tree containing the anaconda installer, diff --git a/internal/manifest/build.go b/vendor/github.com/osbuild/images/pkg/manifest/build.go similarity index 92% rename from internal/manifest/build.go rename to vendor/github.com/osbuild/images/pkg/manifest/build.go index 36b3fa337..f147eb588 100644 --- a/internal/manifest/build.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/build.go @@ -1,11 +1,11 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/runner" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/runner" ) // A Build represents the build environment for other pipelines. As a diff --git a/internal/manifest/coi_iso_tree.go b/vendor/github.com/osbuild/images/pkg/manifest/coi_iso_tree.go similarity index 96% rename from internal/manifest/coi_iso_tree.go rename to vendor/github.com/osbuild/images/pkg/manifest/coi_iso_tree.go index 89093e842..38cee4200 100644 --- a/internal/manifest/coi_iso_tree.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/coi_iso_tree.go @@ -4,9 +4,9 @@ import ( "crypto/sha256" "fmt" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/users" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/osbuild" ) type CoreOSISOTree struct { diff --git a/internal/manifest/commit.go b/vendor/github.com/osbuild/images/pkg/manifest/commit.go similarity index 96% rename from internal/manifest/commit.go rename to vendor/github.com/osbuild/images/pkg/manifest/commit.go index b864eb0a0..89155c687 100644 --- a/internal/manifest/commit.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/commit.go @@ -1,7 +1,7 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/osbuild" + "github.com/osbuild/images/pkg/osbuild" ) // OSTreeCommit represents an ostree with one commit. diff --git a/internal/manifest/commit_server_tree.go b/vendor/github.com/osbuild/images/pkg/manifest/commit_server_tree.go similarity index 92% rename from internal/manifest/commit_server_tree.go rename to vendor/github.com/osbuild/images/pkg/manifest/commit_server_tree.go index ec7021bd5..c51ee2aa4 100644 --- a/internal/manifest/commit_server_tree.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/commit_server_tree.go @@ -3,12 +3,12 @@ package manifest import ( "path/filepath" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) // An OSTreeCommitServer contains an nginx server serving diff --git a/internal/manifest/coreos_installer.go b/vendor/github.com/osbuild/images/pkg/manifest/coreos_installer.go similarity index 92% rename from internal/manifest/coreos_installer.go rename to vendor/github.com/osbuild/images/pkg/manifest/coreos_installer.go index c7769b90e..d1ba436bb 100644 --- a/internal/manifest/coreos_installer.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/coreos_installer.go @@ -3,13 +3,13 @@ package manifest import ( "fmt" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/fdo" - "github.com/osbuild/osbuild-composer/internal/ignition" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/internal/fdo" + "github.com/osbuild/images/internal/ignition" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) type CoreOSInstaller struct { diff --git a/internal/manifest/efi_boot_tree.go b/vendor/github.com/osbuild/images/pkg/manifest/efi_boot_tree.go similarity index 91% rename from internal/manifest/efi_boot_tree.go rename to vendor/github.com/osbuild/images/pkg/manifest/efi_boot_tree.go index 2b2d0077e..7ba473ba6 100644 --- a/internal/manifest/efi_boot_tree.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/efi_boot_tree.go @@ -1,8 +1,8 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/platform" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" ) type EFIBootTree struct { diff --git a/internal/manifest/empty.go b/vendor/github.com/osbuild/images/pkg/manifest/empty.go similarity index 90% rename from internal/manifest/empty.go rename to vendor/github.com/osbuild/images/pkg/manifest/empty.go index b065dbbe6..71211cddc 100644 --- a/internal/manifest/empty.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/empty.go @@ -1,10 +1,10 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rpmmd" ) // A ContentTest can be used to define content sources without generating diff --git a/internal/manifest/iso.go b/vendor/github.com/osbuild/images/pkg/manifest/iso.go similarity index 93% rename from internal/manifest/iso.go rename to vendor/github.com/osbuild/images/pkg/manifest/iso.go index 22e68b278..937b3cb7c 100644 --- a/internal/manifest/iso.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/iso.go @@ -1,8 +1,8 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/osbuild" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/osbuild" ) // An ISO represents a bootable ISO file created from an diff --git a/internal/manifest/iso_rootfs.go b/vendor/github.com/osbuild/images/pkg/manifest/iso_rootfs.go similarity index 96% rename from internal/manifest/iso_rootfs.go rename to vendor/github.com/osbuild/images/pkg/manifest/iso_rootfs.go index edd9d4dc7..96f4f35f1 100644 --- a/internal/manifest/iso_rootfs.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/iso_rootfs.go @@ -3,7 +3,7 @@ package manifest import ( "fmt" - "github.com/osbuild/osbuild-composer/internal/osbuild" + "github.com/osbuild/images/pkg/osbuild" ) type ISORootfsImg struct { diff --git a/internal/manifest/manifest.go b/vendor/github.com/osbuild/images/pkg/manifest/manifest.go similarity index 96% rename from internal/manifest/manifest.go rename to vendor/github.com/osbuild/images/pkg/manifest/manifest.go index cd485b4fd..22770a6ea 100644 --- a/internal/manifest/manifest.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/manifest.go @@ -15,10 +15,10 @@ package manifest import ( "encoding/json" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rpmmd" ) type Arch uint64 diff --git a/internal/manifest/oci_container.go b/vendor/github.com/osbuild/images/pkg/manifest/oci_container.go similarity index 92% rename from internal/manifest/oci_container.go rename to vendor/github.com/osbuild/images/pkg/manifest/oci_container.go index 5bb523cc1..23d50c709 100644 --- a/internal/manifest/oci_container.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/oci_container.go @@ -1,8 +1,8 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/osbuild" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/osbuild" ) // An OCIContainer represents an OCI container, containing a filesystem diff --git a/internal/manifest/os.go b/vendor/github.com/osbuild/images/pkg/manifest/os.go similarity index 96% rename from internal/manifest/os.go rename to vendor/github.com/osbuild/images/pkg/manifest/os.go index 6c43cf27d..afb524bdc 100644 --- a/internal/manifest/os.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/os.go @@ -5,20 +5,20 @@ import ( "path/filepath" "strings" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/environment" - "github.com/osbuild/osbuild-composer/internal/fsnode" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rhsm/facts" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/shell" - "github.com/osbuild/osbuild-composer/internal/subscription" - "github.com/osbuild/osbuild-composer/internal/users" - "github.com/osbuild/osbuild-composer/internal/workload" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/environment" + "github.com/osbuild/images/internal/fsnode" + "github.com/osbuild/images/internal/shell" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/internal/workload" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rhsm/facts" + "github.com/osbuild/images/pkg/rpmmd" + "github.com/osbuild/images/pkg/subscription" ) // OSCustomizations encapsulates all configuration applied to the base diff --git a/internal/manifest/ostree_deployment.go b/vendor/github.com/osbuild/images/pkg/manifest/ostree_deployment.go similarity index 94% rename from internal/manifest/ostree_deployment.go rename to vendor/github.com/osbuild/images/pkg/manifest/ostree_deployment.go index f5fa06ef8..1d98e38d9 100644 --- a/internal/manifest/ostree_deployment.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/ostree_deployment.go @@ -4,15 +4,15 @@ import ( "os" "strings" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/disk" - "github.com/osbuild/osbuild-composer/internal/fsnode" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/users" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/internal/fsnode" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/disk" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) // OSTreeDeployment represents the filesystem tree of a target image based diff --git a/internal/manifest/ovf.go b/vendor/github.com/osbuild/images/pkg/manifest/ovf.go similarity index 95% rename from internal/manifest/ovf.go rename to vendor/github.com/osbuild/images/pkg/manifest/ovf.go index bc07c95e3..f4fedc7ce 100644 --- a/internal/manifest/ovf.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/ovf.go @@ -3,7 +3,7 @@ package manifest import ( "fmt" - "github.com/osbuild/osbuild-composer/internal/osbuild" + "github.com/osbuild/images/pkg/osbuild" ) // A OVF copies a vmdk image to it's own tree and generates an OVF descriptor diff --git a/internal/manifest/pipeline.go b/vendor/github.com/osbuild/images/pkg/manifest/pipeline.go similarity index 94% rename from internal/manifest/pipeline.go rename to vendor/github.com/osbuild/images/pkg/manifest/pipeline.go index f2a8b2d42..bf8743236 100644 --- a/internal/manifest/pipeline.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/pipeline.go @@ -1,12 +1,12 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/platform" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/platform" + "github.com/osbuild/images/pkg/rpmmd" ) // Pipeline serializes to a series of stages that modify a file system tree diff --git a/internal/manifest/qcow2.go b/vendor/github.com/osbuild/images/pkg/manifest/qcow2.go similarity index 92% rename from internal/manifest/qcow2.go rename to vendor/github.com/osbuild/images/pkg/manifest/qcow2.go index 526e0b5c0..75e81f57a 100644 --- a/internal/manifest/qcow2.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/qcow2.go @@ -1,8 +1,8 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/osbuild" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/osbuild" ) // A QCOW2 turns a raw image file into qcow2 image. diff --git a/internal/manifest/raw.go b/vendor/github.com/osbuild/images/pkg/manifest/raw.go similarity index 93% rename from internal/manifest/raw.go rename to vendor/github.com/osbuild/images/pkg/manifest/raw.go index b48783283..6efabe9f9 100644 --- a/internal/manifest/raw.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/raw.go @@ -1,9 +1,9 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/platform" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" ) // A RawImage represents a raw image file which can be booted in a diff --git a/internal/manifest/raw_ostree.go b/vendor/github.com/osbuild/images/pkg/manifest/raw_ostree.go similarity index 95% rename from internal/manifest/raw_ostree.go rename to vendor/github.com/osbuild/images/pkg/manifest/raw_ostree.go index dbc39c7b3..d29818abe 100644 --- a/internal/manifest/raw_ostree.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/raw_ostree.go @@ -3,9 +3,9 @@ package manifest import ( "fmt" - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/osbuild" - "github.com/osbuild/osbuild-composer/internal/platform" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/osbuild" + "github.com/osbuild/images/pkg/platform" ) // A RawOSTreeImage represents a raw ostree image file which can be booted in a diff --git a/internal/manifest/tar.go b/vendor/github.com/osbuild/images/pkg/manifest/tar.go similarity index 92% rename from internal/manifest/tar.go rename to vendor/github.com/osbuild/images/pkg/manifest/tar.go index ea78a56b1..7bf6aba1f 100644 --- a/internal/manifest/tar.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/tar.go @@ -1,8 +1,8 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/osbuild" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/osbuild" ) // A Tar represents the contents of another pipeline in a tar file diff --git a/internal/manifest/vmdk.go b/vendor/github.com/osbuild/images/pkg/manifest/vmdk.go similarity index 91% rename from internal/manifest/vmdk.go rename to vendor/github.com/osbuild/images/pkg/manifest/vmdk.go index 72e476d25..f82796634 100644 --- a/internal/manifest/vmdk.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/vmdk.go @@ -1,8 +1,8 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/osbuild" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/osbuild" ) // A VMDK turns a raw image file into vmdk image. diff --git a/internal/manifest/vpc.go b/vendor/github.com/osbuild/images/pkg/manifest/vpc.go similarity index 92% rename from internal/manifest/vpc.go rename to vendor/github.com/osbuild/images/pkg/manifest/vpc.go index fc9449165..0b816bcd0 100644 --- a/internal/manifest/vpc.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/vpc.go @@ -1,8 +1,8 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/osbuild" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/osbuild" ) // A VPC turns a raw image file into qemu-based image format, such as qcow2. diff --git a/internal/manifest/xz.go b/vendor/github.com/osbuild/images/pkg/manifest/xz.go similarity index 90% rename from internal/manifest/xz.go rename to vendor/github.com/osbuild/images/pkg/manifest/xz.go index 7d9b309c3..e4b9565a5 100644 --- a/internal/manifest/xz.go +++ b/vendor/github.com/osbuild/images/pkg/manifest/xz.go @@ -1,8 +1,8 @@ package manifest import ( - "github.com/osbuild/osbuild-composer/internal/artifact" - "github.com/osbuild/osbuild-composer/internal/osbuild" + "github.com/osbuild/images/pkg/artifact" + "github.com/osbuild/images/pkg/osbuild" ) // The XZ pipeline compresses a raw image file using xz. diff --git a/internal/osbuild/anaconda_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/anaconda_stage.go similarity index 100% rename from internal/osbuild/anaconda_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/anaconda_stage.go diff --git a/internal/osbuild/authconfig_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/authconfig_stage.go similarity index 100% rename from internal/osbuild/authconfig_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/authconfig_stage.go diff --git a/internal/osbuild/authselect_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/authselect_stage.go similarity index 100% rename from internal/osbuild/authselect_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/authselect_stage.go diff --git a/internal/osbuild/bootiso_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/bootiso_stage.go similarity index 100% rename from internal/osbuild/bootiso_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/bootiso_stage.go diff --git a/internal/osbuild/btrfs_mount.go b/vendor/github.com/osbuild/images/pkg/osbuild/btrfs_mount.go similarity index 100% rename from internal/osbuild/btrfs_mount.go rename to vendor/github.com/osbuild/images/pkg/osbuild/btrfs_mount.go diff --git a/internal/osbuild/buildstamp_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/buildstamp_stage.go similarity index 100% rename from internal/osbuild/buildstamp_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/buildstamp_stage.go diff --git a/internal/osbuild/chmod_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/chmod_stage.go similarity index 100% rename from internal/osbuild/chmod_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/chmod_stage.go diff --git a/internal/osbuild/chown_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/chown_stage.go similarity index 100% rename from internal/osbuild/chown_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/chown_stage.go diff --git a/internal/osbuild/chrony_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/chrony_stage.go similarity index 100% rename from internal/osbuild/chrony_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/chrony_stage.go diff --git a/internal/osbuild/clevis_luks_bind_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/clevis_luks_bind_stage.go similarity index 100% rename from internal/osbuild/clevis_luks_bind_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/clevis_luks_bind_stage.go diff --git a/internal/osbuild/cloud_init_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/cloud_init_stage.go similarity index 100% rename from internal/osbuild/cloud_init_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/cloud_init_stage.go diff --git a/internal/osbuild/containers_input.go b/vendor/github.com/osbuild/images/pkg/osbuild/containers_input.go similarity index 94% rename from internal/osbuild/containers_input.go rename to vendor/github.com/osbuild/images/pkg/osbuild/containers_input.go index c1803fa90..c0243672b 100644 --- a/internal/osbuild/containers_input.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/containers_input.go @@ -1,7 +1,7 @@ package osbuild import ( - "github.com/osbuild/osbuild-composer/internal/container" + "github.com/osbuild/images/pkg/container" ) type ContainersInputReferences interface { diff --git a/internal/osbuild/containers_storage_conf_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/containers_storage_conf_stage.go similarity index 100% rename from internal/osbuild/containers_storage_conf_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/containers_storage_conf_stage.go diff --git a/internal/osbuild/copy_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/copy_stage.go similarity index 98% rename from internal/osbuild/copy_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/copy_stage.go index 73388240a..8fc41e50f 100644 --- a/internal/osbuild/copy_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/copy_stage.go @@ -4,7 +4,7 @@ import ( "fmt" "sort" - "github.com/osbuild/osbuild-composer/internal/disk" + "github.com/osbuild/images/pkg/disk" ) // Stage to copy items from inputs to mount points or the tree. Multiple items diff --git a/internal/osbuild/curl_source.go b/vendor/github.com/osbuild/images/pkg/osbuild/curl_source.go similarity index 100% rename from internal/osbuild/curl_source.go rename to vendor/github.com/osbuild/images/pkg/osbuild/curl_source.go diff --git a/internal/osbuild/device.go b/vendor/github.com/osbuild/images/pkg/osbuild/device.go similarity index 99% rename from internal/osbuild/device.go rename to vendor/github.com/osbuild/images/pkg/osbuild/device.go index 942cd4ba4..66d651a7b 100644 --- a/internal/osbuild/device.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/device.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/osbuild/osbuild-composer/internal/disk" + "github.com/osbuild/images/pkg/disk" ) type Devices map[string]Device diff --git a/internal/osbuild/discinfo_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/discinfo_stage.go similarity index 100% rename from internal/osbuild/discinfo_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/discinfo_stage.go diff --git a/internal/osbuild/disk.go b/vendor/github.com/osbuild/images/pkg/osbuild/disk.go similarity index 98% rename from internal/osbuild/disk.go rename to vendor/github.com/osbuild/images/pkg/osbuild/disk.go index ad165eb3c..2ffe5a831 100644 --- a/internal/osbuild/disk.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/disk.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/google/uuid" - "github.com/osbuild/osbuild-composer/internal/disk" + "github.com/osbuild/images/pkg/disk" ) // sfdiskStageOptions creates the options and devices properties for an diff --git a/internal/osbuild/dnf_automatic_config_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/dnf_automatic_config_stage.go similarity index 100% rename from internal/osbuild/dnf_automatic_config_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/dnf_automatic_config_stage.go diff --git a/internal/osbuild/dnf_config_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/dnf_config_stage.go similarity index 100% rename from internal/osbuild/dnf_config_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/dnf_config_stage.go diff --git a/internal/osbuild/dracut_conf_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/dracut_conf_stage.go similarity index 100% rename from internal/osbuild/dracut_conf_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/dracut_conf_stage.go diff --git a/internal/osbuild/dracut_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/dracut_stage.go similarity index 100% rename from internal/osbuild/dracut_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/dracut_stage.go diff --git a/internal/osbuild/ext4_mount.go b/vendor/github.com/osbuild/images/pkg/osbuild/ext4_mount.go similarity index 100% rename from internal/osbuild/ext4_mount.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ext4_mount.go diff --git a/internal/osbuild/fat_mount.go b/vendor/github.com/osbuild/images/pkg/osbuild/fat_mount.go similarity index 100% rename from internal/osbuild/fat_mount.go rename to vendor/github.com/osbuild/images/pkg/osbuild/fat_mount.go diff --git a/internal/osbuild/fdo_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/fdo_stage.go similarity index 100% rename from internal/osbuild/fdo_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/fdo_stage.go diff --git a/internal/osbuild/files_input.go b/vendor/github.com/osbuild/images/pkg/osbuild/files_input.go similarity index 99% rename from internal/osbuild/files_input.go rename to vendor/github.com/osbuild/images/pkg/osbuild/files_input.go index 0b613471f..6490943d8 100644 --- a/internal/osbuild/files_input.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/files_input.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/osbuild/osbuild-composer/internal/container" + "github.com/osbuild/images/pkg/container" ) // SPECIFIC INPUT STRUCTURE diff --git a/internal/osbuild/firewall_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/firewall_stage.go similarity index 100% rename from internal/osbuild/firewall_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/firewall_stage.go diff --git a/internal/osbuild/first_boot_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/first_boot_stage.go similarity index 100% rename from internal/osbuild/first_boot_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/first_boot_stage.go diff --git a/internal/osbuild/fix_bls_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/fix_bls_stage.go similarity index 100% rename from internal/osbuild/fix_bls_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/fix_bls_stage.go diff --git a/internal/osbuild/fsnode.go b/vendor/github.com/osbuild/images/pkg/osbuild/fsnode.go similarity index 98% rename from internal/osbuild/fsnode.go rename to vendor/github.com/osbuild/images/pkg/osbuild/fsnode.go index 922cab20b..9345f82c6 100644 --- a/internal/osbuild/fsnode.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/fsnode.go @@ -4,7 +4,7 @@ import ( "crypto/sha256" "fmt" - "github.com/osbuild/osbuild-composer/internal/fsnode" + "github.com/osbuild/images/internal/fsnode" ) // GenFileNodesStages generates the stages for a list of file nodes. diff --git a/internal/osbuild/fstab_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/fstab_stage.go similarity index 97% rename from internal/osbuild/fstab_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/fstab_stage.go index d0cc66a22..09c913988 100644 --- a/internal/osbuild/fstab_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/fstab_stage.go @@ -4,7 +4,7 @@ import ( "fmt" "sort" - "github.com/osbuild/osbuild-composer/internal/disk" + "github.com/osbuild/images/pkg/disk" ) // The FSTabStageOptions describe the content of the /etc/fstab file. diff --git a/internal/osbuild/gcp_guest_agent_conf_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/gcp_guest_agent_conf_stage.go similarity index 100% rename from internal/osbuild/gcp_guest_agent_conf_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/gcp_guest_agent_conf_stage.go diff --git a/internal/osbuild/groups_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/groups_stage.go similarity index 94% rename from internal/osbuild/groups_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/groups_stage.go index 4b12ae7e3..97350807b 100644 --- a/internal/osbuild/groups_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/groups_stage.go @@ -1,7 +1,7 @@ package osbuild import ( - "github.com/osbuild/osbuild-composer/internal/users" + "github.com/osbuild/images/internal/users" ) type GroupsStageOptions struct { diff --git a/internal/osbuild/grub2_inst_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/grub2_inst_stage.go similarity index 98% rename from internal/osbuild/grub2_inst_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/grub2_inst_stage.go index b1a408ac6..f0fac27f3 100644 --- a/internal/osbuild/grub2_inst_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/grub2_inst_stage.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/osbuild/osbuild-composer/internal/disk" + "github.com/osbuild/images/pkg/disk" ) // Install the grub2 boot loader for non-UEFI systems or hybrid boot diff --git a/internal/osbuild/grub2_legacy_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/grub2_legacy_stage.go similarity index 97% rename from internal/osbuild/grub2_legacy_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/grub2_legacy_stage.go index b41d2a265..6e37c40dd 100644 --- a/internal/osbuild/grub2_legacy_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/grub2_legacy_stage.go @@ -6,8 +6,8 @@ import ( "github.com/google/uuid" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/disk" ) type GRUB2FSDesc struct { diff --git a/internal/osbuild/grub2_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/grub2_stage.go similarity index 96% rename from internal/osbuild/grub2_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/grub2_stage.go index bebee052b..ec8da6b89 100644 --- a/internal/osbuild/grub2_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/grub2_stage.go @@ -3,9 +3,9 @@ package osbuild import ( "github.com/google/uuid" - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/disk" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/blueprint" + "github.com/osbuild/images/pkg/disk" ) // The GRUB2StageOptions describes the bootloader configuration. diff --git a/internal/osbuild/grub_iso_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/grub_iso_stage.go similarity index 100% rename from internal/osbuild/grub_iso_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/grub_iso_stage.go diff --git a/internal/osbuild/hostname_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/hostname_stage.go similarity index 100% rename from internal/osbuild/hostname_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/hostname_stage.go diff --git a/internal/osbuild/ignition_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ignition_stage.go similarity index 100% rename from internal/osbuild/ignition_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ignition_stage.go diff --git a/internal/osbuild/implantisomd5_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/implantisomd5_stage.go similarity index 100% rename from internal/osbuild/implantisomd5_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/implantisomd5_stage.go diff --git a/internal/osbuild/inline_source.go b/vendor/github.com/osbuild/images/pkg/osbuild/inline_source.go similarity index 100% rename from internal/osbuild/inline_source.go rename to vendor/github.com/osbuild/images/pkg/osbuild/inline_source.go diff --git a/internal/osbuild/input.go b/vendor/github.com/osbuild/images/pkg/osbuild/input.go similarity index 100% rename from internal/osbuild/input.go rename to vendor/github.com/osbuild/images/pkg/osbuild/input.go diff --git a/internal/osbuild/isolinux_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/isolinux_stage.go similarity index 100% rename from internal/osbuild/isolinux_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/isolinux_stage.go diff --git a/internal/osbuild/kernel_cmdline_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/kernel_cmdline_stage.go similarity index 100% rename from internal/osbuild/kernel_cmdline_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/kernel_cmdline_stage.go diff --git a/internal/osbuild/keymap_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/keymap_stage.go similarity index 100% rename from internal/osbuild/keymap_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/keymap_stage.go diff --git a/internal/osbuild/kickstart_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/kickstart_stage.go similarity index 96% rename from internal/osbuild/kickstart_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/kickstart_stage.go index e09bf77fa..0f41baca5 100644 --- a/internal/osbuild/kickstart_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/kickstart_stage.go @@ -1,6 +1,6 @@ package osbuild -import "github.com/osbuild/osbuild-composer/internal/users" +import "github.com/osbuild/images/internal/users" type KickstartStageOptions struct { // Where to place the kickstart file diff --git a/internal/osbuild/locale_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/locale_stage.go similarity index 100% rename from internal/osbuild/locale_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/locale_stage.go diff --git a/internal/osbuild/loopback_device.go b/vendor/github.com/osbuild/images/pkg/osbuild/loopback_device.go similarity index 100% rename from internal/osbuild/loopback_device.go rename to vendor/github.com/osbuild/images/pkg/osbuild/loopback_device.go diff --git a/internal/osbuild/lorax_script_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/lorax_script_stage.go similarity index 100% rename from internal/osbuild/lorax_script_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/lorax_script_stage.go diff --git a/internal/osbuild/luks2_device.go b/vendor/github.com/osbuild/images/pkg/osbuild/luks2_device.go similarity index 100% rename from internal/osbuild/luks2_device.go rename to vendor/github.com/osbuild/images/pkg/osbuild/luks2_device.go diff --git a/internal/osbuild/luks2_format_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/luks2_format_stage.go similarity index 100% rename from internal/osbuild/luks2_format_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/luks2_format_stage.go diff --git a/internal/osbuild/luks2_remove_key_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/luks2_remove_key_stage.go similarity index 100% rename from internal/osbuild/luks2_remove_key_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/luks2_remove_key_stage.go diff --git a/internal/osbuild/lvm2_create_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/lvm2_create_stage.go similarity index 100% rename from internal/osbuild/lvm2_create_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/lvm2_create_stage.go diff --git a/internal/osbuild/lvm2_lv_device.go b/vendor/github.com/osbuild/images/pkg/osbuild/lvm2_lv_device.go similarity index 100% rename from internal/osbuild/lvm2_lv_device.go rename to vendor/github.com/osbuild/images/pkg/osbuild/lvm2_lv_device.go diff --git a/internal/osbuild/lvm2_metadata_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/lvm2_metadata_stage.go similarity index 100% rename from internal/osbuild/lvm2_metadata_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/lvm2_metadata_stage.go diff --git a/internal/osbuild/mkdir_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/mkdir_stage.go similarity index 100% rename from internal/osbuild/mkdir_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/mkdir_stage.go diff --git a/internal/osbuild/mkfs_btrfs_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/mkfs_btrfs_stage.go similarity index 100% rename from internal/osbuild/mkfs_btrfs_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/mkfs_btrfs_stage.go diff --git a/internal/osbuild/mkfs_ext4_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/mkfs_ext4_stage.go similarity index 100% rename from internal/osbuild/mkfs_ext4_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/mkfs_ext4_stage.go diff --git a/internal/osbuild/mkfs_fat_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/mkfs_fat_stage.go similarity index 100% rename from internal/osbuild/mkfs_fat_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/mkfs_fat_stage.go diff --git a/internal/osbuild/mkfs_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/mkfs_stage.go similarity index 97% rename from internal/osbuild/mkfs_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/mkfs_stage.go index 86f06bb8c..6120d7671 100644 --- a/internal/osbuild/mkfs_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/mkfs_stage.go @@ -3,7 +3,7 @@ package osbuild import ( "strings" - "github.com/osbuild/osbuild-composer/internal/disk" + "github.com/osbuild/images/pkg/disk" ) // GenMkfsStages generates a list of org.mkfs.* stages based on a diff --git a/internal/osbuild/mkfs_xfs_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/mkfs_xfs_stage.go similarity index 100% rename from internal/osbuild/mkfs_xfs_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/mkfs_xfs_stage.go diff --git a/internal/osbuild/modprobe_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/modprobe_stage.go similarity index 100% rename from internal/osbuild/modprobe_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/modprobe_stage.go diff --git a/internal/osbuild/mount.go b/vendor/github.com/osbuild/images/pkg/osbuild/mount.go similarity index 100% rename from internal/osbuild/mount.go rename to vendor/github.com/osbuild/images/pkg/osbuild/mount.go diff --git a/internal/osbuild/nginxconf_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/nginxconf_stage.go similarity index 100% rename from internal/osbuild/nginxconf_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/nginxconf_stage.go diff --git a/internal/osbuild/oci_archive_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/oci_archive_stage.go similarity index 100% rename from internal/osbuild/oci_archive_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/oci_archive_stage.go diff --git a/internal/osbuild/osbuild-exec.go b/vendor/github.com/osbuild/images/pkg/osbuild/osbuild-exec.go similarity index 100% rename from internal/osbuild/osbuild-exec.go rename to vendor/github.com/osbuild/images/pkg/osbuild/osbuild-exec.go diff --git a/internal/osbuild/osbuild.go b/vendor/github.com/osbuild/images/pkg/osbuild/osbuild.go similarity index 100% rename from internal/osbuild/osbuild.go rename to vendor/github.com/osbuild/images/pkg/osbuild/osbuild.go diff --git a/internal/osbuild/oscap_remediation_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/oscap_remediation_stage.go similarity index 100% rename from internal/osbuild/oscap_remediation_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/oscap_remediation_stage.go diff --git a/internal/osbuild/ostree_commit_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_commit_stage.go similarity index 100% rename from internal/osbuild/ostree_commit_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_commit_stage.go diff --git a/internal/osbuild/ostree_config_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_config_stage.go similarity index 100% rename from internal/osbuild/ostree_config_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_config_stage.go diff --git a/internal/osbuild/ostree_deploy_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_deploy_stage.go similarity index 100% rename from internal/osbuild/ostree_deploy_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_deploy_stage.go diff --git a/internal/osbuild/ostree_deployment_mount.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_deployment_mount.go similarity index 100% rename from internal/osbuild/ostree_deployment_mount.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_deployment_mount.go diff --git a/internal/osbuild/ostree_fillvar_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_fillvar_stage.go similarity index 100% rename from internal/osbuild/ostree_fillvar_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_fillvar_stage.go diff --git a/internal/osbuild/ostree_init_fs_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_init_fs_stage.go similarity index 100% rename from internal/osbuild/ostree_init_fs_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_init_fs_stage.go diff --git a/internal/osbuild/ostree_init_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_init_stage.go similarity index 100% rename from internal/osbuild/ostree_init_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_init_stage.go diff --git a/internal/osbuild/ostree_input.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_input.go similarity index 100% rename from internal/osbuild/ostree_input.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_input.go diff --git a/internal/osbuild/ostree_os_init_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_os_init_stage.go similarity index 100% rename from internal/osbuild/ostree_os_init_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_os_init_stage.go diff --git a/internal/osbuild/ostree_passwd_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_passwd_stage.go similarity index 100% rename from internal/osbuild/ostree_passwd_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_passwd_stage.go diff --git a/internal/osbuild/ostree_preptree_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_preptree_stage.go similarity index 100% rename from internal/osbuild/ostree_preptree_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_preptree_stage.go diff --git a/internal/osbuild/ostree_pull_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_pull_stage.go similarity index 100% rename from internal/osbuild/ostree_pull_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_pull_stage.go diff --git a/internal/osbuild/ostree_remotes_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_remotes_stage.go similarity index 100% rename from internal/osbuild/ostree_remotes_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_remotes_stage.go diff --git a/internal/osbuild/ostree_selinux_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_selinux_stage.go similarity index 100% rename from internal/osbuild/ostree_selinux_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_selinux_stage.go diff --git a/internal/osbuild/ostree_source.go b/vendor/github.com/osbuild/images/pkg/osbuild/ostree_source.go similarity index 100% rename from internal/osbuild/ostree_source.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ostree_source.go diff --git a/internal/osbuild/ovf_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/ovf_stage.go similarity index 100% rename from internal/osbuild/ovf_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/ovf_stage.go diff --git a/internal/osbuild/pam_limits_conf_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/pam_limits_conf_stage.go similarity index 100% rename from internal/osbuild/pam_limits_conf_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/pam_limits_conf_stage.go diff --git a/internal/osbuild/pwquality_conf_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/pwquality_conf_stage.go similarity index 100% rename from internal/osbuild/pwquality_conf_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/pwquality_conf_stage.go diff --git a/internal/osbuild/qemu_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/qemu_stage.go similarity index 100% rename from internal/osbuild/qemu_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/qemu_stage.go diff --git a/internal/osbuild/result.go b/vendor/github.com/osbuild/images/pkg/osbuild/result.go similarity index 100% rename from internal/osbuild/result.go rename to vendor/github.com/osbuild/images/pkg/osbuild/result.go diff --git a/internal/osbuild/result_test_data.go b/vendor/github.com/osbuild/images/pkg/osbuild/result_test_data.go similarity index 100% rename from internal/osbuild/result_test_data.go rename to vendor/github.com/osbuild/images/pkg/osbuild/result_test_data.go diff --git a/internal/osbuild/rhsm_facts_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/rhsm_facts_stage.go similarity index 100% rename from internal/osbuild/rhsm_facts_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/rhsm_facts_stage.go diff --git a/internal/osbuild/rhsm_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/rhsm_stage.go similarity index 100% rename from internal/osbuild/rhsm_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/rhsm_stage.go diff --git a/internal/osbuild/rpm_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/rpm_stage.go similarity index 98% rename from internal/osbuild/rpm_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/rpm_stage.go index 02bbf9fa7..3dc7fdb4d 100644 --- a/internal/osbuild/rpm_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/rpm_stage.go @@ -1,7 +1,7 @@ package osbuild import ( - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/rpmmd" ) type RPMStageOptions struct { diff --git a/internal/osbuild/script_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/script_stage.go similarity index 100% rename from internal/osbuild/script_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/script_stage.go diff --git a/internal/osbuild/selinux_config_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/selinux_config_stage.go similarity index 100% rename from internal/osbuild/selinux_config_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/selinux_config_stage.go diff --git a/internal/osbuild/selinux_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/selinux_stage.go similarity index 100% rename from internal/osbuild/selinux_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/selinux_stage.go diff --git a/internal/osbuild/sfdisk_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/sfdisk_stage.go similarity index 100% rename from internal/osbuild/sfdisk_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/sfdisk_stage.go diff --git a/internal/osbuild/sgdisk_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/sgdisk_stage.go similarity index 100% rename from internal/osbuild/sgdisk_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/sgdisk_stage.go diff --git a/internal/osbuild/shell_init_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/shell_init_stage.go similarity index 97% rename from internal/osbuild/shell_init_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/shell_init_stage.go index f007f35ef..f3cfdf6a8 100644 --- a/internal/osbuild/shell_init_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/shell_init_stage.go @@ -4,7 +4,7 @@ import ( "fmt" "regexp" - "github.com/osbuild/osbuild-composer/internal/shell" + "github.com/osbuild/images/internal/shell" ) const filenameRegex = "^[a-zA-Z0-9\\.\\-_]{1,250}$" diff --git a/internal/osbuild/skopeo_index_source.go b/vendor/github.com/osbuild/images/pkg/osbuild/skopeo_index_source.go similarity index 100% rename from internal/osbuild/skopeo_index_source.go rename to vendor/github.com/osbuild/images/pkg/osbuild/skopeo_index_source.go diff --git a/internal/osbuild/skopeo_source.go b/vendor/github.com/osbuild/images/pkg/osbuild/skopeo_source.go similarity index 100% rename from internal/osbuild/skopeo_source.go rename to vendor/github.com/osbuild/images/pkg/osbuild/skopeo_source.go diff --git a/internal/osbuild/skopeo_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/skopeo_stage.go similarity index 100% rename from internal/osbuild/skopeo_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/skopeo_stage.go diff --git a/internal/osbuild/source.go b/vendor/github.com/osbuild/images/pkg/osbuild/source.go similarity index 94% rename from internal/osbuild/source.go rename to vendor/github.com/osbuild/images/pkg/osbuild/source.go index 862a5c3f1..98a057b0f 100644 --- a/internal/osbuild/source.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/source.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" - "github.com/osbuild/osbuild-composer/internal/container" - "github.com/osbuild/osbuild-composer/internal/ostree" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/ostree" + "github.com/osbuild/images/pkg/rpmmd" ) // A Sources map contains all the sources made available to an osbuild run diff --git a/internal/osbuild/squashfs_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/squashfs_stage.go similarity index 100% rename from internal/osbuild/squashfs_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/squashfs_stage.go diff --git a/internal/osbuild/sshd_config_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/sshd_config_stage.go similarity index 100% rename from internal/osbuild/sshd_config_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/sshd_config_stage.go diff --git a/internal/osbuild/stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/stage.go similarity index 100% rename from internal/osbuild/stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/stage.go diff --git a/internal/osbuild/sysconfig_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/sysconfig_stage.go similarity index 100% rename from internal/osbuild/sysconfig_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/sysconfig_stage.go diff --git a/internal/osbuild/sysctld_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/sysctld_stage.go similarity index 100% rename from internal/osbuild/sysctld_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/sysctld_stage.go diff --git a/internal/osbuild/systemd_journald_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/systemd_journald_stage.go similarity index 100% rename from internal/osbuild/systemd_journald_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/systemd_journald_stage.go diff --git a/internal/osbuild/systemd_logind_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/systemd_logind_stage.go similarity index 100% rename from internal/osbuild/systemd_logind_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/systemd_logind_stage.go diff --git a/internal/osbuild/systemd_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/systemd_stage.go similarity index 100% rename from internal/osbuild/systemd_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/systemd_stage.go diff --git a/internal/osbuild/systemd_unit_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/systemd_unit_stage.go similarity index 100% rename from internal/osbuild/systemd_unit_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/systemd_unit_stage.go diff --git a/internal/osbuild/tar_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/tar_stage.go similarity index 100% rename from internal/osbuild/tar_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/tar_stage.go diff --git a/internal/osbuild/timezone_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/timezone_stage.go similarity index 100% rename from internal/osbuild/timezone_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/timezone_stage.go diff --git a/internal/osbuild/tmpfilesd_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/tmpfilesd_stage.go similarity index 100% rename from internal/osbuild/tmpfilesd_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/tmpfilesd_stage.go diff --git a/internal/osbuild/tree_input.go b/vendor/github.com/osbuild/images/pkg/osbuild/tree_input.go similarity index 100% rename from internal/osbuild/tree_input.go rename to vendor/github.com/osbuild/images/pkg/osbuild/tree_input.go diff --git a/internal/osbuild/truncate_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/truncate_stage.go similarity index 100% rename from internal/osbuild/truncate_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/truncate_stage.go diff --git a/internal/osbuild/tuned_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/tuned_stage.go similarity index 100% rename from internal/osbuild/tuned_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/tuned_stage.go diff --git a/internal/osbuild/udev_rules_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/udev_rules_stage.go similarity index 95% rename from internal/osbuild/udev_rules_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/udev_rules_stage.go index 4dc9cca21..e4bfaca40 100644 --- a/internal/osbuild/udev_rules_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/udev_rules_stage.go @@ -218,10 +218,10 @@ type UdevKV struct { V string // Value, e.g. "1" } -//NewUdevRule creates a new UdevRule from a list of UdevKV -//helper structs. A UdevOpSimple or a UdevOpArg is created -//depending on the value of the `A` field. The result is -//validated and the function will panic if validation fails. +// NewUdevRule creates a new UdevRule from a list of UdevKV +// helper structs. A UdevOpSimple or a UdevOpArg is created +// depending on the value of the `A` field. The result is +// validated and the function will panic if validation fails. func NewUdevRule(ops []UdevKV) UdevRule { res := make(UdevOps, 0, len(ops)) diff --git a/internal/osbuild/users_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/users_stage.go similarity index 96% rename from internal/osbuild/users_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/users_stage.go index 70e2ff436..cd9f77d02 100644 --- a/internal/osbuild/users_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/users_stage.go @@ -1,8 +1,8 @@ package osbuild import ( - "github.com/osbuild/osbuild-composer/internal/crypt" - "github.com/osbuild/osbuild-composer/internal/users" + "github.com/osbuild/images/internal/users" + "github.com/osbuild/images/pkg/crypt" ) type UsersStageOptions struct { diff --git a/internal/osbuild/v1result.go b/vendor/github.com/osbuild/images/pkg/osbuild/v1result.go similarity index 100% rename from internal/osbuild/v1result.go rename to vendor/github.com/osbuild/images/pkg/osbuild/v1result.go diff --git a/internal/osbuild/waagent_conf.go b/vendor/github.com/osbuild/images/pkg/osbuild/waagent_conf.go similarity index 100% rename from internal/osbuild/waagent_conf.go rename to vendor/github.com/osbuild/images/pkg/osbuild/waagent_conf.go diff --git a/internal/osbuild/xfs_mount.go b/vendor/github.com/osbuild/images/pkg/osbuild/xfs_mount.go similarity index 100% rename from internal/osbuild/xfs_mount.go rename to vendor/github.com/osbuild/images/pkg/osbuild/xfs_mount.go diff --git a/internal/osbuild/xorrisofs_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/xorrisofs_stage.go similarity index 100% rename from internal/osbuild/xorrisofs_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/xorrisofs_stage.go diff --git a/internal/osbuild/xz_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/xz_stage.go similarity index 100% rename from internal/osbuild/xz_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/xz_stage.go diff --git a/internal/osbuild/yum_config_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/yum_config_stage.go similarity index 100% rename from internal/osbuild/yum_config_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/yum_config_stage.go diff --git a/internal/osbuild/yum_repos_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/yum_repos_stage.go similarity index 97% rename from internal/osbuild/yum_repos_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/yum_repos_stage.go index 4662edd18..297811865 100644 --- a/internal/osbuild/yum_repos_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/yum_repos_stage.go @@ -4,8 +4,8 @@ import ( "fmt" "regexp" - "github.com/osbuild/osbuild-composer/internal/common" - "github.com/osbuild/osbuild-composer/internal/rpmmd" + "github.com/osbuild/images/internal/common" + "github.com/osbuild/images/pkg/rpmmd" ) const repoFilenameRegex = "^[\\w.-]{1,250}\\.repo$" diff --git a/internal/osbuild/zipl_inst_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/zipl_inst_stage.go similarity index 96% rename from internal/osbuild/zipl_inst_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/zipl_inst_stage.go index cdf03221d..f65f60e45 100644 --- a/internal/osbuild/zipl_inst_stage.go +++ b/vendor/github.com/osbuild/images/pkg/osbuild/zipl_inst_stage.go @@ -1,6 +1,6 @@ package osbuild -import "github.com/osbuild/osbuild-composer/internal/disk" +import "github.com/osbuild/images/pkg/disk" // Install the Z Initial Program Loader diff --git a/internal/osbuild/zipl_stage.go b/vendor/github.com/osbuild/images/pkg/osbuild/zipl_stage.go similarity index 100% rename from internal/osbuild/zipl_stage.go rename to vendor/github.com/osbuild/images/pkg/osbuild/zipl_stage.go diff --git a/internal/ostree/errors.go b/vendor/github.com/osbuild/images/pkg/ostree/errors.go similarity index 100% rename from internal/ostree/errors.go rename to vendor/github.com/osbuild/images/pkg/ostree/errors.go diff --git a/internal/ostree/mock_ostree_repo/mock_repo.go b/vendor/github.com/osbuild/images/pkg/ostree/mock_ostree_repo/mock_repo.go similarity index 100% rename from internal/ostree/mock_ostree_repo/mock_repo.go rename to vendor/github.com/osbuild/images/pkg/ostree/mock_ostree_repo/mock_repo.go diff --git a/internal/ostree/ostree.go b/vendor/github.com/osbuild/images/pkg/ostree/ostree.go similarity index 99% rename from internal/ostree/ostree.go rename to vendor/github.com/osbuild/images/pkg/ostree/ostree.go index b9ba88f4d..c2e9b2f8c 100644 --- a/internal/ostree/ostree.go +++ b/vendor/github.com/osbuild/images/pkg/ostree/ostree.go @@ -14,7 +14,7 @@ import ( "strings" "time" - "github.com/osbuild/osbuild-composer/internal/rhsm" + "github.com/osbuild/images/pkg/rhsm" ) var ostreeRefRE = regexp.MustCompile(`^(?:[\w\d][-._\w\d]*\/)*[\w\d][-._\w\d]*$`) diff --git a/vendor/github.com/osbuild/images/pkg/platform/aarch64.go b/vendor/github.com/osbuild/images/pkg/platform/aarch64.go new file mode 100644 index 000000000..2e8b81cd6 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/platform/aarch64.go @@ -0,0 +1,62 @@ +package platform + +type Aarch64 struct { + BasePlatform + UEFIVendor string +} + +func (p *Aarch64) GetArch() Arch { + return ARCH_AARCH64 +} + +func (p *Aarch64) GetUEFIVendor() string { + return p.UEFIVendor +} + +func (p *Aarch64) GetPackages() []string { + packages := p.BasePlatform.FirmwarePackages + + if p.UEFIVendor != "" { + packages = append(packages, + "dracut-config-generic", + "efibootmgr", + "grub2-efi-aa64", + "grub2-tools", + "shim-aa64") + } + + return packages +} + +type Aarch64_IoT struct { + BasePlatform + UEFIVendor string + BootFiles [][2]string +} + +func (p *Aarch64_IoT) GetArch() Arch { + return ARCH_AARCH64 +} + +func (p *Aarch64_IoT) GetUEFIVendor() string { + return p.UEFIVendor +} + +func (p *Aarch64_IoT) GetPackages() []string { + packages := p.BasePlatform.FirmwarePackages + + if p.UEFIVendor != "" { + packages = append(packages, + "dracut-config-generic", + "efibootmgr", + "grub2-efi-aa64", + "grub2-tools", + "shim-aa64") + } + + return packages +} + +func (p *Aarch64_IoT) GetBootFiles() [][2]string { + return p.BootFiles +} diff --git a/vendor/github.com/osbuild/images/pkg/platform/platform.go b/vendor/github.com/osbuild/images/pkg/platform/platform.go new file mode 100644 index 000000000..854b861d3 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/platform/platform.go @@ -0,0 +1,108 @@ +package platform + +type Arch uint64 +type ImageFormat uint64 + +const ( // architecture enum + ARCH_AARCH64 Arch = iota + ARCH_PPC64LE + ARCH_S390X + ARCH_X86_64 +) + +const ( // image format enum + FORMAT_UNSET ImageFormat = iota + FORMAT_RAW + FORMAT_ISO + FORMAT_QCOW2 + FORMAT_VMDK + FORMAT_VHD + FORMAT_GCE + FORMAT_OVA +) + +func (a Arch) String() string { + switch a { + case ARCH_AARCH64: + return "aarch64" + case ARCH_PPC64LE: + return "ppc64le" + case ARCH_S390X: + return "s390x" + case ARCH_X86_64: + return "x86_64" + default: + panic("invalid architecture") + } +} + +func (f ImageFormat) String() string { + switch f { + case FORMAT_RAW: + return "raw" + case FORMAT_ISO: + return "iso" + case FORMAT_QCOW2: + return "qcow2" + case FORMAT_VMDK: + return "vmdk" + case FORMAT_VHD: + return "vhd" + case FORMAT_GCE: + return "gce" + case FORMAT_OVA: + return "ova" + default: + panic("invalid image format") + } +} + +type Platform interface { + GetArch() Arch + GetImageFormat() ImageFormat + GetQCOW2Compat() string + GetBIOSPlatform() string + GetUEFIVendor() string + GetZiplSupport() bool + GetPackages() []string + GetBuildPackages() []string + GetBootFiles() [][2]string +} + +type BasePlatform struct { + ImageFormat ImageFormat + QCOW2Compat string + FirmwarePackages []string +} + +func (p BasePlatform) GetImageFormat() ImageFormat { + return p.ImageFormat +} + +func (p BasePlatform) GetQCOW2Compat() string { + return p.QCOW2Compat +} + +func (p BasePlatform) GetBIOSPlatform() string { + return "" +} + +func (p BasePlatform) GetUEFIVendor() string { + return "" +} + +func (p BasePlatform) GetZiplSupport() bool { + return false +} + +func (p BasePlatform) GetPackages() []string { + return p.FirmwarePackages +} + +func (p BasePlatform) GetBuildPackages() []string { + return []string{} +} + +func (p BasePlatform) GetBootFiles() [][2]string { + return [][2]string{} +} diff --git a/vendor/github.com/osbuild/images/pkg/platform/ppc64le.go b/vendor/github.com/osbuild/images/pkg/platform/ppc64le.go new file mode 100644 index 000000000..8aab9634f --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/platform/ppc64le.go @@ -0,0 +1,33 @@ +package platform + +type PPC64LE struct { + BasePlatform + BIOS bool +} + +func (p *PPC64LE) GetArch() Arch { + return ARCH_PPC64LE +} + +func (p *PPC64LE) GetBIOSPlatform() string { + if p.BIOS { + return "powerpc-ieee1275" + } + return "" +} + +func (p *PPC64LE) GetPackages() []string { + return []string{ + "dracut-config-generic", + "powerpc-utils", + "grub2-ppc64le", + "grub2-ppc64le-modules", + } +} + +func (p *PPC64LE) GetBuildPackages() []string { + return []string{ + "grub2-ppc64le", + "grub2-ppc64le-modules", + } +} diff --git a/vendor/github.com/osbuild/images/pkg/platform/s390x.go b/vendor/github.com/osbuild/images/pkg/platform/s390x.go new file mode 100644 index 000000000..d67f52510 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/platform/s390x.go @@ -0,0 +1,32 @@ +package platform + +type S390X struct { + BasePlatform + Zipl bool +} + +func (p *S390X) GetArch() Arch { + return ARCH_S390X +} + +func (p *S390X) GetZiplSupport() bool { + return p.Zipl +} + +func (p *S390X) GetPackages() []string { + packages := p.BasePlatform.FirmwarePackages + // TODO: should these packages be present also in images not intended for booting? + packages = append(packages, + "dracut-config-generic", + "s390utils-base", + "s390utils-core", + ) + return packages +} + +func (p *S390X) GetBuildPackages() []string { + // TODO: should these packages be present also in images not intended for booting? + return []string{ + "s390utils-base", + } +} diff --git a/vendor/github.com/osbuild/images/pkg/platform/x86_64.go b/vendor/github.com/osbuild/images/pkg/platform/x86_64.go new file mode 100644 index 000000000..d9403b2f7 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/platform/x86_64.go @@ -0,0 +1,52 @@ +package platform + +type X86BootLoader uint64 + +type X86 struct { + BasePlatform + BIOS bool + UEFIVendor string +} + +func (p *X86) GetArch() Arch { + return ARCH_X86_64 +} + +func (p *X86) GetBIOSPlatform() string { + if p.BIOS { + return "i386-pc" + } + return "" +} + +func (p *X86) GetUEFIVendor() string { + return p.UEFIVendor +} + +func (p *X86) GetPackages() []string { + packages := p.BasePlatform.FirmwarePackages + + if p.BIOS { + packages = append(packages, + "dracut-config-generic", + "grub2-pc") + } + + if p.UEFIVendor != "" { + packages = append(packages, + "dracut-config-generic", + "efibootmgr", + "grub2-efi-x64", + "shim-x64") + } + + return packages +} + +func (p *X86) GetBuildPackages() []string { + packages := []string{} + if p.BIOS { + packages = append(packages, "grub2-pc") + } + return packages +} diff --git a/internal/rhsm/facts/facts.go b/vendor/github.com/osbuild/images/pkg/rhsm/facts/facts.go similarity index 100% rename from internal/rhsm/facts/facts.go rename to vendor/github.com/osbuild/images/pkg/rhsm/facts/facts.go diff --git a/internal/rhsm/secrets.go b/vendor/github.com/osbuild/images/pkg/rhsm/secrets.go similarity index 100% rename from internal/rhsm/secrets.go rename to vendor/github.com/osbuild/images/pkg/rhsm/secrets.go diff --git a/internal/rpmmd/metadata.go b/vendor/github.com/osbuild/images/pkg/rpmmd/metadata.go similarity index 100% rename from internal/rpmmd/metadata.go rename to vendor/github.com/osbuild/images/pkg/rpmmd/metadata.go diff --git a/internal/rpmmd/repository.go b/vendor/github.com/osbuild/images/pkg/rpmmd/repository.go similarity index 100% rename from internal/rpmmd/repository.go rename to vendor/github.com/osbuild/images/pkg/rpmmd/repository.go diff --git a/vendor/github.com/osbuild/images/pkg/runner/centos.go b/vendor/github.com/osbuild/images/pkg/runner/centos.go new file mode 100644 index 000000000..2c65fac9a --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/runner/centos.go @@ -0,0 +1,39 @@ +package runner + +import "fmt" + +type CentOS struct { + Version uint64 +} + +func (c *CentOS) String() string { + return fmt.Sprintf("org.osbuild.centos%d", c.Version) +} + +func (c *CentOS) GetBuildPackages() []string { + packages := []string{ + "glibc", // ldconfig + "platform-python", // osbuild + } + if c.Version >= 8 { + packages = append(packages, + "systemd", // systemd-tmpfiles and systemd-sysusers + ) + } + if c.Version < 9 { + packages = append(packages, + // The RHEL 8 runner (which is also used for CS8) in osbuild runs + // with platform-python but explicitly symlinks python 3.6 to + // /etc/alternatives (which in turn is the target for + // /usr/bin/python3) for the stages. + // https://github.com/osbuild/osbuild/blob/ea8261cad6c5c606c00c0f2824c3f483c01a0cc9/runners/org.osbuild.rhel82#L61 + // Install python36 explicitly for CS8. + "python36", + ) + } else { + packages = append(packages, + "python3", // osbuild stages + ) + } + return packages +} diff --git a/vendor/github.com/osbuild/images/pkg/runner/fedora.go b/vendor/github.com/osbuild/images/pkg/runner/fedora.go new file mode 100644 index 000000000..3482b0e11 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/runner/fedora.go @@ -0,0 +1,19 @@ +package runner + +import "fmt" + +type Fedora struct { + Version uint64 +} + +func (r *Fedora) String() string { + return fmt.Sprintf("org.osbuild.fedora%d", r.Version) +} + +func (p *Fedora) GetBuildPackages() []string { + return []string{ + "glibc", // ldconfig + "systemd", // systemd-tmpfiles and systemd-sysusers + "python3", // osbuild + } +} diff --git a/vendor/github.com/osbuild/images/pkg/runner/linux.go b/vendor/github.com/osbuild/images/pkg/runner/linux.go new file mode 100644 index 000000000..9e3ee7731 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/runner/linux.go @@ -0,0 +1,16 @@ +package runner + +type Linux struct { +} + +func (r *Linux) String() string { + return "org.osbuild.linux" +} + +func (p *Linux) GetBuildPackages() []string { + return []string{ + "glibc", // ldconfig + "systemd", // systemd-tmpfiles and systemd-sysusers + "python3", // osbuild + } +} diff --git a/vendor/github.com/osbuild/images/pkg/runner/rhel.go b/vendor/github.com/osbuild/images/pkg/runner/rhel.go new file mode 100644 index 000000000..8b921a211 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/runner/rhel.go @@ -0,0 +1,40 @@ +package runner + +import "fmt" + +type RHEL struct { + Major uint64 + Minor uint64 +} + +func (r *RHEL) String() string { + return fmt.Sprintf("org.osbuild.rhel%d%d", r.Major, r.Minor) +} + +func (p *RHEL) GetBuildPackages() []string { + packages := []string{ + "glibc", // ldconfig + } + if p.Major >= 8 { + packages = append(packages, + "systemd", // systemd-tmpfiles and systemd-sysusers + "platform-python", // osbuild + ) + } + + if p.Major < 9 { + packages = append(packages, + // The RHEL 8 runner in osbuild runs with platform-python but + // explicitly symlinks python 3.6 to /etc/alternatives (which in turn + // is the target for /usr/bin/python3) for the stages. + // https://github.com/osbuild/osbuild/blob/ea8261cad6c5c606c00c0f2824c3f483c01a0cc9/runners/org.osbuild.rhel82#L61 + // Install python36 explicitly for RHEL 8. + "python36", + ) + } else { + packages = append(packages, + "python3", // osbuild stages + ) + } + return packages +} diff --git a/vendor/github.com/osbuild/images/pkg/runner/runner.go b/vendor/github.com/osbuild/images/pkg/runner/runner.go new file mode 100644 index 000000000..60679ba28 --- /dev/null +++ b/vendor/github.com/osbuild/images/pkg/runner/runner.go @@ -0,0 +1,6 @@ +package runner + +type Runner interface { + String() string + GetBuildPackages() []string +} diff --git a/internal/subscription/subscription.go b/vendor/github.com/osbuild/images/pkg/subscription/subscription.go similarity index 100% rename from internal/subscription/subscription.go rename to vendor/github.com/osbuild/images/pkg/subscription/subscription.go diff --git a/vendor/modules.txt b/vendor/modules.txt index 99cfc6235..9c3562f12 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -607,6 +607,44 @@ github.com/oracle/oci-go-sdk/v54/identity github.com/oracle/oci-go-sdk/v54/objectstorage github.com/oracle/oci-go-sdk/v54/objectstorage/transfer github.com/oracle/oci-go-sdk/v54/workrequests +# github.com/osbuild/images v0.0.0-20230710155525-7045e8251769 +## explicit; go 1.18 +github.com/osbuild/images/internal/common +github.com/osbuild/images/internal/dnfjson +github.com/osbuild/images/internal/environment +github.com/osbuild/images/internal/fdo +github.com/osbuild/images/internal/fsnode +github.com/osbuild/images/internal/ignition +github.com/osbuild/images/internal/mocks/dnfjson +github.com/osbuild/images/internal/oscap +github.com/osbuild/images/internal/pathpolicy +github.com/osbuild/images/internal/shell +github.com/osbuild/images/internal/users +github.com/osbuild/images/internal/workload +github.com/osbuild/images/pkg/artifact +github.com/osbuild/images/pkg/blueprint +github.com/osbuild/images/pkg/container +github.com/osbuild/images/pkg/crypt +github.com/osbuild/images/pkg/disk +github.com/osbuild/images/pkg/distro +github.com/osbuild/images/pkg/distro/distro_test_common +github.com/osbuild/images/pkg/distro/fedora +github.com/osbuild/images/pkg/distro/rhel7 +github.com/osbuild/images/pkg/distro/rhel8 +github.com/osbuild/images/pkg/distro/rhel9 +github.com/osbuild/images/pkg/distro/test_distro +github.com/osbuild/images/pkg/distroregistry +github.com/osbuild/images/pkg/image +github.com/osbuild/images/pkg/manifest +github.com/osbuild/images/pkg/osbuild +github.com/osbuild/images/pkg/ostree +github.com/osbuild/images/pkg/ostree/mock_ostree_repo +github.com/osbuild/images/pkg/platform +github.com/osbuild/images/pkg/rhsm +github.com/osbuild/images/pkg/rhsm/facts +github.com/osbuild/images/pkg/rpmmd +github.com/osbuild/images/pkg/runner +github.com/osbuild/images/pkg/subscription # github.com/pkg/errors v0.9.1 ## explicit github.com/pkg/errors