Skip to content

Allow to download files related to cloud-init via http(s)#172

Merged
StefanScherer merged 2 commits intohypriot:masterfrom
witsch:http-downloads
Apr 10, 2020
Merged

Allow to download files related to cloud-init via http(s)#172
StefanScherer merged 2 commits intohypriot:masterfrom
witsch:http-downloads

Conversation

@witsch
Copy link
Contributor

@witsch witsch commented Apr 3, 2020

With this URLs can be specified instead of local files for --bootconf, --config, --userdata, --metadata and --file.

Now URLs can be specified instead of local files for `--bootconf`,
`--config`, `--userdata`, `--metadata` and `--file`.
@StefanScherer
Copy link
Member

Thank you @witsch that sounds Like a super cool feature! I‘ll have a look at it soon.

@witsch
Copy link
Contributor Author

witsch commented Apr 3, 2020

Hmm, unfortunately the tests fail, but locally I've had the same strange failure for the "cloud-init: flash --metadata replaces meta-data" test I borrowed from…

> flash-test@0.0.1 test /code
> if [ -e ../node_modules/.bin/bats ]; then ../node_modules/.bin/bats --tap test; else node_modules/.bin/bats --tap test; fi

1..28
ok 1 cloud-init: flash aborts if YAML is not valid
ok 2 cloud-init: flash works
ok 3 cloud-init: flash --hostname sets hostname
ok 4 cloud-init: flash --ssid does NOT set ssid as it's COMMENTED in default image
ok 5 cloud-init: flash --password does NOT set psk as it's COMMENTED in default image
ok 6 cloud-init: flash --ssid still sets ssid when user-data also specified
ok 7 cloud-init: flash --password still sets psk when user-data also specified
ok 8 cloud-init: flash --ssid does NOT set ssid if COMMENTED when user-data also specified
ok 9 cloud-init: flash --password does NOT set psk if COMMENTED when user-data also specified
ok 10 cloud-init: flash --config does not replace user-data
ok 11 cloud-init: flash --userdata replaces user-data
not ok 12 cloud-init: flash --metadata replaces meta-data
# (from function `assert_contains' in file test/../../node_modules/bats-assert/all.bash, line 63,
#  from function `assert_output_contains' in file test/../../node_modules/bats-assert/all.bash, line 98,
#  in test file test/cloud-init.bats, line 212)
#   `assert_output_contains "hostname: good"' failed
# expected:   instance-id: iid-local01
# to contain: hostname: good
ok 13 cloud-init: flash --bootconf replaces config.txt
ok 14 cloud-init: flash --userdata can be downloaded
not ok 15 cloud-init: flash --metadata replaces meta-data
# (from function `assert_contains' in file test/../../node_modules/bats-assert/all.bash, line 63,
#  from function `assert_output_contains' in file test/../../node_modules/bats-assert/all.bash, line 98,
#  in test file test/cloud-init.bats, line 212)
#   `assert_output_contains "hostname: good"' failed
# expected:   instance-id: iid-local01
# to contain: hostname: good
ok 16 cloud-init: flash --userdata aborts on 'not found' (404)
ok 17 device-init: flash works
ok 18 device-init: flash --hostname sets hostname
ok 19 device-init: flash --ssid sets WiFi
ok 20 device-init: flash --config replaces device-init.yaml
ok 21 device-init: flash --bootconf replaces config.txt
ok 22 fake-hwclock: flash updates fake-hwclock.data
ok 23 flash with url to img.zip works
ok 24 # skip (Download is really slow and the use-case very rare) flash with url to img.xz works
ok 25 # skip (Download is really slow) flash with url to Raspbian LITE zip works
ok 26 flash --help shows usage
ok 27 flash without parameters shows usage
ok 28 flash --version shows version dirty
npm ERR! Test failed.  See above for more details.
make: *** [test] Error 1

I suppose I'll leave that assertion out of the new one as setting the hostname correctly is actually unrelated to downloading the file, right?

@witsch
Copy link
Contributor Author

witsch commented Apr 3, 2020

I suppose I'll leave that assertion out of the new one as setting the hostname correctly is actually unrelated to downloading the file, right?

Oops, turns out to be a bad "copy & paste"… 😊 It should be fixed in 024db1f.

Copy link
Member

@StefanScherer StefanScherer left a comment

Choose a reason for hiding this comment

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

Thank you, that's really convenient, I can put my user-data file to GitHub :-)

./flash -n test -u https://raw.githubusercontent.com/StefanScherer/docker-at-home/master/user-data https://github.com/hypriot/image-builder-rpi/releases/download/v1.12.0/hypriotos-rpi-v1.12.0.img.zip

And thanks for the test!
LGTM

@StefanScherer StefanScherer merged commit af94d51 into hypriot:master Apr 10, 2020
@witsch
Copy link
Contributor Author

witsch commented Apr 11, 2020

Thank you, that's really convenient, I can put my user-data file to GitHub :-)

Yes, that was the idea… after I recently got a new Pi and found HyprioOS (big props, btw) I started playing with Docker stacks (and I suppose that was mainly because of that blog post you guys put up), but most of the examples I found were either using compose or didn't quite work out of the box. Or at least for me, albeit not being very familar with the topic didn't help… 🙂

Anyway, after figuring a few things out I thought it might be useful to make it available somewhere, and at that point it just seemed nice to be able to avoid the extra step of downloading an example user-data file to get you started. But now I can… 😄

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