hetzner-k3s 0.4.7 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e4c46ae74be52152443a9fab3b7b7dd00fa5e7cae5dffb99457b522646103ba
4
- data.tar.gz: e2495e717211c2351c2e203bd2741d3079e84729c305e8c6ad7434c24cf3d989
3
+ metadata.gz: c236d440e3e99f656c62b8ced99ac899199e435ca41e9675c4adeb326a87c5d8
4
+ data.tar.gz: fd8da58d3c4cc3b54018c1ff261f8606391e8f524b974660fc5984fcd10397f7
5
5
  SHA512:
6
- metadata.gz: c82cd916cdde9cec408d0681dc7d46902309bd1246424c8267ed2164345aef54e8e6eca8730c668b146245129450e1daabe97a698e2aca165e7f2a63cb9e5b0d
7
- data.tar.gz: 857abb763f92c64a65eeb2d484528708060db50aa121d7ccad847a5f6cbc2fec3c8d9a3873e8568ba2f03ea76ab53b529bc50267271d235b369d69e67d6c4f5a
6
+ metadata.gz: 8ebe7779e0f79ec500c1e0d230212cd568ef62e94a3dd2d936214f03f48baf8fc937a683b7bf4478b66a3dc0a7b02ee001a6fe3e542ad401f0add4ee27a68b03
7
+ data.tar.gz: dae117d8d1e3babf392814baf372009d1558113673a4968b7526a0a4e3a06b8eea034edaa11452047286721efc2a37af3e8214f2dbeafde73d864493feae5626
data/.rubocop.yml ADDED
@@ -0,0 +1,121 @@
1
+ Gemspec/DateAssignment: # new in 1.10
2
+ Enabled: true
3
+ Gemspec/RequireMFA: # new in 1.23
4
+ Enabled: true
5
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
6
+ Enabled: true
7
+ Layout/SpaceBeforeBrackets: # new in 1.7
8
+ Enabled: true
9
+ Lint/AmbiguousAssignment: # new in 1.7
10
+ Enabled: true
11
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
12
+ Enabled: true
13
+ Lint/AmbiguousRange: # new in 1.19
14
+ Enabled: true
15
+ Lint/DeprecatedConstants: # new in 1.8
16
+ Enabled: true
17
+ Lint/DuplicateBranch: # new in 1.3
18
+ Enabled: true
19
+ Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
20
+ Enabled: true
21
+ Lint/EmptyBlock: # new in 1.1
22
+ Enabled: true
23
+ Lint/EmptyClass: # new in 1.3
24
+ Enabled: true
25
+ Lint/EmptyInPattern: # new in 1.16
26
+ Enabled: true
27
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
28
+ Enabled: true
29
+ Lint/LambdaWithoutLiteralBlock: # new in 1.8
30
+ Enabled: true
31
+ Lint/NoReturnInBeginEndBlocks: # new in 1.2
32
+ Enabled: true
33
+ Lint/NumberedParameterAssignment: # new in 1.9
34
+ Enabled: true
35
+ Lint/OrAssignmentToConstant: # new in 1.9
36
+ Enabled: true
37
+ Lint/RedundantDirGlobSort: # new in 1.8
38
+ Enabled: true
39
+ Lint/RequireRelativeSelfPath: # new in 1.22
40
+ Enabled: true
41
+ Lint/SymbolConversion: # new in 1.9
42
+ Enabled: true
43
+ Lint/ToEnumArguments: # new in 1.1
44
+ Enabled: true
45
+ Lint/TripleQuotes: # new in 1.9
46
+ Enabled: true
47
+ Lint/UnexpectedBlockArity: # new in 1.5
48
+ Enabled: true
49
+ Lint/UnmodifiedReduceAccumulator: # new in 1.1
50
+ Enabled: true
51
+ Lint/UselessRuby2Keywords: # new in 1.23
52
+ Enabled: true
53
+ Naming/BlockForwarding: # new in 1.24
54
+ Enabled: true
55
+ Security/IoMethods: # new in 1.22
56
+ Enabled: true
57
+ Style/ArgumentsForwarding: # new in 1.1
58
+ Enabled: true
59
+ Style/CollectionCompact: # new in 1.2
60
+ Enabled: true
61
+ Style/DocumentDynamicEvalDefinition: # new in 1.1
62
+ Enabled: true
63
+ Style/EndlessMethod: # new in 1.8
64
+ Enabled: true
65
+ Style/FileRead: # new in 1.24
66
+ Enabled: true
67
+ Style/FileWrite: # new in 1.24
68
+ Enabled: true
69
+ Style/HashConversion: # new in 1.10
70
+ Enabled: true
71
+ Style/HashExcept: # new in 1.7
72
+ Enabled: true
73
+ Style/IfWithBooleanLiteralBranches: # new in 1.9
74
+ Enabled: true
75
+ Style/InPatternThen: # new in 1.16
76
+ Enabled: true
77
+ Style/MapToHash: # new in 1.24
78
+ Enabled: true
79
+ Style/MultilineInPatternThen: # new in 1.16
80
+ Enabled: true
81
+ Style/NegatedIfElseCondition: # new in 1.2
82
+ Enabled: true
83
+ Style/NilLambda: # new in 1.3
84
+ Enabled: true
85
+ Style/NumberedParameters: # new in 1.22
86
+ Enabled: true
87
+ Style/NumberedParametersLimit: # new in 1.22
88
+ Enabled: true
89
+ Style/OpenStructUse: # new in 1.23
90
+ Enabled: true
91
+ Style/QuotedSymbols: # new in 1.16
92
+ Enabled: true
93
+ Style/RedundantArgument: # new in 1.4
94
+ Enabled: true
95
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
96
+ Enabled: true
97
+ Style/SelectByRegexp: # new in 1.22
98
+ Enabled: true
99
+ Style/StringChars: # new in 1.12
100
+ Enabled: true
101
+ Style/SwapValues: # new in 1.1
102
+ Enabled: true
103
+ Style/Documentation:
104
+ Enabled: false
105
+ Metrics/MethodLength:
106
+ Enabled: false
107
+ Metrics/AbcSize:
108
+ Enabled: false
109
+ Metrics/CyclomaticComplexity:
110
+ Enabled: false
111
+ Metrics/ClassLength:
112
+ Enabled: false
113
+ Layout/LineLength:
114
+ Enabled: false
115
+ Metrics/PerceivedComplexity:
116
+ Enabled: false
117
+ Metrics/ParameterLists:
118
+ Max: 10
119
+ Style/FrozenStringLiteralComment:
120
+ Exclude:
121
+ - exe/hetzner-k3s
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.0
data/Dockerfile CHANGED
@@ -1,7 +1,10 @@
1
- FROM ruby:2.7.4-alpine
1
+ FROM ruby:3.1.0-alpine
2
2
 
3
3
  RUN apk update --no-cache \
4
- && apk add build-base git openssh-client
4
+ && apk add build-base git openssh-client curl bash
5
+
6
+ RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
7
+ && install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
5
8
 
6
9
  COPY . .
7
10
 
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in k3s.gemspec
4
6
  gemspec
5
7
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hetzner-k3s (0.4.5)
4
+ hetzner-k3s (0.5.0)
5
5
  bcrypt_pbkdf
6
6
  ed25519
7
7
  http
8
- k8s-ruby
9
8
  net-ssh
10
9
  sshkey
10
+ subprocess
11
11
  thor
12
12
 
13
13
  GEM
@@ -15,44 +15,16 @@ GEM
15
15
  specs:
16
16
  addressable (2.8.0)
17
17
  public_suffix (>= 2.0.2, < 5.0)
18
+ ast (2.4.2)
18
19
  bcrypt_pbkdf (1.1.0)
19
- concurrent-ruby (1.1.9)
20
20
  diff-lcs (1.4.4)
21
21
  domain_name (0.5.20190701)
22
22
  unf (>= 0.0.5, < 1.0.0)
23
- dry-configurable (0.13.0)
24
- concurrent-ruby (~> 1.0)
25
- dry-core (~> 0.6)
26
- dry-container (0.9.0)
27
- concurrent-ruby (~> 1.0)
28
- dry-configurable (~> 0.13, >= 0.13.0)
29
- dry-core (0.7.1)
30
- concurrent-ruby (~> 1.0)
31
- dry-equalizer (0.3.0)
32
- dry-inflector (0.2.1)
33
- dry-logic (0.6.1)
34
- concurrent-ruby (~> 1.0)
35
- dry-core (~> 0.2)
36
- dry-equalizer (~> 0.2)
37
- dry-struct (0.5.1)
38
- dry-core (~> 0.4, >= 0.4.3)
39
- dry-equalizer (~> 0.2)
40
- dry-types (~> 0.13)
41
- ice_nine (~> 0.11)
42
- dry-types (0.13.4)
43
- concurrent-ruby (~> 1.0)
44
- dry-container (~> 0.3)
45
- dry-core (~> 0.4, >= 0.4.4)
46
- dry-equalizer (~> 0.2)
47
- dry-inflector (~> 0.1, >= 0.1.2)
48
- dry-logic (~> 0.4, >= 0.4.2)
49
- ed25519 (1.2.4)
50
- excon (0.85.0)
51
- ffi (1.15.3)
23
+ ed25519 (1.3.0)
24
+ ffi (1.15.5)
52
25
  ffi-compiler (1.0.1)
53
26
  ffi (>= 1.0.0)
54
27
  rake
55
- hashdiff (1.0.1)
56
28
  http (4.4.1)
57
29
  addressable (~> 2.3)
58
30
  http-cookie (~> 1.0)
@@ -63,24 +35,15 @@ GEM
63
35
  http-form_data (2.3.0)
64
36
  http-parser (1.2.3)
65
37
  ffi-compiler (>= 1.0, < 2.0)
66
- ice_nine (0.11.2)
67
- jsonpath (0.9.9)
68
- multi_json
69
- to_regexp (~> 0.2.1)
70
- k8s-ruby (0.10.5)
71
- dry-struct (~> 0.5.0)
72
- dry-types (~> 0.13.0)
73
- excon (~> 0.71)
74
- hashdiff (~> 1.0.0)
75
- jsonpath (~> 0.9.5)
76
- recursive-open-struct (~> 1.1.0)
77
- yajl-ruby (~> 1.4.0)
78
- yaml-safe_load_stream (~> 0.1)
79
- multi_json (1.15.0)
80
38
  net-ssh (6.1.0)
39
+ parallel (1.21.0)
40
+ parser (3.1.0.0)
41
+ ast (~> 2.4.1)
81
42
  public_suffix (4.0.6)
43
+ rainbow (3.1.1)
82
44
  rake (12.3.3)
83
- recursive-open-struct (1.1.3)
45
+ regexp_parser (2.2.0)
46
+ rexml (3.2.5)
84
47
  rspec (3.10.0)
85
48
  rspec-core (~> 3.10.0)
86
49
  rspec-expectations (~> 3.10.0)
@@ -94,14 +57,25 @@ GEM
94
57
  diff-lcs (>= 1.2.0, < 2.0)
95
58
  rspec-support (~> 3.10.0)
96
59
  rspec-support (3.10.2)
60
+ rubocop (1.25.1)
61
+ parallel (~> 1.10)
62
+ parser (>= 3.1.0.0)
63
+ rainbow (>= 2.2.2, < 4.0)
64
+ regexp_parser (>= 1.8, < 3.0)
65
+ rexml
66
+ rubocop-ast (>= 1.15.1, < 2.0)
67
+ ruby-progressbar (~> 1.7)
68
+ unicode-display_width (>= 1.4.0, < 3.0)
69
+ rubocop-ast (1.15.1)
70
+ parser (>= 3.0.1.1)
71
+ ruby-progressbar (1.11.0)
97
72
  sshkey (2.0.0)
98
- thor (1.1.0)
99
- to_regexp (0.2.1)
73
+ subprocess (1.5.5)
74
+ thor (1.2.1)
100
75
  unf (0.1.4)
101
76
  unf_ext
102
77
  unf_ext (0.0.8)
103
- yajl-ruby (1.4.1)
104
- yaml-safe_load_stream (0.1.1)
78
+ unicode-display_width (2.1.0)
105
79
 
106
80
  PLATFORMS
107
81
  ruby
@@ -110,6 +84,7 @@ DEPENDENCIES
110
84
  hetzner-k3s!
111
85
  rake (~> 12.0)
112
86
  rspec (~> 3.0)
87
+ rubocop
113
88
 
114
89
  BUNDLED WITH
115
- 2.1.4
90
+ 2.3.4
data/README.md CHANGED
@@ -25,7 +25,7 @@ All that is needed to use this tool is
25
25
 
26
26
  ## Installation
27
27
 
28
- Once you have the Ruby runtime up and running (2.7.2 or newer in the 2.7 series is recommended at this stage), you just need to install the gem:
28
+ Once you have the Ruby runtime up and running (2.7.2 or newer), you just need to install the gem:
29
29
 
30
30
  ```bash
31
31
  gem install hetzner-k3s
@@ -38,7 +38,7 @@ This will install the `hetzner-k3s` executable in your PATH.
38
38
  Alternatively, if you don't want to set up a Ruby runtime but have Docker installed, you can use a container. Run the following from inside the directory where you have the config file for the cluster (described in the next section):
39
39
 
40
40
  ```bash
41
- docker run --rm -it -v ${PWD}:/cluster -v ${HOME}/.ssh:/tmp/.ssh vitobotta/hetzner-k3s:v0.4.7 create-cluster --config-file /cluster/test.yaml
41
+ docker run --rm -it -v ${PWD}:/cluster -v ${HOME}/.ssh:/tmp/.ssh vitobotta/hetzner-k3s:v0.5.1 create-cluster --config-file /cluster/test.yaml
42
42
  ```
43
43
 
44
44
  Replace `test.yaml` with the name of your config file.
@@ -70,11 +70,14 @@ worker_node_pools:
70
70
  - name: big
71
71
  instance_type: cpx31
72
72
  instance_count: 2
73
+ additional_packages:
74
+ - somepackage
75
+ enable_ipsec_encryption: true
73
76
  ```
74
77
 
75
78
  It should hopefully be self explanatory; you can run `hetzner-k3s releases` to see a list of the available releases from the most recent to the oldest available.
76
79
 
77
- If you are using Docker, then set `kubeconfig_path` to `/cluster/kubeconfig` so that the kubeconfig is created in the same directory where your config file is.
80
+ If you are using Docker, then set `kubeconfig_path` to `/cluster/kubeconfig` so that the kubeconfig is created in the same directory where your config file is. Also set the config file path to `/cluster/<filename>`.
78
81
 
79
82
  If you don't want to specify the Hetzner token in the config file (for example if you want to use the tool with CI), then you can use the `HCLOUD_TOKEN` environment variable instead, which has predecence.
80
83
 
@@ -108,7 +111,7 @@ curl \
108
111
  'https://api.hetzner.cloud/v1/images'
109
112
  ```
110
113
 
111
- Note that if you use a custom image, the creation of the servers may take longer than when using the default image.
114
+ Note that if you use a custom image, the creation of the servers may take longer than when using the default image.
112
115
 
113
116
  Also note: the option `verify_host_key` is by default set to `false` to disable host key verification. This is because sometimes when creating new servers, Hetzner may assign IP addresses that were previously used by other servers you owned in the past. Therefore the host key verification would fail. If you set this option to `true` and this happens, the tool won't be able to continue creating the cluster until you resolve the issue with one of the suggestions it will give you.
114
117
 
@@ -211,7 +214,7 @@ kubectl label node <master1> <master2> <master2> plan.upgrade.cattle.io/k3s-serv
211
214
  To delete a cluster, running
212
215
 
213
216
  ```bash
214
- hetzner-k3s delete-cluster --config-file cluster_config.yam
217
+ hetzner-k3s delete-cluster --config-file cluster_config.yaml
215
218
  ```
216
219
 
217
220
  This will delete all the resources in the Hetzner Cloud project for the cluster being deleted.
@@ -254,6 +257,24 @@ I recommend that you create a separate Hetzner project for each cluster, because
254
257
 
255
258
  ## changelog
256
259
 
260
+ - 0.5.1
261
+ - Each node pool gets its own placement group. This is to minimize issues due to the max 10 nodes limitation for a single node group. A validation has also been added to limit pools to 10 nodes each because of this.
262
+
263
+ - 0.5.0
264
+ - Allow installing additional packages when creating the servers
265
+ - Allow enabling ipsec encryption
266
+
267
+ - 0.4.9
268
+ - Ensure the program always exits with exit code 1 if the config file fails validation
269
+ - Upgrade System Upgrade Controller to 0.8.1
270
+ - Remove dependency on unmaintained gem k8s-ruby
271
+ - Make the gem compatible with Ruby 3.1.0
272
+
273
+ - 0.4.8
274
+ - Increase timeout with API requests to 30 seconds
275
+ - Limit number of retries for API requests to 3
276
+ - Ensure all version tags are listed for k3s (thanks @janosmiko)
277
+
257
278
  - 0.4.7
258
279
  - Made it possible to specify a custom image/snapshot for the servers
259
280
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/build.sh CHANGED
@@ -6,9 +6,9 @@ set -e
6
6
 
7
7
  IMAGE="vitobotta/hetzner-k3s"
8
8
 
9
- docker build -t ${IMAGE}:v0.4.7 \
9
+ docker build -t ${IMAGE}:v0.5.1 \
10
10
  --platform=linux/amd64 \
11
- --cache-from ${IMAGE}:v0.4.6 \
11
+ --cache-from ${IMAGE}:v0.5.0 \
12
12
  --build-arg BUILDKIT_INLINE_CACHE=1 .
13
13
 
14
- docker push vitobotta/hetzner-k3s:v0.4.7
14
+ docker push vitobotta/hetzner-k3s:v0.5.1
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "k3s"
3
+ require 'bundler/setup'
4
+ require 'k3s'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "k3s"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
File without changes
@@ -1,11 +1,15 @@
1
1
  ---
2
- hetzner_token: blah
2
+ hetzner_token: <your token>
3
3
  cluster_name: test
4
- kubeconfig_path: "../kubeconfig"
4
+ kubeconfig_path: "./kubeconfig"
5
5
  k3s_version: v1.21.3+k3s1
6
- ssh_key_path: "~/.ssh/id_rsa.pub"
6
+ public_ssh_key_path: "~/.ssh/id_rsa.pub"
7
+ private_ssh_key_path: "~/.ssh/id_rsa"
8
+ ssh_allowed_networks:
9
+ - 0.0.0.0/0
7
10
  verify_host_key: false
8
11
  location: nbg1
12
+ schedule_workloads_on_masters: false
9
13
  masters:
10
14
  instance_type: cpx21
11
15
  instance_count: 3
@@ -14,5 +18,5 @@ worker_node_pools:
14
18
  instance_type: cpx21
15
19
  instance_count: 4
16
20
  - name: big
17
- instance_type: cp321
21
+ instance_type: cpx31
18
22
  instance_count: 2
data/hetzner-k3s.gemspec CHANGED
@@ -1,37 +1,41 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'lib/hetzner/k3s/version'
2
4
 
3
5
  Gem::Specification.new do |spec|
4
- spec.name = "hetzner-k3s"
6
+ spec.name = 'hetzner-k3s'
5
7
  spec.version = Hetzner::K3s::VERSION
6
- spec.authors = ["Vito Botta"]
7
- spec.email = ["vito@botta.me"]
8
+ spec.authors = ['Vito Botta']
9
+ spec.email = ['vito@botta.me']
8
10
 
9
- spec.summary = %q{A CLI to create a Kubernetes cluster in Hetzner Cloud very quickly using k3s.}
10
- spec.description = %q{A CLI to create a Kubernetes cluster in Hetzner Cloud very quickly using k3s.}
11
- spec.homepage = "https://github.com/vitobotta/hetzner-k3s"
12
- spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
11
+ spec.summary = 'A CLI to create a Kubernetes cluster in Hetzner Cloud very quickly using k3s.'
12
+ spec.description = 'A CLI to create a Kubernetes cluster in Hetzner Cloud very quickly using k3s.'
13
+ spec.homepage = 'https://github.com/vitobotta/hetzner-k3s'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.1.0')
14
16
 
15
17
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
18
 
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://github.com/vitobotta/hetzner-k3s"
19
- spec.metadata["changelog_uri"] = "https://github.com/vitobotta/hetzner-k3s"
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/vitobotta/hetzner-k3s'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/vitobotta/hetzner-k3s'
20
22
 
21
- spec.add_dependency "thor"
22
- spec.add_dependency "http"
23
- spec.add_dependency "net-ssh"
24
- spec.add_dependency "k8s-ruby"
25
- spec.add_dependency "sshkey"
26
- spec.add_dependency "ed25519"
27
- spec.add_dependency "bcrypt_pbkdf"
23
+ spec.add_dependency 'bcrypt_pbkdf'
24
+ spec.add_dependency 'ed25519'
25
+ spec.add_dependency 'http'
26
+ spec.add_dependency 'net-ssh'
27
+ spec.add_dependency 'sshkey'
28
+ spec.add_dependency 'subprocess'
29
+ spec.add_dependency 'thor'
30
+ spec.add_development_dependency 'rubocop'
28
31
 
29
32
  # Specify which files should be added to the gem when it is released.
30
33
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
34
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
32
35
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
36
  end
34
- spec.bindir = "exe"
37
+ spec.bindir = 'exe'
35
38
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
- spec.require_paths = ["lib"]
39
+ spec.require_paths = ['lib']
40
+ spec.metadata['rubygems_mfa_required'] = 'true'
37
41
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hetzner
2
4
  class Client
3
- BASE_URI = "https://api.hetzner.cloud/v1"
5
+ BASE_URI = 'https://api.hetzner.cloud/v1'
4
6
 
5
7
  attr_reader :token
6
8
 
@@ -22,25 +24,27 @@ module Hetzner
22
24
 
23
25
  def delete(path, id)
24
26
  make_request do
25
- HTTP.headers(headers).delete(BASE_URI + path + "/" + id.to_s)
27
+ HTTP.headers(headers).delete("#{BASE_URI}#{path}/#{id}")
26
28
  end
27
29
  end
28
30
 
29
31
  private
30
32
 
31
- def headers
32
- {
33
- "Authorization": "Bearer #{@token}",
34
- "Content-Type": "application/json"
35
- }
36
- end
33
+ def headers
34
+ {
35
+ Authorization: "Bearer #{@token}",
36
+ 'Content-Type': 'application/json'
37
+ }
38
+ end
37
39
 
38
- def make_request &block
39
- Timeout::timeout(5) do
40
- block.call
41
- end
42
- rescue Timeout::Error
43
- retry
40
+ def make_request(&block)
41
+ retries ||= 0
42
+
43
+ Timeout.timeout(30) do
44
+ block.call
44
45
  end
46
+ rescue Timeout::Error
47
+ retry if (retries += 1) < 3
48
+ end
45
49
  end
46
50
  end