klog has added ktesting/textlogger and is going to deprecate
klogr. The deprecation is going to trigger golangci-lint (staticcheck)
errors so rework the logging and move to ktesting/textlogger.
The commit also fixes the loglevel setting with operator.
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
FPGA and SGX webhooks mutate container resources which
are immutable. Therefore, stop processing pod updates
and act on creation only.
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
For some reason the API server may want to pass an already mutated CR
through the webhook once again. The webhook must accept such CR with
no additional transformations.
This patch adds support for such idempotence by maintaining
a set of identity mappings which effectively resolve to themselves. No
patching is applied to them.
Fixes a linter warning:
"unexported-return: exported method GetPatcher returns unexported type
*patcher.patcher, which can be annoying to use (revive)"
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
Webhook's patcher currently can't be re-applied to its output because it
rejects containers with the env vars it adds (e.i. FPGA_AFU_* and
FPGA_REGION_*).
Instead of rejecting container with disallowed env vars just reset them
first upon patching.
Add govet-fieldalignment to .golangci.yml
Fix errors that come from adding govet-fieldalignment
- by reordering the fields of structs
- by putting nolint:govet annotations
Signed-off-by: Hyeongju Johannes Lee <hyeongju.lee@intel.com>
Update tool versions
Fix the errors and warnings originated from the update:
-Correct type deviceInfo (->DeviceInfo) to make it public
-Fix gpu_plugin.go and vpu_plugin_test.go where stylecheck errors occur
-Fix deprecation warnings
-Rename type 'PatcherManager' to 'Manager' to solve exported errors
-Rename type 'SgxMutator' to 'Mutator' to solve exported errors
Signed-off-by: Hyeongju Johannes Lee <hyeongju.lee@intel.com>
The function will be re-used by other webhooks too so it's better
to move it to its own package.
The unit tests are taken from the original implementation with some
minor changes.
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
This commit adds new function validateContainer() that runs the
same FPGA_* ENV validation checks as before in getRequestedResources().
The restructuring is done in preparations for moving
getRequestedResources() to a separate package.
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>