Delete unused methods and make types and fields private where
possible. Some code is moved around, but apart from that there
is no change in behavior.
The naming of the distros were moved back into the distro
packages as the common types now only had one user, and this
allowed us to drop some redundant error checking.
Signed-off-by: Tom Gundersen <teg@jklm.no>
This likely needs to be reintroduced in some fashion, but it was
unused, and when we reintroduced it it should be as a real Distro
object.
For now, drop it.
Signed-off-by: Tom Gundersen <teg@jklm.no>
Usage of these have now been entirely replaced with the newly
introduced interfaces. The individual distros should be cleaned up
and dead code removed, buth that is left for a future patch.
Signed-off-by: Tom Gundersen <teg@jklm.no>
This is purely internal, and there is no benefit to translating
to a tag, a string identifier will do just fine.
Signed-off-by: Tom Gundersen <teg@jklm.no>
Rather than using the `common` package, parse the JSON as strings,
then resolve into real Arch and ImageType objects.
This should not be a behavioural change, but will simplify the code
in subsequent commits.
Signed-off-by: Tom Gundersen <teg@jklm.no>
Currently all image types are supported on all arches, but in the
future we may want to restrict this. In that case, return the
image types that are valid for the arch in qusetion, rather than
all the possible ones.
Signed-off-by: Tom Gundersen <teg@jklm.no>
Check for errors and return early if they are found, rather than
check for the absence of errors.
This is not a functional change.
Signed-off-by: Tom Gundersen <teg@jklm.no>
weldr needs to know the host architecture. Rather than pinning
a string, pin a real Arch object, and query its name when we
need it.
This verifies the validitiy of the architecture for the given
distro before it is passed to weldr, rather than lazily on
demand.
Signed-off-by: Tom Gundersen <teg@jklm.no>
Objects implementing these interfaces will represent the
architecture support for a given distro and the image type
support for a given architecture distro combination, respectively.
The idea is to always resolve to these objects early, and drop
the equilavent methods from the distro interface. This means that
we convert our input strings to real objects once, and then never
have to verify their correctness again.
Signed-off-by: Tom Gundersen <teg@jklm.no>
Require the caller to pass in the required distros explicitly. This
would allow us to easily add distros in osbuild-pipeline and tests
before exposing them in composer itself, for instance.
This means there is no longer a dependency from the distro package
to each of the individual distros, so the distros are now able
to depend on the distro packag for types and interfaces.
Signed-off-by: Tom Gundersen <teg@jklm.no>
Simplify the code by dropping the potential error return. The
constructor simply instantiates some maps, this cannot fail.
Signed-off-by: Tom Gundersen <teg@jklm.no>
Rather than having to assume that we only ever produce one
artifact, have each upload target contain the filename it expects
to upload from the osbuild output.
An image file is always explicitly named in the manifest, and we
leave it up to each distro to decide how this is done, but the
convention is to use the same image filename as used when
downloading the image through weldr.
Now make this policy explicit, by quering the distro for the image
name and inserting it into each upload target.
Signed-off-by: Tom Gundersen <teg@jklm.no>
For serializeation, make our own private structs. The structs
in the target package are not exactly the same as the ones used by
weldr, so in order to avoid too many compromises, let's just do
an explicity translation.
As a general principle, we aim to only use private types for
serialization and rather translate than reuse for different
purposes.
Signed-off-by: Tom Gundersen <teg@jklm.no>
The same types are used in the weldr API as internally. We want
to avoid sharing serialized types like this, as it easily leads
to layering vialotions.
For now just make the translation explicity, in a follow-up
we will introduce types dedicated to serialization in the weldr
API.
Signed-off-by: Tom Gundersen <teg@jklm.no>
Build constraints must be added to every file. We only want to build
this package when the `integration` tag is set.
Without this, every build prints this warning:
# github.com/osbuild/osbuild-composer/cmd/osbuild-image-tests
runtime.main_main·f: function main is undeclared in the main package
The rpms and tarballs generated by the Makefile all end up under
rpmbuild/, so there is no reason to ignore them explicitly.
Signed-off-by: Tom Gundersen <teg@jklm.no>
This script generates json test cases for each supported output format.
It requires an architecure, distro, osbuild store, and output directory
as input. There is also a json object which maps from output format to a
test case request which includes the compose request and boot type.
The script uses these test case requests to call the generate-test-case
script and then outputs the resulting json test cases to files in the
specified output directory.
The generate-test-cases no longer maps from output format to boot
type. Instead, the boot data is passed in through the standard input
alongside the composer-request object.
The script generate-test-cases only creates a single test case per run.
Therefore, the name should be singular. Also, this script has been moved
to a directory which will contain all test case generators.
When using %#v instead of %v, printing an error gives a slightly more
informative error message, therefore this commit switches to %#v in all
error prints.
The distro argument and restrictions to run only tests for the same distro
as the host's one were confusing. This commit removes them. Now the behaviour
is following:
By default all the test cases in test case directory are run.
If test cases are given by arguments, they are all run, and test case
directory is ignored.
Previously we had only tests for Fedora 30, therefore I added a hack to treat
every Fedora as Fedora 30, so the tests would run. Now, we have tests for
multiple Fedora versions, therefore the hack is no longer needed.
We're currently rewriting all the integration tests to use the Go
testing framework. This commit does the switch for the image tests.
I decided not to use the testing framework in functions which are
not directly tight to testing (booting images, running osbuild). I think
it's reasonable to use classic error handling there and propagate the errors
to places directly tight to testing and use the testing library.
This enables us to reuse the code in different part of projects if needed.