k8snetworkplumbingwg / resource-mgmt-utils

Library for for commonly used sriov functions
Apache License 2.0
0 stars 2 forks source link

resource mgmt utils first steps #1

Open adrianchiris opened 3 years ago

adrianchiris commented 3 years ago

It was decided that a common util repo that will be used to host common functionality shared between resource-management projects e.g sriov-cni, sriov-device-plugin, network-resource-injector and sriov-network-operator is desirable as it will reduce code duplication and maintenance.

Currently for repositories like SRIOV CNI / SRIOV CNI Operator / Network Resources Injector and Device Plugin there is or will be a set of E2E tests that are using utils from util package. The set of packages inside allows for instance to create / delete K8s objects, read interface details. Those packages are almost similar in implementation between repositories and most probably could be implemented in one place and imported by each component. Beside tests such utils can be used in code if needed.

Some examples: https://github.com/k8snetworkplumbingwg/network-resources-injector/tree/master/test/util https://github.com/k8snetworkplumbingwg/sriov-network-operator/tree/master/test/util https://github.com/k8snetworkplumbingwg/sriov-network-device-plugin/tree/master/pkg/utils https://github.com/k8snetworkplumbingwg/sriov-cni/tree/master/pkg/utils

next steps are:

MichalGuzieniuk commented 3 years ago

I like the idea of this repository as a place for a common code between network plumbing repositories. I know that on the meetings we are now discussing functions that are going to be moved as a first one. Those functions are from utils packages.

But on the other hand we have E2E tests that also contains a lot of duplicated code. Currently I'm working on E2E tests for SRIOV CNI and NRI and I would like to utilize this repository to keep utils from tests in one place instead of making copy and paste. Please take those two files as an example

My question is about structure of this repository. I suppose that is would be good to split utils used purely in tests from utils used in production code. Will be there two or more packages inside this module?

For instance such folder structure. Is it acceptable?

- utils
      utils.go
- test
--- utils
------ pod 
            pod.go
------ configmap
            configmap.go
------ nad
            networkattachmentdefinition.go
adrianchiris commented 3 years ago

IMO we should definitely have a test folder. for simplicity perhaps just put all k8s object test util files under the same folder ? (especially if they will all eventually share the same package name)

e.g:

- test
--- utils
------ k8sresources
--------- pod.go
--------- configmap.go
--------- nad.go

this effort can be separate from moving non test related functionality.

PR is welcome :)