tonobo / hcloud-ruby Goto Github PK
View Code? Open in Web Editor NEWNative ruby client for HetznerCloud
License: MIT License
Native ruby client for HetznerCloud
License: MIT License
Hetzner Cloud released ARM64 servers, we have to check whether everything is supported and add missing functionality to hcloud-ruby.
architecture
in queries (Docs)architecture
(Docs)architecture
in queries (Docs)architecture
? Could not find it in the API Docs, thougharchitecture
and include_architecture_wildcard
(Docs)architecture
(Docs)Build gem and push it to the rubygem mirror.
it might make sense to delineate it from:
https://github.com/floriandejonckheere/hcloud
When using the IPv6 address ::/0
in a firewall rule, we will get the Ruby symbol :":/0"
as a parsed response. I was able to trace it down to Oj.load
changing the string in parsed_json
in entry_loader.rb
.
To my understanding, this is probably related to this discussion: ohler55/oj#285
I have to admit, I do not get the arguments of the Oj developers, either. If Oj.load('{"foo": ":"}')
does not work, this looks broken. If I get them right, then using the default mode: :object
is almost always the wrong thing to do. When parsing JSON data that was not generated with Oj, it seems we need to use mode: :compat
.
Here's a minimal reproducing example:
require 'oj'
data = '{"foo": ["::/0"]}'
p "Input data is:"
p data
puts "\n"
p "Oj parsed result with default mode is:"
p Oj.load(data)
puts "\n"
p "Oj parsed result with compat mode is:"
p Oj.load(data, mode: :compat)
with the output:
"Input data is:"
"{\"foo\": [\"::/0\"]}"
"Oj parsed result with default mode is:"
{"foo"=>[:":/0"]}
"Oj parsed result with compat mode is:"
{"foo"=>["::/0"]}
Rspec tests usually follow a human-readable schema that's almost an English sentence.
We currently check whether a Typhoeus stub was called with expect(stub.times_called).to eq(1)
. Side note: times_called
uses Typhoeus private data.
Rspec, at least for yield_control
, has expect { ... }.to yield_control.twice
and similar tests. Following the same design as yield_control
we could implement the following have_been_called
matcher:
expect(stub).to have_been_called
expect(stub).to have_been_called.once
expect(stub).to have_been_called.exactly(k).times
expect(stub).to have_been_called.at_most(k).times
expect(stub).to have_been_called.at_least(k).times
activesupport
is currently pinned to the last 6.*
version due to some autoload problems with 7.*
.
It's been a while since someone worked on this project so there is a bit of a gap between what you can do through the API and through this gem, so we should go through the API and check what is actually missing and then create issues to close the gaps (e.g. LoadBalancer
are missing as well as PlacementGroups
)
So all unchecked entries are not yet checked for differences - based on the official docs
We found a situation in which the doubles tests do not run successfully with random order. The following seed breaks the tests:
bundle exec rspec -t doubles --order rand --seed 50938
When I implemented firewalls, I forgot to return the actions from the API to the caller.
The API returns a JSON
{
"actions": [...],
"firewall": {...}
}
but firewall = client.firewalls.create(...)
only returns the firewall.
The behavior of other create
methods with actions is:
action, foo = client.foos.create() # e.g. floating IP
action, foo, next_actions = client.foos.create() # e.g. servers and volumes
The natural behavior of firewalls thus should be:
actions, fw = client.firewalls.create()
GitHub is pretty weird with it's workflows. We currently can't trigger any CI Runs for external contributions. Seems like we need to add an workflow_dispatch
trigger:
https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
We are using doubles tests as our primary unit testing mechanism now (spec/hcloud/
and spec/doubles/
). We are planning to keep the older fake service tests and use them as integration tests for the real API.
At the moment they are in the folder spec/integration/
, but still behave in the old way using the fake service from spec/fake_service/
. We want to completely delete the fakes in spec/fake_service/
and instead use the real API for testing.
A quick first test showed that this will require several adjustments to the code, because currently the tests expect to start in a clean project with 0 other resources. This is not granted in the CI project. We have to make sure that tests also work when there are already other resources in the cloud project.
Thanks for the gem,
how can I "busy wait" for an Action to complete. This does not update the status of the action:
action,server = c.servers.create(name: "moo5", server_type: "cx11", image: "ubuntu-16.04")
while true do
puts action.status
puts server.status
puts server.public_net["ipv4"]
sleep 1
end
In general how to I refetch a server or any other resource for status updates ?
Thanks for maintaining this gem. It's already helpful - I use it to manage my son's Minecraft server (which is, as you can imagine, pretty essential for a 14-year old).
Keep up the good work!
Currently the update
method returns a new object, but it should also update itself.
3.0.0 :002 > c = Hcloud::Client.new(token: t)
=> #<Hcloud::Client:0x0000558be8697980 @token="yOafprj2IMQZ2GFOtgCbZmgIDJfiwnt96LmNaF5o0hgaXR8rjDU0peM5Kouur6NR", @user_agent="hcloud-ruby v1.0.2", @auto_pagination=false, @concurrency=20, @hydra=#<Typhoeus::Hydra:0x0000558be8c3e5c8 @options={:max_concurrency=>20}...
3.0.0 :003 > c.servers.map(&:name)
Traceback (most recent call last):
10: from ~/.rvm/rubies/ruby-3.0.0/bin/irb:23:in `<main>'
9: from ~/.rvm/rubies/ruby-3.0.0/bin/irb:23:in `load'
8: from ~/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/irb-1.3.0/exe/irb:11:in `<top (required)>'
7: from (irb):3:in `<main>'
6: from (irb):3:in `map'
5: from ~/.rvm/gems/ruby-3.0.0/gems/hcloud-1.0.2/lib/hcloud/abstract_resource.rb:142:in `each'
4: from ~/.rvm/gems/ruby-3.0.0/gems/hcloud-1.0.2/lib/hcloud/abstract_resource.rb:133:in `run'
3: from ~/.rvm/gems/ruby-3.0.0/gems/hcloud-1.0.2/lib/hcloud/abstract_resource.rb:172:in `multi_query'
2: from ~/.rvm/gems/ruby-3.0.0/gems/hcloud-1.0.2/lib/hcloud/abstract_resource.rb:9:in `prepare_request'
1: from ~/.rvm/gems/ruby-3.0.0/gems/hcloud-1.0.2/lib/hcloud/client.rb:110:in `prepare_request'
ArgumentError (wrong number of arguments (given 2, expected 1))
Hi,
I updated from 1.1.0 to 1.2.0 and I cannot create ssh keys anymore. It aborts with this error:
undefined method `blank?' for "Beaker-runner-fv-az186-249-4769264692-2023-11-01_09_28_37_305488169":String
/home/runner/work/puppet-systemd/puppet-systemd/vendor/bundle/ruby/3.2.0/gems/hcloud-1.2.0/lib/hcloud/ssh_key_resource.rb:15:in `create'
/home/runner/work/puppet-systemd/puppet-systemd/vendor/bundle/ruby/3.2.0/bundler/gems/beaker-hcloud-5afc510af942/lib/beaker/hypervisor/hcloud.rb:67:in `create_ssh_key'
/home/runner/work/puppet-systemd/puppet-systemd/vendor/bundle/ruby/3.2.0/bundler/gems/beaker-hcloud-5afc510af942/lib/beaker/hypervisor/hcloud.rb:29:in `provision'
I noticed that between the 1.1.0 and 1.2.0 release a bunch of validation got added that checks strings with .blank?
. That's not a Ruby method for the String class but a Rails method. I assume the dependency is missing.
Steps to reproduce:
require 'hcloud'
# https://github.com/bastelfreak/beaker-hcloud/blob/label2/lib/beaker-hcloud/ssh_data_patches.rb
require_relative 'lib/beaker-hcloud/ssh_data_patches'
client = ::Hcloud::Client.new(token: token)
ssh_key_name = 'foo1234'
ssh_key = SSHData::PrivateKey::ED25519.generate
key_file = Tempfile.create(ssh_key_name)
File.write(key_file.path, ssh_key.openssh(comment: ssh_key_name))
hcloud_ssh_key = client.ssh_keys.create(name: ssh_key_name, public_key: ssh_key.public_key.openssh(comment: ssh_key_name))
This gives me:
NoMethodError: undefined method `blank?' for "foo123":String
```
After some digging around I noticed that activemodel has no version constraints which is quite bad. In 6.x `.blank?` is available, but not in 7 (or it got moved and we need to require something else, but I've no time to dig into this right now).
The auto_pagination handler will trigger a per page fetch for each entry.
I did not find primary IPs in the issue list or in the existing code
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.