SUSE / connect-ng

Other
9 stars 16 forks source link

collectors: add detection of container runtimes #243

Closed mssola closed 3 months ago

mssola commented 3 months ago

How to test it

Podman/Docker:

# change the command to `podman` if using podman, but the rest is the same.
$ docker run --rm --privileged -ti -v (pwd):/connect registry.suse.com/bci/golang:1.21-openssl
> cd /connect; git config --global --add safe.directory /connect
> zypper in -y dmidecode systemd
> make build
> ./out/suseconnect -r <regcode>
> ./out/suseconnect --debug --keepalive

Expect: "container_runtime": "docker" (or "podman" in case of podman).

Not containerized:

1. Grab a VM with an OS that can be registered.
2. Build and copy the executable into the VM.
3. Then run:
    $ ./out/suseconnect -r <regcode>
    $ ./out/suseconnect --debug --keepalive

Expect: no container_runtime in the sent data.

Tests

None have been provided since we would basically need to mock the whole thing. Thus, there is not much of a point on doing this.

mssola commented 3 months ago

[CAT] Detect container runtime

mssola commented 3 months ago

@felixsch @josegomezr I have re-written the implementation so we are now not importing the package, but we are actually using just the functions we need. The main rationale being:

mssola commented 3 months ago

Note: I have changed container-runtime to container_runtime. I have updated the test instructions.