Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCM API: use the new PushComposeRequest method #231

Merged
merged 11 commits into from
Feb 20, 2020

Conversation

msehnout
Copy link
Contributor

@msehnout msehnout commented Feb 13, 2020

see individual commits

internal/rpmmd/repository.go Outdated Show resolved Hide resolved
internal/rcm/api.go Outdated Show resolved Hide resolved
cmd/osbuild-dnf-json-tests/main.go Outdated Show resolved Hide resolved
internal/rpmmd/repository.go Outdated Show resolved Hide resolved
internal/rcm/api_test.go Show resolved Hide resolved
@msehnout msehnout force-pushed the rcm-api-contd-2 branch 2 times, most recently from 5a31e6a to e24537a Compare February 19, 2020 11:13
internal/common/types.go Show resolved Hide resolved
func main() {
// Tests that the package wrapping dnf-json works as expected
dir, err := setUpTemporaryRepository()
defer func(dir string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just a small nit - I don't think the dir parameter is needed, I'm fine with the function being closure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's (probably) correct, happy to take a clean-up in a follow-up PR.

internal/common/types.go Show resolved Hide resolved
}
id, exists := mapping[*dist]
if !exists {
return "", &CustomTypeError{reason: "Distribution does not have a module platform ID assigned"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just panic here, this is clearly our mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it again, I think we should keep it like this because we have the same logic in other transformation functions in this package.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have preferred to look up the distro and query that, but let's not block on that. Not a fan of hardcoding strings more than once.

@@ -72,7 +72,7 @@ func main() {
// Optionally run RCM API as well as Weldr API
if len(listeners) == 3 {
rcmListener := listeners[2]
rcmAPI := rcm.New(logger, store)
rcmAPI := rcm.New(logger, store, rpmmd.NewRPMMD())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rpm variable can be reused here instead of creating new RPMMD instance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I was thinking about it. Is it safe to share it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type rpmmdImpl struct{} - it doesn't have much state. :-D

Martin Sehnoutka added 11 commits February 20, 2020 09:18
this is needed for RCM API because the user will provide only the URL
and we need to fetch the checksum ourselves
this test will create a temporary directory, create repo inside, then
fetch the checksum, and finally clean up the directory
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.
it used a wrong mapping, replace it with the right one
The change also requires customizations in the error handling, as some
errors are now handled automatically by the custom unmarshaler.

Include a note about HTTP return types.
the new version is better suited for the need of this API
previously these were provided, but in case of RCM API they are not,
therefore we fetch them automatically
the name was misleading because the function could do more than just
download package list. In PushComposeRequest it is also used to fetch
checksums for the repositories, therefore I decided to rename it to
reflect this usage.
When I run make build I expect to build all the code we have to make
sure it still compiles just fine.
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.
Copy link
Member

@ondrejbudai ondrejbudai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! When @teg approves it's imho ready to be merged.

Copy link
Member

@teg teg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Thanks! I left some minor comments, but just for future reference.

func main() {
// Tests that the package wrapping dnf-json works as expected
dir, err := setUpTemporaryRepository()
defer func(dir string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's (probably) correct, happy to take a clean-up in a follow-up PR.

}
id, exists := mapping[*dist]
if !exists {
return "", &CustomTypeError{reason: "Distribution does not have a module platform ID assigned"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have preferred to look up the distro and query that, but let's not block on that. Not a fan of hardcoding strings more than once.

@teg teg merged commit 923a0b0 into osbuild:master Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants