-
Notifications
You must be signed in to change notification settings - Fork 34
Refactor internal/{api,module}
#364
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
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qbarrand The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
✅ Deploy Preview for kubernetes-sigs-kmm ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
internal/{api,module}
@yevgeny-shnaidman PTAL. |
/lgtm |
internal/api/factory.go
Outdated
//go:generate mockgen -source=factory.go -package=api -destination=mock_factory.go ModuleLoaderDataFactory,moduleLoaderDataFactoryHelper | ||
|
||
type ModuleLoaderDataFactory interface { | ||
FromModule(mod *kmmv1beta1.Module, kernelVersion string) (*ModuleLoaderData, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we plan to have other mlds rather then a module one? I am wondering why we need a factory if we only have 1 type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the name of the interface is a little bit confusing: usually factory means creating various other interface/objects and then using them. In this case it just means manifacturing ModuleLoaderData structure. It also threw me off the first time i saw the interface, until i looked at the rest of the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to ModuleLoaderDataCreator
.
internal/api/factory.go
Outdated
mld.KernelVersion = kernelVersion | ||
mld.Name = mod.Name | ||
mld.Namespace = mod.Namespace | ||
mld.ImageRepoSecret = mod.Spec.ImageRepoSecret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImagePullPolicy also needs to be set here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
/hold |
New changes are detected. LGTM label has been removed. |
Move MLD-related internal/module functions to internal/api. Remove the KernelMapper type in favor of ModuleLoaderCreator. Use ModuleLoaderData methods everywhere instead of internal/module functions.
} | ||
|
||
type sectionGetter interface { | ||
GetRelevantBuild(moduleBuild *kmmv1beta1.Build, mappingBuild *kmmv1beta1.Build) *kmmv1beta1.Build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those interface's methods can be private, they are not used anywhere outside of the package
|
||
mld := &ModuleLoaderData{} | ||
// prepare the build | ||
if mapping.Build != nil || mod.Spec.ModuleLoader.Container.Build != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think about moving the checks for kenrelMapping sign/buid and module sign/build into the getRelevantBuidl/Sign functions? This will make prepareModuleLoader code cleaner, and those functions are returning pointer anyway
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
(this fixes a small discrepancy between upstream and midstream infavour of upstream) log error if sign-file fails (kubernetes-sigs#237) the error from the sign-file binary was getting lost because it wasn't returned through the stack call correctly. This commit fixes that by passing the message up. Also remove a couple of commented out code lines.
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Move MLD-related
internal/module
functions tointernal/api
.Remove the
KernelMapper
type in favor ofModuleLoaderFactory
.Use
ModuleLoaderData
methods everywhere instead ofinternal/module
functions./cc @mresvanis @yevgeny-shnaidman