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

add resin config generate --ethernet and --wifi options for noninteractive cli #410

Closed
hh opened this issue Dec 2, 2016 · 5 comments
Closed

Comments

@hh
Copy link

hh commented Dec 2, 2016

Currently resin config generate does not allow specifying all necessary options via the cli.
It requires navigating with arrow keys interactively via console rather than specifying parameters.

$ resin config generate --app iichip --output config.json 
? Network Connection (Use arrow keys)
❯ ethernet 
  wifi 

This poses a problem to automation pipelines which currently need a work around using something like expect:

https://gitlab.ii.org.nz/iichip/resin-cli/blob/latest/config.exp

#!/usr/bin/expect -f
spawn resin config generate --app "$env(APP)" --output config.json
match_max 100000
expect "ethernet"
send -- "\r"
expect "Check for updates every X minutes"
send -- "\r"
expect eof

Our work around just hit's enter twice to enable ethernet, but adding wifi configuration to the pipeline would be great.

@ii wrapped this expect into a Docker container to allow us to generate the config.json during our resin-os image bulid:

docker pull iichip/resin-cli
docker run -e EMAIL="$EMAIL" \
           -e APP="$APP" \
           -e PASSWORD="$PASSWORD" iichip/resin-cli > config.json

Front logo Front conversations

@hh hh changed the title add resin config generate --etherent and --wifi options for noninteractive cli add resin config generate --ethernet and --wifi options for noninteractive cli Dec 2, 2016
@jviotti
Copy link
Contributor

jviotti commented Dec 5, 2016

Hey there,

Thanks for the suggestion, it sounds like a good addition. The problem is that the set of question we ask to be able to generate a config.json comes from an external service (the CLI blindly asks such questions), so hardcoding --wifi/--ethernet options would not be a possible way forward. As a consequence, we have to add some way for allowed options to be computed at runtime, or put a generic option what you can pass any set of key/value combinations that will be applied on top of the retrieved question list. We could also accept a path to a json file containing certain defaults, like networkType: 'wifi'. Would that suit your needs?

@hh
Copy link
Author

hh commented Dec 5, 2016

Paired with a --show-opts and --generate-opt-file fill-me-out.json/yaml I think we have a winning combination!

Is there an API test suite or documentation area that addresses config generate and friends?
A quick look at https://docs.resin.io/runtime/data-api/ didn't reveal anything.

@jviotti
Copy link
Contributor

jviotti commented Dec 5, 2016

Sounds good! I'll try to allocate some time for this soon. In order to get unblocked, you could use https://github.com/resin-io-modules/resin-device-config, which is the low-level module that generates configuration to create a simple script that does what you want. You could also take a look at https://github.com/resin-io/resin-config-json, which is the module that injects config.json to the device, in case you need that as well!

@imrehg
Copy link
Contributor

imrehg commented Apr 21, 2017

In general I get quite a few requests for completely non-interactive resin config generate (so it's possible to use the script automated). Would that be possible to include in the near-term updates? Would help with things like the workflow we've shown in our preloading and preprovisioning blogpost

pimterry added a commit that referenced this issue Nov 14, 2017
pimterry added a commit that referenced this issue Nov 14, 2017
pimterry added a commit that referenced this issue Nov 16, 2017
@pimterry
Copy link
Contributor

Fixed and released in 6.9.0, see the docs for config generate for the full details.

Example:

resin config generate --app MyApp --network wifi --wifiSsid mySsid --wifiKey abcdefgh --appUpdatePollInterval 1

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

No branches or pull requests

4 participants