Commit graph

27 commits

Author SHA1 Message Date
Tom Gundersen
ac5f69e757 osbuild: move result serialization from common
In the same way `osbuild.Manifest` is the input to the osbuild API,
`osbuild.Result` is the output. Move it to the `osbuild` package where
it belongs.

This is not a functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-08-26 12:12:37 +02:00
Tom Gundersen
2c3790f20c common/ImageType: move to the store package
This is now only used for marshalling in the store, so keep the logic
where it is used.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
3f2e7be9cf common/types: drop dead code
Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Tom Gundersen
8797cd4704 common: drop unused image types
The Alibaba and GCE image types were not used, and they were
causing problems when translated from and to strings as they were
mapping to the same internal image type. The end result was that
AWS jobs were shown as Alibaba or GCE in the UI.

This fixes #369.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-04-03 08:46:50 +02:00
Jakub Rusz
4f160447ee tests: use asserts in states_test.go 2020-04-02 09:17:09 +02:00
Jakub Rusz
1cf2af10d0 tests: add coverage for common/helpers.go
This also changes the helpers.go to enable mocking all the different architectures.
2020-04-02 09:14:40 +02:00
Jakub Rusz
4807b64dea tests: add coverage for compose_result.go 2020-03-31 16:32:34 +02:00
Jakub Rusz
2b87ca41b5 Separate nested structure in compose_result.go
This separated the nested structure into their own struct types.
2020-03-31 16:32:34 +02:00
Tom Gundersen
4a7519807e common/Architecture: drop unused code
The intended use for this will be repalced by Arch objects, currently
it was unused, so drop it.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-24 15:46:57 +01:00
Tom Gundersen
87b0bb6e5d distro: mass cleanup
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>
2020-03-24 14:13:03 +01:00
Lars Karlitski
72f8b07e8b store: move ComposeRequest to the store package
A ComposeRequest is data used to submit a compose to the store, so it
should live in that package.

Remove the json marshalling test, because ComposeRequest is never
marshalled to JSON.

This will allow to use types from `distro` in the ComposeRequest struct.
2020-03-12 20:01:24 +01:00
Lars Karlitski
17ca73ab14 osbuild-pipeline: validate distro when fetching it
We were verifying two things: if the passed distroArg exists in the
distribution mapping in common/types.go and if the it is an actually
registered distro. Since you cannot have distros registered that don't
correspond to a type, the first test is unnecessary.

Merge the two tests by moving the (much better) error message down into
the second test. This makes DistributionExists redundant, because
Registry.GetDistro() checks this implicitly.

Also, move ListDistributions() to the Registry object, because we want
to show distributions that are actually registered.

Add a test which checks that Registry.List() works and that all included
distributions register correctly.
2020-03-03 16:21:13 +01:00
Ondřej Budai
d7cbc22da4 lint: fix unhandled errors 2020-03-02 14:28:55 +01:00
Ondřej Budai
efb100fbca lint: fix gosimple/S1005 errors 2020-03-02 14:28:55 +01:00
Jacob Kozol
2a3a5b318b distro: add rhel-8.1 support
Images can be built for rhel 8.1. The pipeline generation and distro
tests are based off of the rhel 8.2 ones. Repository information as been
added for rhel 8.1. The repo urls are internal ones and will only work
if the user is on the Red Hat vpn.
2020-02-29 01:17:50 +01:00
Ondřej Budai
80f0888896 cmd/composer: move currentArch helper to common package
The helper function might be useful also in different parts of the project.
2020-02-26 16:58:39 +01:00
Martin Sehnoutka
923a0b0b97 rcm: introduce rpmmd member of the api structure
This is needed for unit tests, because it wasn't possible to mock the
rpmmd module before. This also requires that the checksum is moved to
the compose request and evaluated in the endpoint handler instead of
push compose. I think it makes sense to have the checksum in the compose
request directly.

Also a "module platform ID" is required now, but we don't have the
"global" distribution any more, so this patch introduces mapping from a
distribution to the module platform ID.
2020-02-20 13:04:28 +01:00
Martin Sehnoutka
5b0611983a common: fix bug in architecture ToString implementation
it used a wrong mapping, replace it with the right one
2020-02-20 13:04:28 +01:00
Martin Sehnoutka
6b957f01a0 common: fix method signature for UnmarshalJSON
There was a bug in the previous implementation which used to pass the
argument as a value but that does not work because we need to change the
value of it. The new implementation uses pass by reference.

Create a test to cover this scenario.
2020-02-20 13:04:28 +01:00
Jacob Kozol
fae51095d2 distro: add fedora 32 support
Images can be built for fedora 32. The pipeline generation and distro
 tests are based off of the fedora 30 ones. Repository information has
 also been added for the fedora 32 repos.
2020-02-19 14:18:58 +01:00
Lars Karlitski
4f2ac6a687 tree-wide: format code with gofmt 2020-02-17 16:09:17 +01:00
Martin Sehnoutka
62d186cd1b common: refactor build states into a separate file
These states will be used for tracking the image builds and compose
states in the rest of our codebase. There should be no change in the
behavior. It is a 1 to 1 replacement with the only difference of using
type alias instead of plain string.
2020-02-12 11:17:26 +01:00
Martin Sehnoutka
9c91b12076 common: compose request should include full bp and repositories
we want to move to a state where composer is a stateless service,
therefore we cannot take blueprints by name (and fetch them from a
storage) or assume repositories by the distribution. This commit
introduces both of these parameters as part of the structure.
2020-02-12 11:17:26 +01:00
Martin Sehnoutka
cffa74f0a1 common: extend common types with helper functions
It is very common that a string is required in the rest of our code and
also for user input/output. These helper functions will make this easy.
2020-02-12 11:17:26 +01:00
Ondřej Budai
a43dd00459 move ComposeResult type into common package to allow its reusing 2020-02-05 01:35:50 +01:00
Martin Sehnoutka
b0ddbc744a osbuild-pipeline: improve CLI interface
In the current state, osbuild-pipeline exits with random golang error,
such as goroutine failed, which is not at all helpful. This PR
introduces CLI arguments validation and helful error messages that use
the newly introduced types so that we don't waste time guessing what
was the right way to invoke this tool.
2020-01-30 15:17:05 +01:00
Martin Sehnoutka
8dac72f4fd internal: propose custom types for image types, arches, etc.
We currently use strings for passing arches and image types around,
which is not ideal. We should have a finite set of supported image types
and architectures as well as upload targets. This PR introduces custom
types to make the code base more readable and possibly also more
correct.

I considered some alternatives like a struct with private fields, but struct cannot
be const, so that does not help either. Eventually I think this is the "get s**t done"
solution.

The package also includes unit-tests which try to convert string to
structure and the other way around to make sure it all works properly.
2020-01-30 14:42:25 +01:00