8000 More flexibility in configuration · Issue #17 · tlkamp/litter-exporter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

More flexibility in configuration #17

New issue

Have a question about this project? Sign up for 8000 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

Closed
Starttoaster opened this issue Jul 20, 2022 · 9 comments · Fixed by #22
Closed

More flexibility in configuration #17

Starttoaster opened this issue Jul 20, 2022 · 9 comments · Fixed by #22
Labels

Comments

@Starttoaster
Copy link
Starttoaster commented Jul 20, 2022

It would be a nice-to-have for setting these values with either a yaml config, or environment variables.

The yaml config would be nice for Kubernetes deployments, as you could mount a k8s Secret object in the container.

Environment variables are a bit of a lower hanging fruit. But would be nice to have as it's a pattern for configuring behavior inside containers that people are accustomed to.

I could help with this if you're interested. I'll probably have already forked this repo and done it for my own use.

@tlkamp
Copy link
Owner
tlkamp commented Jul 20, 2022

Referring to these?

https://github.com/tlkamp/litter-exporter/blob/main/main.go#L12-L22

I think that would be pretty easy to implement. I would be happy to do the implementation, but I'll also accept contributions :)

@Starttoaster
Copy link
Author
Starttoaster commented Jul 20, 2022

Yup! Referring to those. Either way is fine with me, if you would like to write it, I won't argue.

I'm actually trying to debug a different issue I'm having anyway. On the call to the login() function in tlkamp/litter-api, I'm getting the error time="2022-07-20T00:39:38Z" level=error msg="failed to parse token claims" error="token contains an invalid number of segments" so perhaps something regarding the JWT token returned from the litter robot API was altered. (Understanding that this convo is better suited for a different Issue, and if you'd like, I could open one up for it. Otherwise I'm fine with getting to the bottom of it too.)

@tlkamp
Copy link
Owner
tlkamp commented Jul 20, 2022

I think you are likely having an auth configuration issue as everything is working fine for me.

@Starttoaster
Copy link
Author
Starttoaster commented Jul 20, 2022

I think you are likely having an auth configuration issue as everything is working fine for me.

You're right. After a bit of digging, I found I actually needed the -client-id and -client-secret flags, and I used the values I found on a random google search result lol: https://raw.githubusercontent.com/dcmeglio/hubitat-litterrobot/master/smartapps/natekspencer/litter-robot-manager.src/litter-robot-manager.groovy

Not sure if that was expected... but the README implies the exporter should start without those flags... hence the confusion 😄

edit: Though I'm seeing now that if I were to read the content of the docs directory, it also says as much. (The example on the readme is just a bit misleading I guess.)

@tlkamp
Copy link
Owner
tlkamp commented Jul 20, 2022

The architecture of the Litter Robot API appears to be an AWS API Gateway fronting a Python Lambda function, and the API Gateway seems to require the various tokens. The only way to obtain them has been to reverse engineer the mobile phone apps since the API isn't exactly public or documented, but the values mentioned in the example do work:
https://github.com/tlkamp/litter-exporter/blob/main/doc/examples/docker-compose.yml

I can set them as defaults in the CLI.

@Starttoaster
Copy link
Author

The values in that docker-compose file do get this working for me. I don't currently have any litter robot related metrics showing up on the exporter, just the default ones that the prometheus library self-reports. But for now I'm assuming that's just because I got my Litter Robot last night and my cats haven't used it yet 😂

@tlkamp
Copy link
Owner
tlkamp commented Jul 20, 2022

Possible! You should see some configuration related information at the very least. You can always cycle it manually to force it though :)

tlkamp added a commit that referenced this issue Jul 21, 2022
Adds defaults for client ID, API key and client secret, which are set to
values that have been reverse engineered from the mobile app.

See #17
tlkamp added a commit that referenced this issue Jul 21, 2022
Adds defaults for client ID, API key and client secret, which are set to
values that have been reverse engineered from the mobile app.

See #17
tlkamp pushed a commit that referenced this issue Jul 21, 2022
# [1.5.0](v1.4.2...v1.5.0) (2022-07-21)

### Features

* **cli:** add defaults for some args ([#19](#19)) ([1ab4e0e](1ab4e0e)), closes [#17](#17)
tlkamp added a commit that referenced this issue Jul 23, 2022
Supports environment variables as configuration options. Uses Viper and Pflag to achieve this
functionality.

BREAKING CHANGE: Pflag does not support multi-character shorthands for flags, so double hyphens are
now required for all flags being passed via CLI.

Closes #17
@tlkamp
Copy link
Owner
tlkamp commented Jul 23, 2022

@Starttoaster I have a PR open for environment variable support now. Please have a look and confirm this is what you imagined.

Also note the breaking changes.

tlkamp added a commit that referenced this issue Jul 23, 2022
Supports environment variables as configuration options. Uses Viper and Pflag to achieve this
functionality.

BREAKING CHANGE: Pflag does not support multi-character shorthands for flags, so double hyphens are
now required for all flags being passed via CLI.

Closes #17
@tlkamp tlkamp closed this as completed in 7f90542 Jul 23, 2022
tlkamp pushed a commit that referenced this issue Jul 23, 2022
# [2.0.0](v1.5.1...v2.0.0) (2022-07-23)

### Features

* support environment variables ([#22](#22)) ([7f90542](7f90542)), closes [#17](#17)

### BREAKING CHANGES

* Pflag does not support multi-character shorthands for flags, so double hyphens are
now required for all flags being passed via CLI.
@tlkamp
Copy link
Owner
tlkamp commented Jul 23, 2022

🎉 This issue has been resolved in version 2.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0