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

Support specifying options in module constructors #88

Merged
merged 4 commits into from
Nov 15, 2018
Merged

Conversation

jaypipes
Copy link
Owner

Each module (CPU(), Memory(), Network(), etc...) now supports calling
the main module constructor with zero or more pointers to WithOption
structs. There is only a single option (the CHROOT value for path
construction) but I've designed it so the system is flexible for future
additional options without needing to change the calling interface.

To specify a chroot override for a particular module, use the
WithChroot() function, like so:

mem, err := ghw.Memory(WithChroot("/host"));

Issue #86

Removes the instantiation of a possibly incomplete HostInfo struct from
the Host() function implementation, only returning a complete HostInfo
struct if all member fields have been properly constructed.
There were a few places where the memory_linux.go module was still
relying on hard-coded filepaths and not using the path_linux.go
functions to append the GHW_CHROOT path properly. Since the next patch
will add support for passing chroot as options, this patch gets those
straggler hard-coded paths sorted.
Each module (CPU(), Memory(), Network(), etc...) now supports calling
the main module constructor with zero or more pointers to WithOption
structs. There is only a single option (the CHROOT value for path
construction) but I've designed it so the system is flexible for future
additional options without needing to change the calling interface.

To specify a chroot override for a particular module, use the
WithChroot() function, like so:

```go
mem, err := ghw.Memory(WithChroot("/host"));
```

Issue #86
@jaypipes
Copy link
Owner Author

@deviantony @chiptus if you have the opportunity to pull this commit (78e8fd3) and test it in your environment before I merge, that would be great. :)

@deviantony
Copy link

@jaypipes we will test this PR in our env, thanks !

@chiptus
Copy link

chiptus commented Nov 15, 2018

@jaypipes, thanks for all your work, we really appreciate it.

our problem is mostly with pcidb, so we can't test it until the new version of pcidb is in.

@jaypipes
Copy link
Owner Author

Ah, OK. Let me do the remaining work for pcidb, cut a release and then use the new release in ghw.

@jaypipes jaypipes merged commit 4025af8 into master Nov 15, 2018
@jaypipes jaypipes deleted the issue86 branch January 29, 2019 19:09
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.

3 participants