Skip to content

fix: Minor bug/typo in parseWinCertStoreType that ignored the passed in parameter #662

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

johnweldon
Copy link

converted the function to non-member, to reduce unnecessary dependencies

…in parameter

made the function non-member to reduce unnecessary dependencies
@@ -415,8 +415,7 @@ func (c *Context) NATSOptions(opts ...nats.Option) ([]nats.Option, error) {
return nopts, nil
}

func (c *Context) parseWinCertStoreType(t string) (certstore.StoreType, error) {
storeTypeString := c.config.WinCertStoreType
func parseWinCertStoreType(storeTypeString string) (certstore.StoreType, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which dependencies do you mean here when you say reduce dependencies? With functions like certStoreNatsOptions() this feels correctly placed - the purpose of it (see below) is to act on the *Context configuration.

Not clear to me how this was actually broken - sure it ignores t string argument but it always acts on c.config.WinCertStoreType which is the only thing it's ever being called with. Was it broken?

I think the correct thing is to keep it attached to *Context and just remove the argument t string, since its only ever called with the value it was acting on anyway

So it's basically just this:

func (c *Context) parseWinCertStoreType() (certstore.StoreType, error) {
	switch c.config.WinCertStoreType {
	case "machine":
		return certstore.ParseCertStore("windowslocalmachine")
	case "user":
		return certstore.ParseCertStore("windowscurrentuser")
	default:
		return certstore.ParseCertStore(c.config.WinCertStoreType)
	}
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make that change. I could go either way, and just picked the more functional, less object oriented, approach; but the oo approach is perfectly reasonable too

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.

2 participants