GithubHelp home page GithubHelp logo

hcloud-ruby's People

Contributors

bastelfreak avatar coorasse avatar dependabot[bot] avatar kjarrigan avatar markusfreitag avatar raphaelpour avatar skoch-hc avatar tonobo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hcloud-ruby's Issues

Doubles tests failure with seed 50938

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

[Bug] Firewalls do not expose actions

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()

[Feature] Add missing Resources/Endpoints Q1/2022

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

  • Actions
  • Certificates missing #26
  • Certificate Actions missing #26
  • Datacenters
  • Firewalls missing #25
  • Firewall Actions missing #25
  • Floating IPs - field:labels missing #12
  • Floating IP Actions
  • Images - field:labels missing #12
  • Image Actions - get action(s) missing #30
  • ISOs
  • Load Balancers missing #29
  • Load Balancer Actions missing #29
  • Load Balancer Types missing #29
  • Locations
  • Networks - field:labels missing #12 #26
  • Network Actions get action(s) + change_ip_range missing
  • Placement Groups missing #27
  • Pricing missing #28
  • Servers - field:labels missing #12 + get-metrics missing
  • Server Actions - change_dns_ptr missing #30
  • Server Types
  • SSH Keys - field:labels missing #12
  • Volumes - field:labels missing #12
  • Volume Actions

Thank you!

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!

[CI] Change fake service tests to integration tests

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.

Support Ruby 3.0+

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))

Documentation for busy waiting

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 ?

[Enhancement] Make Typhoeus call check more natural to read

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

ARM64 Support

Hetzner Cloud released ARM64 servers, we have to check whether everything is supported and add missing functionality to hcloud-ruby.

  • Server Types support a filter architecture in queries (Docs)
  • Server Types have a new attribute architecture (Docs)
  • Images support a filter architecture in queries (Docs)
  • Images might also have an attribute architecture? Could not find it in the API Docs, though
  • ISOs have two new filters architecture and include_architecture_wildcard (Docs)
  • ISOs have a new attribute architecture (Docs)

1.2.0 release raises `undefined method 'blank?'` errors

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).

[Bug] IPv6 global address is not parsed correctly

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"]}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.