Skip to content

added config path to Service interface#255

Open
jasmingacic wants to merge 7 commits intokardianos:masterfrom
jasmingacic:configpath
Open

added config path to Service interface#255
jasmingacic wants to merge 7 commits intokardianos:masterfrom
jasmingacic:configpath

Conversation

@jasmingacic
Copy link
Copy Markdown

For some sort of automations it is practical to get information where service files are stored.

@kardianos
Copy link
Copy Markdown
Owner

This may be alright. But, the ConfigPath would need to be a separate interface; right now it breaks windows I think.

@jasmingacic
Copy link
Copy Markdown
Author

jasmingacic commented Dec 17, 2020 via email

@kardianos
Copy link
Copy Markdown
Owner

GOOS=windows go build .

@jasmingacic
Copy link
Copy Markdown
Author

@kardianos Fixed it for windows.

I also wanted to check with you if I did it right. In most of cases I renamed configPath() string, error to ConfigPath()string and refactored accordingly. Do you think that's the best approach or maybe it should be done differently?

@kardianos
Copy link
Copy Markdown
Owner

So yes, for this change to happen:

  • Make the ConfigPath return (string error).
  • Remove it from the service interface.
  • Make an optional interface it may support (windows won't implement).
  • Require a type assertion for it to use.

@jasmingacic
Copy link
Copy Markdown
Author

jasmingacic commented Dec 17, 2020

@kardianos Do you mind if I call the optional interface ConfigInfo? (I can't think of a better name right now)

@kardianos
Copy link
Copy Markdown
Owner

No. How about Metaer :) or ConfigPather

hmmm, maybe PatholoConfiger ... I'm getting worse.

Not Config, but maybe not PatholoConfiger either.

@jasmingacic
Copy link
Copy Markdown
Author

I think ConfigInfo sound ok then we can have ConfigPath and what other information might be stored there.

@jasmingacic
Copy link
Copy Markdown
Author

@kardianos I just refactored it to use the optional interface ConfigInfo, later we can decide on the name.

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 17, 2020

Coverage Status

Coverage increased (+1.1%) to 13.9% when pulling f509d03 on jasmingacic:configpath into ef35c56 on kardianos:master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.3%) to 12.525% when pulling 20d92e3 on jasmingacic:configpath into ef35c56 on kardianos:master.

Copy link
Copy Markdown
Owner

@kardianos kardianos left a comment

Choose a reason for hiding this comment

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

Ensure you run
go mod tidy
and go fmt
prior to commit.

Comment thread service.go Outdated
Comment thread service.go Outdated
Comment thread service.go Outdated
Comment thread service.go Outdated
Comment thread linux_test/Makefile
Comment thread service.go Outdated
Comment thread service.go Outdated
Comment thread service_aix.go Outdated
Comment thread linux_test/Makefile
@jasmingacic
Copy link
Copy Markdown
Author

@kardianos can you help me out with the test for ConfigPath how do you want to have it implemented?

@kardianos
Copy link
Copy Markdown
Owner

Go ahead and read the diffs and correct the other OSes. Also, no need to have an exported method and un-exported method that do the same thing. Just use the exported method.

@jasmingacic
Copy link
Copy Markdown
Author

So getting config value like this is fine?

	_, err = s.(service.ConfigInfoer).ConfigPath()

Also I'm not sure what you mean by read the diffs and correct the other OSes, I already did that. Unless I'm missing something.

Copy link
Copy Markdown
Owner

@kardianos kardianos left a comment

Choose a reason for hiding this comment

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

Please read all my comments carefully this time. Please read your diffs carefully.

Comment thread service_aix.go Outdated
Comment thread service_freebsd.go Outdated
Comment thread service_openrc_linux.go Outdated
Comment thread service_solaris.go Outdated
Comment thread service_systemd_linux.go Outdated
Comment thread service_upstart_linux.go Outdated
Comment thread service_test.go
t.Fatalf("New err: %s", err)
}

_, err = s.(service.ConfigInfoer).ConfigPath()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Is this test valid?

@jasmingacic
Copy link
Copy Markdown
Author

ping

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.

4 participants