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

allow override chroot with New() #13

Merged
merged 1 commit into from Nov 13, 2018
Merged

allow override chroot with New() #13

merged 1 commit into from Nov 13, 2018

Conversation

jaypipes
Copy link
Owner

Adds the ability to override the CHROOT and whether to only use the
cached pciids file using options passed to the pcidb.New() function.
The chroot still defaults to the PCIDB_CHROOT environs variable value,
if set, but now it's possible to set this configuration value like so:

pci := pcidb.New(pcidb.WithChroot("/override"))

Issue #12

Adds the ability to override the CHROOT and whether to only use the
cached pciids file using options passed to the `pcidb.New()` function.
The chroot still defaults to the PCIDB_CHROOT environs variable value,
if set, but now it's possible to set this configuration value like so:

```go
pci := pcidb.New(pcidb.WithChroot("/override"))
```

Issue #12
@jaypipes
Copy link
Owner Author

@chiptus @deviantony mind taking a look at this PR?

@chiptus
Copy link
Contributor

chiptus commented Nov 13, 2018 via email

@jaypipes
Copy link
Owner Author

@chiptus most of the new code is actually just moved from the discover.go module (where it was hard-coding the lookup of environ vars) to the main.go module, so not a whole lot of new code. I needed to use the pointer-to-string and pointer-to-bool stuff in order to check for the absence of values.

I was modeling the WithChroot(), WithCacheOnly() modifier functions after the way that etcd's clientv3.KVS class works, where you can pass zero or more WithSort() or WithPrefix() modifiers to methods like Op.Put(). I found it a nice and consistent user experience that allows using the same function/method without any modifiers and still get a coherent interface.

Anyway, thanks for taking a look! :)

-jay

@jaypipes jaypipes merged commit 4bdeb34 into master Nov 13, 2018
@jaypipes jaypipes deleted the issue12 branch November 13, 2018 19:14
@deviantony
Copy link

deviantony commented Nov 13, 2018

Ah it's merged already, sorry, TZ issue I guess :-)

Thanks @jaypipes

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.

None yet

3 participants