lib/hetzner/k3s/configuration.rb in hetzner-k3s-0.5.9 vs lib/hetzner/k3s/configuration.rb in hetzner-k3s-0.6.0.pre1

- old
+ new

@@ -90,16 +90,14 @@ def raw configuration end - private + private_class_method - attr_reader :configuration, :errors, :options - def self.fetch_releases(url) - response = HTTP.get(url) + response = HTTParty.get(url) [response, JSON.parse(response.body).map { |hash| hash['name'] }] end def self.extract_next_github_page_url(link_header) link_header.split(GITHUB_DELIM_LINKS).each do |link| @@ -119,17 +117,21 @@ when 'next' url_part end end + private + + attr_reader :configuration, :errors, :options + def validate_create validate_public_ssh_key validate_private_ssh_key validate_ssh_allowed_networks validate_api_allowed_networks validate_masters_location - validate_k3s_version + # validate_k3s_version validate_masters validate_worker_node_pools validate_verify_host_key validate_additional_packages validate_post_create_commands @@ -142,11 +144,11 @@ validate_existing_network end def validate_upgrade validate_kubeconfig_path_must_exist - validate_new_k3s_version + # validate_new_k3s_version end def validate_public_ssh_key path = File.expand_path(configuration['public_ssh_key_path']) errors << 'Invalid Public SSH key path' and return unless File.exist? path @@ -397,11 +399,11 @@ def valid_token? return @valid unless @valid.nil? begin token = hetzner_token - @hetzner_client = Hetzner::Client.new(token:) + @hetzner_client = Hetzner::Client.new(token: token) response = hetzner_client.get('/locations') error_code = response.dig('error', 'code') @valid = error_code != 'unauthorized' rescue StandardError @valid = false @@ -470,15 +472,15 @@ @errors << 'Cannot fetch server types with Hetzner API, please try again later' false end def validate_existing_network - if configuration["existing_network"] - existing_network = Hetzner::Network.new(hetzner_client:, cluster_name: configuration["cluster_name"], existing_network: configuration["existing_network"]).get + return unless configuration['existing_network'] - unless existing_network - @errors << "You have specified that you want to use the existing network named '#{configuration["existing_network"]} but this network doesn't exist" - end - end + existing_network = Hetzner::Network.new(hetzner_client: hetzner_client, cluster_name: configuration['cluster_name'], existing_network: configuration['existing_network']).get + + return if existing_network + + @errors << "You have specified that you want to use the existing network named '#{configuration['existing_network']} but this network doesn't exist" end end end