Commit graph

135 commits

Author SHA1 Message Date
Brian C. Lane
0256e09031 lint: Clean up golangci-lint v1.60 complaints
This cleans up the linting results by adding checks for
integer underflow/overflow in several places, suppressing the error in
places where it has been checked, or fixing the types when possible.
2025-02-24 04:20:42 -08:00
Achilleas Koutsou
49271e614b blueprint: test the conversion 2025-02-05 11:32:52 +01:00
Achilleas Koutsou
68dd8699ed blueprint: add local DiskCustomization
Add DiskCustomization and all its children to the internal blueprint.
Add the conversion to the images counterpart to the Convert() function.
2025-02-05 11:32:52 +01:00
Lukas Zapletal
d531f62488 blueprint: add cacert customization 2025-01-10 10:26:54 +01:00
Achilleas Koutsou
66c2c31a1c blueprint: add kickstart contents to conversion test
The option was added in f5c6cdd9cf but a
value was never added to the conversion test.
2024-10-22 22:08:39 +02:00
Achilleas Koutsou
654a6ad8f5 blueprint: enable the anaconda modules customization
This has been available since v0.74.0 of osbuild/images but was never
connected to the frontend blueprint.

See https://github.com/osbuild/images/pull/799
2024-10-22 22:08:39 +02:00
Achilleas Koutsou
ec01c6908b blueprint: sshkey to users in images blueprint conversion
The sshkey customization in osbuild/images has been dropped.  In
osbuild-composer we maintain it for backwards compatibility, converting
each to a user customization, which is a superset of the sshkey.
2024-09-17 23:33:44 +02:00
Sanne Raymaekers
b21f24e751 cloudapi/v2: populate openscap related rhsm facts
Also adds the policy id to the blueprint, this doesn't have any effect
on the openscap step, it just puts in place the rhsm fact so instances
registered to insights will appear under that policy.
2024-09-06 11:39:35 +02:00
Tomáš Hozza
768537dba3 Add support for RHSM customizations
Add support for RHSM customizations, which currently allow various
aspects of RHSM. Specifically enabling / disabling DNF plugins shipped
by subscription-manager package and setting a subset of options in the
rhsm.conf.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-08-13 15:52:44 +02:00
Tomáš Hozza
26dd54a4d7 Add support for RPM customizations
Add support for RPM customizations, which currently allow to import RPM
GPG key from a file installed in the image. This is e.g. done for the
Azure RHUI image type.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-08-13 15:52:44 +02:00
Gianluca Zuccarelli
16180e9c58 blueprint/customizations: json tailoring
Add support to the blueprints for json tailoring files
2024-08-07 12:06:28 +02:00
Achilleas Koutsou
f5c6cdd9cf blueprint: add new kickstart.contents option 2024-05-29 00:27:31 +02:00
Achilleas Koutsou
a3a539abd1 Update osbuild/images v0.63.0
Pulling in (among others):
- https://github.com/osbuild/images/pull/700
    - Blueprint User customization change required.
- https://github.com/osbuild/images/pull/705
2024-05-29 00:27:31 +02:00
Andre Marianiello
0ef11c1f07 internal/blueprint: Go fmt customizations test 2024-05-27 13:06:48 +02:00
Andre Marianiello
0ece609c8b Add ExpireDate to user customizations test 2024-05-27 13:06:48 +02:00
Sanne Raymaekers
3be2c92a1b internal/blueprint: add ExpireDate to UserCustomization
Just to make osbuild-composer compile, this field is not functional yet.
2024-03-28 11:11:13 +01:00
Achilleas Koutsou
bd57d95e49 blueprint: add installer customizations 2024-03-20 11:45:08 +01:00
Gianluca Zuccarelli
f6b76cce31 Update osbuild/images to v0.41.0
Multiple blueprint fixes:

- Extend the blueprint service customizations to accept services to be
  masked.

- The `storage-path` and `container-transport` fields were removed in
  imagees 41.0 in order to simplify the way local storage containers are
  handled.
2024-02-29 20:57:39 +01:00
Florian Schüller
42da3cb143 blueprint: rename package variable for readability 2024-02-22 15:22:52 +01:00
Florian Schüller
fb8634a991 blueprint: improve error message on missing name
the error should not infer that a version is mandatory.
Also the error message is now explicitly checked
2024-02-22 15:22:52 +01:00
Florian Schüller
99e84abc66 api: add error message for package without name RHEL-16006 2024-02-22 15:22:52 +01:00
Tomáš Hozza
625b1578fa Port osbuild/images v0.33.0 with dot-notation to composer
Update the osbuild/images to the version which introduces "dot notation"
for distro release versions.

 - Replace all uses of distroregistry by distrofactory.
 - Delete local version of reporegistry and use the one from the
   osbuild/images.
 - Weldr: unify `createWeldrAPI()` and `createWeldrAPI2()` into a single
   `createTestWeldrAPI()` function`.
 - store/fixture: rework fixtures to allow overriding the host distro
   name and host architecture name. A cleanup function to restore the
   host distro and arch names is always part of the fixture struct.
 - Delete `distro_mock` package, since it is no longer used.
 - Bump the required version of osbuild to 98, because the OSCAP
   customization is using the 'compress_results' stage option, which is
   not available in older versions of osbuild.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-01-26 11:32:34 +01:00
Achilleas Koutsou
6d57e01506 deps: update images to v0.24.0
Update the images dependency to v0.24.0

Includes the addition of the new FDO option
'di_mfg_string_type_mac_iface'.
2023-12-14 22:21:09 +01:00
Sanne Raymaekers
c6aa7d88d2 internal/weldr: specify architecture of compose
This is useful in environments with multi-arch remote workers.
Defaults to the host architecture.
2023-12-14 21:25:32 +01:00
Miguel Martín
3c64edfcb9 Define the FIPS blueprint customization
Define a new blueprint customization that
allows to enable the system FIPS mode

Signed-off-by: Miguel Martín <mmartinv@redhat.com>
2023-12-13 10:19:47 +01:00
Gianluca Zuccarelli
fdf1364bb5 internal/blueprints: filesystem TOML tests
Move the filesystem customization tests into their own file.
Additionally add tests for unmarshalling filesystem customizations
from TOML, since we have added a new `minsize` tag to ensure
consistency with the json tag.

The new tests check the validation of the TOML input and ensures
that either one or both of the `minsize` and `size` inputs are
set. If both are set, the input is checked to ensure that both
match.
2023-11-09 15:47:07 +01:00
Gianluca Zuccarelli
4ddb2c300b internal/blueprints: fix mountpoint size keyword
Due to an oversight, the toml and json tags for the `MinSize`
field had different keywords. This commit fixes this by creating
a `minsize` toml tag and ensuring backwards compatability by
checking the old `size` tag.

If both `minsize` & `size` are set in the toml block, the
custom unmarshal function validates the input for inconsistencies.
2023-11-09 15:47:07 +01:00
Brian C. Lane
2729f6ac54 blueprint: Add partitioning_mode customization 2023-10-23 14:52:30 +02:00
Tomáš Hozza
2cc55065b0 Delete unused function converting repository BP customization
These functions are leftover from the `osbuild/images` split and are not
used by any code in osbuild composer. Instead, the version in
`osbuild/images` is used by distro definitions.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-10-20 18:59:00 +02:00
Tomáš Hozza
d4e3173234 Delete unused blueprint.ValidateDirFileCustomizations() function
This function is no longer used by any code. Instead, its copy in the
`osbuild/images` repository is used by distro definitions to validate
the customization.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-10-20 18:59:00 +02:00
Tomáš Hozza
d57f2e5bb5 Delete unused internal/pathpolicy package
This copy of the package in osbuild-composer is no longer used by any
code. Instead, the copy which is in the `osbuild/images` repository (and
module) is the implementation used by distro definitions.

Delete this code to reduce potential confusion and code duplication.

Also delete code in `internal/blueprint` package, which uses the
pathpolicy package. This code is no longer used, but instead the version
from `osbuild/images` is being used.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-10-20 18:59:00 +02:00
Brian C. Lane
9e39080d00 lint: Fix implicit memory aliasing in for loops
Fix all instances of gosec G601: Implicit memory aliasing in for loop.
2023-09-21 16:56:54 +02:00
Ondřej Budai
1a6dac1cfa blueprint: make Convert respect nils
Previously, nil values in the conversion source were in some cases converted
to empty arrays or empty objects. This is undesirable, because it can be in
certain cases changing the semantics of the blueprint. See e.g.
f317064da5/pkg/distro/rhel7/imagetype.go (L239C7-L239C7)

This commit modifies the conversion process so nil values are converted
without any changes. Also, the `Convert` function was covered with a unit
test.
2023-08-10 20:02:45 +02:00
Achilleas Koutsou
f2deb3a083 blueprint: add openscap Tailoring customizations
See https://github.com/osbuild/images/pull/43
2023-08-10 12:49:44 +02:00
Ondřej Budai
cac9327b44 update to go 1.19
UBI and the oldest support Fedora (37) now all have go 1.19, so we are
cleared to switch.

gofmt now reformats comments in certain cases, so that explains the formatting
changes in this commit.
See https://go.dev/doc/go1.19#go-doc

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-07-21 19:18:00 +02:00
Achilleas Koutsou
0e4a9e586f 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.
2023-07-10 21:11:19 +02:00
Gianluca Zuccarelli
ce299dfa0e internal/rpmmd: change ignoressl to pointer
Change the `IgnoreSSL` field in `rpmmd.RepoConfig`
to a pointer. This will be later used to configure
the `SSLVerify` field in the yum repo stage.
2023-05-31 16:24:36 +02:00
Gianluca Zuccarelli
c18f2962ae internal/blueprint: repo filename validation
Validate custome repository filenames in order to
avoid unexpected `5xx` errors when building an image.

Before this the filename was only validated at the
yum repo stage, which was causing unexpected errors.
2023-05-03 18:27:06 +02:00
Gianluca Zuccarelli
f59e248bc8 blueprint: add gpgkey validation
Add custom repo gpg keys validation checks to
make sure that a gpg key is either a valid key
or a valid url.
2023-04-26 14:16:16 +01:00
Gianluca Zuccarelli
29643c2e06 customizations: custom repo utility functions
Create some utility functions that will be used for implementing
custom repo configuration files. This commit adds these functions:
- a helper to get the filename of a custom repo, or the
  `<repo-id>.repo` if the filename is empty
- a function to convert the custom repos to a map of `RepoConfig`.
  This function also creates an `fsnode.File` for each inline gpg
  key set in the customizations and swaps the inline key for the
  file path. The function returns the map of `RepoConfig` and a list
  of `fsnode.File` containing the inline gpg keys.
2023-04-21 17:40:00 +02:00
Gianluca Zuccarelli
d44703cdc8 rpmmd/repository: repoconfig pointers
Convert some of the fields in the `RepoConfig` struct
to pointers. Since `RepoConfig` will be used to convert
custom repositories to an array of `osbuild.YumRepository`,
we need to ensure that fields that are not set explicitly
are not saved to the `/etc/yum.repos.d` repository files.
2023-04-21 17:40:00 +02:00
Gianluca Zuccarelli
75e2138878 customizations: add custom repositories
Define blueprint custom repositories. These
definitions have been based on the upstream
definitions of a DNF repo[1].

[1] See dnf.conf
2023-04-21 17:40:00 +02:00
Ondřej Budai
d8342862d5 customizations: create all groups unconditionally
We had this weird condition in code that prevented composer to create groups
with the same name as a user has. This unfortunately means that you are not
able to create a user with a primary group with a certain GID that has the
same name as the user. There's the gid field in the user customization,
but it requires that the group already exists.

In order to allow that, we need to remove the condition. From now on, it's
possible to create groups with the same name as a user has, which can be used
to create primary groups with a custom gid.

Note that the lorax compatibility behaviour was actually wrong. When lorax was
given a custom gid for a user, it didn't require the gid to exist. When it
didn't, the group was just created. Thus, we still don't have full backward
compatibility, but at least we now have support for this.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-04-19 11:50:49 +02:00
Tomáš Hozza
3ee973c8ee blueprint: add functions checking dir / file customizations policy
Add helper functions for checking directory and file blueprint
customizations against the policy of allowed paths.

These functions are not yet used in the distro definitions.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
a6dd4943c5 blueprint: add function for validating dir and file customizations
Add a helper function for validating the user-provided directory and
file customizations. This is necessary to fail early on invalid input,
instead of when building the image.

The function 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

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
053c1b090f blueprint: add functions converting dir and file customizations
Add helper functions for converting slices of directory and file
customizations structures from the `blueprint` package to a slice of
structures from the `fsnode` package, which are used in image type
definitions.

These will be used to convert BP customizations to the os pipeline
customization then used by the pipeline generator.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
c1991b3d51 blueprint: add representation of Directories and Files customization
Extend the Blueprint customizations with the representation for custom
Directories and Files specified by the user.

Implement custom Unmarshalers for TOML and JSON. These ensure that all
user-provided values are validated before use and also handle the fact
that user and group ownership for directories and files can be
specifies as a string or as an integer.

Implement helper functions for converting the Blueprint-specific types
for these customizations to their internal representation from `fsnode`
package.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
26e6983320 disk: move remaining mountpoint policy code to different packages
Move the `CheckMountpoints()` implementation to `blueprint` package,
since it does not operate on any data structures from the `disk`.

Move the default mountpoint allow list policy definition to the
`pathpolicy` package.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
eb0531b89b blueprint: move FilesystemCustomization code to separate file
Move the `FilesystemCustomization` structure and its custom
unmarshallers to a dedicated file. This makes `customizations.go` easier
to read.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
0e4dabd265 blueprint: delete HasIgnition() function
Unify how are allowed options checked in distro implementation in
relation to Ignition customization. Specifically, delete `HasIgnition()`
function and replace its use by `GetIgnition()` call and checking if it is
`nil`. This approach is consistent with how this is checked for other
customizations.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00