lib/hetzner/k3s/configuration.rb in hetzner-k3s-0.6.2.pre1 vs lib/hetzner/k3s/configuration.rb in hetzner-k3s-0.6.2

- old
+ new

@@ -1,11 +1,11 @@ # frozen_string_literal: true module Hetzner class Configuration GITHUB_DELIM_LINKS = ',' - GITHUB_LINK_REGEX = /<([^>]+)>; rel="([^"]+)"/ + GITHUB_LINK_REGEX = /<([^>]+)>; rel="([^"]+)"/.freeze attr_reader :hetzner_client def initialize(options:) @options = options @@ -90,12 +90,10 @@ def raw configuration end - private_class_method - def self.fetch_releases(url) response = HTTParty.get(url) [response, JSON.parse(response.body).map { |hash| hash['name'] }] end @@ -194,11 +192,11 @@ network.include? '/' end unless invalid_ranges.empty? invalid_ranges.each do |_network| - errors << 'Please use the CIDR notation for the #{access_type} networks to avoid ambiguity' + errors << "Please use the CIDR notation for the #{access_type} networks to avoid ambiguity" end end return unless invalid_networks.empty? @@ -208,23 +206,21 @@ IPAddr.new(network).include?(current_ip) rescue StandardError false end - unless current_ip_network - case access_type - when "SSH" - errors << "Your current IP #{current_ip} is not included into any of the #{access_type} networks you've specified, so we won't be able to SSH into the nodes " - when "API" - errors << "Your current IP #{current_ip} is not included into any of the #{access_type} networks you've specified, so we won't be able to connect to the Kubernetes API" - end + return if current_ip_network + + case access_type + when 'SSH' + errors << "Your current IP #{current_ip} is not included into any of the #{access_type} networks you've specified, so we won't be able to SSH into the nodes " + when 'API' + errors << "Your current IP #{current_ip} is not included into any of the #{access_type} networks you've specified, so we won't be able to connect to the Kubernetes API" end end - def validate_ssh_allowed_networks - return validate_networks('ssh_allowed_networks', 'SSH') end def validate_api_allowed_networks validate_networks('api_allowed_networks', 'API') @@ -438,9 +434,12 @@ instance_group_errors << 'Masters count must equal to 1 for non-HA clusters or an odd number (recommended 3) for an HA cluster' unless instance_group['instance_count'].odd? end else instance_group_errors << "#{instance_group_type} has an invalid instance count" end + + instance_group_errors << "#{instance_group_type} has an invalid labels format - a hash is expected" if !instance_group['labels'].nil? && !instance_group['labels'].is_a?(Hash) + instance_group_errors << "#{instance_group_type} has an invalid taints format - a hash is expected" if !instance_group['taints'].nil? && !instance_group['taints'].is_a?(Hash) errors << instance_group_errors end def valid_location?(location)