From 0af4fe90629aa49cf20c67e6865550e1bf1cddcd Mon Sep 17 00:00:00 2001 From: Kimmo Lehto Date: Tue, 20 Mar 2018 08:00:54 +0200 Subject: [PATCH] Rubocop config and autocorrects (#91) --- .rubocop.relaxed.yml | 166 ++++++++++++++++++++++++ .rubocop.yml | 49 +++++++ Rakefile | 4 +- bin/kupo | 4 +- examples/vagrant/Vagrantfile | 4 +- kupo.gemspec | 1 + lib/kupo.rb | 3 +- lib/kupo/addon.rb | 23 ++-- lib/kupo/addon_manager.rb | 6 +- lib/kupo/addons/cert_manager.rb | 5 +- lib/kupo/addons/host_upgrades.rb | 9 +- lib/kupo/addons/ingress_nginx.rb | 7 +- lib/kupo/addons/kubernetes_dashboard.rb | 6 +- lib/kupo/addons/kured.rb | 6 +- lib/kupo/addons/struct.rb | 4 +- lib/kupo/autoload.rb | 4 +- lib/kupo/command.rb | 2 + lib/kupo/config.rb | 8 +- lib/kupo/config_schema.rb | 6 +- lib/kupo/configuration/cpu_arch.rb | 18 +-- lib/kupo/configuration/etcd.rb | 2 + lib/kupo/configuration/host.rb | 4 +- lib/kupo/configuration/network.rb | 2 + lib/kupo/configuration/os_release.rb | 11 +- lib/kupo/erb.rb | 3 +- lib/kupo/error.rb | 4 +- lib/kupo/kube.rb | 57 ++++---- lib/kupo/phases/base.rb | 2 + lib/kupo/phases/component.rb | 4 +- lib/kupo/phases/configure_client.rb | 9 +- lib/kupo/phases/configure_dns.rb | 91 +++++++------ lib/kupo/phases/configure_host.rb | 52 ++++---- lib/kupo/phases/configure_kubelet.rb | 5 +- lib/kupo/phases/configure_master.rb | 29 ++--- lib/kupo/phases/configure_metrics.rb | 24 ++-- lib/kupo/phases/configure_network.rb | 14 +- lib/kupo/phases/join_node.rb | 3 +- lib/kupo/phases/label_node.rb | 10 +- lib/kupo/phases/logging.rb | 4 +- lib/kupo/phases/validate_host.rb | 4 +- lib/kupo/root_command.rb | 9 +- lib/kupo/ssh/client.rb | 17 ++- lib/kupo/types.rb | 4 +- lib/kupo/up_command.rb | 12 +- lib/kupo/version.rb | 2 + lib/kupo/version_command.rb | 5 +- 46 files changed, 501 insertions(+), 217 deletions(-) create mode 100644 .rubocop.relaxed.yml create mode 100644 .rubocop.yml diff --git a/.rubocop.relaxed.yml b/.rubocop.relaxed.yml new file mode 100644 index 000000000..24da958e8 --- /dev/null +++ b/.rubocop.relaxed.yml @@ -0,0 +1,166 @@ +# Relaxed.Ruby.Style +## Version 2.2 + +Style/Alias: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylealias + +Style/AsciiComments: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleasciicomments + +Style/BeginBlock: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylebeginblock + +Style/BlockDelimiters: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters + +Style/CommentAnnotation: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylecommentannotation + +Style/Documentation: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styledocumentation + +Layout/DotPosition: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#layoutdotposition + +Style/DoubleNegation: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styledoublenegation + +Style/EndBlock: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleendblock + +Style/FormatString: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleformatstring + +Style/IfUnlessModifier: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier + +Style/Lambda: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylelambda + +Style/ModuleFunction: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylemodulefunction + +Style/MultilineBlockChain: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain + +Style/NegatedIf: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylenegatedif + +Style/NegatedWhile: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile + +Style/ParallelAssignment: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleparallelassignment + +Style/PercentLiteralDelimiters: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters + +Style/PerlBackrefs: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs + +Style/Semicolon: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylesemicolon + +Style/SignalException: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylesignalexception + +Style/SingleLineBlockParams: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams + +Style/SingleLineMethods: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods + +Layout/SpaceBeforeBlockBraces: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#layoutspacebeforeblockbraces + +Layout/SpaceInsideParens: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#layoutspaceinsideparens + +Style/SpecialGlobalVars: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars + +Style/StringLiterals: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylestringliterals + + # Style/TrailingCommaInArguments: + # Enabled: false + # StyleGuide: http://relaxed.ruby.style/#styletrailingcommainarguments + # + # Style/TrailingCommaInArrayLiteral: + # Enabled: false + # StyleGuide: http://relaxed.ruby.style/#styletrailingcommainarrayliteral + # + # Style/TrailingCommaInHashLiteral: + # Enabled: false + # StyleGuide: http://relaxed.ruby.style/#styletrailingcommainhashliteral + +Style/WhileUntilModifier: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier + +Style/WordArray: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#stylewordarray + +Lint/AmbiguousRegexpLiteral: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral + +Lint/AssignmentInCondition: + Enabled: false + StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition + +Metrics/AbcSize: + Enabled: false + +Metrics/BlockNesting: + Enabled: false + +Metrics/ClassLength: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Metrics/CyclomaticComplexity: + Enabled: false + +Metrics/LineLength: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/ParameterLists: + Enabled: false + +Metrics/PerceivedComplexity: + Enabled: false + diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 000000000..2c89021c3 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,49 @@ +inherit_from: .rubocop.relaxed.yml + +AllCops: + Exclude: + - spec/**/* + - Gemfile + - "*.gemspec" + TargetRubyVersion: 2.4 + +Style/PercentLiteralDelimiters: + PreferredDelimiters: + default: () + '%i': '()' + '%I': '()' + '%r': '{}' + '%w': '()' + '%W': '()' + +Style/FormatString: + EnforcedStyle: percent + +Style/FrozenStringLiteralComment: + EnforcedStyle: always + +Style/WordArray: + Enabled: true + MinSize: 3 + +Style/SymbolArray: + Enabled: true + MinSize: 3 + +Gemspec/OrderedDependencies: + Enabled: false + +Style/PerlBackrefs: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +Style/SpecialGlobalVars: + Enabled: true + +Style/Alias: + Enabled: true + +Style/BeginBlock: + Enabled: true diff --git a/Rakefile b/Rakefile index 43022f711..24e113595 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,4 @@ +# frozen_string_literal: true + require "bundler/gem_tasks" -task :default => :spec +task default: :spec diff --git a/bin/kupo b/bin/kupo index b251bf1af..818b4c7e0 100755 --- a/bin/kupo +++ b/bin/kupo @@ -1,10 +1,10 @@ #!/usr/bin/env ruby -# encoding: UTF-8 +# frozen_string_literal: true # add lib to libpath (only needed when running from the sources) require 'pathname' lib_path = File.expand_path('../../lib', Pathname.new(__FILE__).realpath) -$:.unshift lib_path unless $:.include?(lib_path) +$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path) STDOUT.sync = true diff --git a/examples/vagrant/Vagrantfile b/examples/vagrant/Vagrantfile index 4855f0473..7ecbbda55 100644 --- a/examples/vagrant/Vagrantfile +++ b/examples/vagrant/Vagrantfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # -*- mode: ruby -*- # vi: set ft=ruby : @@ -31,7 +33,7 @@ Vagrant.configure("2") do |config| vb.memory = "2048" vb.cpus = 1 end - host.vm.network "private_network", ip: "192.168.100.#{i+100}" + host.vm.network "private_network", ip: "192.168.100.#{i + 100}" end end end diff --git a/kupo.gemspec b/kupo.gemspec index 0c0e5e2de..222e106ca 100644 --- a/kupo.gemspec +++ b/kupo.gemspec @@ -19,6 +19,7 @@ Gem::Specification.new do |spec| spec.bindir = "bin" spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.require_paths = ["lib"] + spec.required_ruby_version = '~> 2.4' spec.add_runtime_dependency "clamp", "1.2.1" spec.add_runtime_dependency "pastel" diff --git a/lib/kupo.rb b/lib/kupo.rb index 9774be1ef..746f75f98 100644 --- a/lib/kupo.rb +++ b/lib/kupo.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "clamp" require_relative "kupo/autoload" require_relative "kupo/version" @@ -6,5 +8,4 @@ require_relative "kupo/root_command" module Kupo - end diff --git a/lib/kupo/addon.rb b/lib/kupo/addon.rb index 9d161fcd1..793412bd4 100644 --- a/lib/kupo/addon.rb +++ b/lib/kupo/addon.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'dry-validation' require_relative 'addons/struct' require_relative 'phases/logging' @@ -92,13 +94,18 @@ def uninstall end def apply_stack(vars = {}) - Kupo::Kube.apply_stack(host.address, self.class.name, vars.merge({ - name: self.class.name, version: self.class.version, config: config, - arch: host.cpu_arch - })) - end - - def apply_resource(resource) + Kupo::Kube.apply_stack( + host.address, self.class.name, + vars.merge( + name: self.class.name, + version: self.class.version, + config: config, + arch: host.cpu_arch + ) + ) + end + + def apply_resource Kupo::Kube.apply_resource(host.address) end @@ -106,4 +113,4 @@ def prune_stack Kupo::Kube.prune_stack(host.address, self.class.name, '-') end end -end \ No newline at end of file +end diff --git a/lib/kupo/addon_manager.rb b/lib/kupo/addon_manager.rb index eafcf9a1c..9f3359859 100644 --- a/lib/kupo/addon_manager.rb +++ b/lib/kupo/addon_manager.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'addon' require_relative 'phases/logging' @@ -27,7 +29,7 @@ def validate(configs) # @param configs [Hash] def apply(host, configs) with_enabled_addons(configs) do |addon_class, config| - self.logger.info { "Applying addon #{addon_class.name} ..." } + logger.info { "Applying addon #{addon_class.name} ..." } schema = addon_class.validate(config) addon = addon_class.new(host, schema) addon.install @@ -73,4 +75,4 @@ def load_addons(dirs) end end end -end \ No newline at end of file +end diff --git a/lib/kupo/addons/cert_manager.rb b/lib/kupo/addons/cert_manager.rb index b2284c997..81c589a5d 100644 --- a/lib/kupo/addons/cert_manager.rb +++ b/lib/kupo/addons/cert_manager.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + module Kupo module Addons class CertManager < Kupo::Addon - name 'cert-manager' version '0.2.3' license 'Apache License 2.0' @@ -25,4 +26,4 @@ class Issuer < Kupo::Addons::Struct } end end -end \ No newline at end of file +end diff --git a/lib/kupo/addons/host_upgrades.rb b/lib/kupo/addons/host_upgrades.rb index 9bc406e40..18e28aa04 100644 --- a/lib/kupo/addons/host_upgrades.rb +++ b/lib/kupo/addons/host_upgrades.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + module Kupo module Addons class HostUpgrades < Kupo::Addon - name 'host-upgrades' version '0.1.0' license 'Apache License 2.0' @@ -15,10 +16,10 @@ class HostUpgrades < Kupo::Addon } def install - apply_stack({ + apply_stack( interval: duration.parse(config.interval).to_sec - }) + ) end end end -end \ No newline at end of file +end diff --git a/lib/kupo/addons/ingress_nginx.rb b/lib/kupo/addons/ingress_nginx.rb index ab0bf0e22..5eb130f90 100644 --- a/lib/kupo/addons/ingress_nginx.rb +++ b/lib/kupo/addons/ingress_nginx.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + module Kupo module Addons class IngressNginx < Kupo::Addon - name 'ingress-nginx' version '0.11.0' license 'Apache License 2.0' @@ -17,10 +18,10 @@ class IngressNginx < Kupo::Addon } def install - apply_stack({ + apply_stack( configmap: config.configmap || {}, node_selector: config.node_selector - }) + ) end end end diff --git a/lib/kupo/addons/kubernetes_dashboard.rb b/lib/kupo/addons/kubernetes_dashboard.rb index ea0cc6e23..8c9ee38eb 100644 --- a/lib/kupo/addons/kubernetes_dashboard.rb +++ b/lib/kupo/addons/kubernetes_dashboard.rb @@ -1,11 +1,11 @@ +# frozen_string_literal: true + module Kupo module Addons class KubeDashboard < Kupo::Addon - name 'kubernetes-dashboard' version '1.8.3' license 'Apache License 2.0' - end end -end \ No newline at end of file +end diff --git a/lib/kupo/addons/kured.rb b/lib/kupo/addons/kured.rb index bdb273db7..532774cc3 100644 --- a/lib/kupo/addons/kured.rb +++ b/lib/kupo/addons/kured.rb @@ -1,11 +1,11 @@ +# frozen_string_literal: true + module Kupo module Addons class Kured < Kupo::Addon - name 'kured' version '1.0.0' license 'Apache License 2.0' - end end -end \ No newline at end of file +end diff --git a/lib/kupo/addons/struct.rb b/lib/kupo/addons/struct.rb index 2ba123892..29be8a9e8 100644 --- a/lib/kupo/addons/struct.rb +++ b/lib/kupo/addons/struct.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'dry-struct' module Kupo @@ -8,4 +10,4 @@ class Struct < Dry::Struct attribute :enabled, Kupo::Types::Strict::Bool end end -end \ No newline at end of file +end diff --git a/lib/kupo/autoload.rb b/lib/kupo/autoload.rb index cb0fdfa17..4317e754b 100644 --- a/lib/kupo/autoload.rb +++ b/lib/kupo/autoload.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + autoload :Kubeclient, 'kubeclient' autoload :Base64, 'base64' autoload :SecureRandom, 'securerandom' @@ -23,4 +25,4 @@ module Phases module Addons end -end \ No newline at end of file +end diff --git a/lib/kupo/command.rb b/lib/kupo/command.rb index 793db07b8..1f80afb6c 100644 --- a/lib/kupo/command.rb +++ b/lib/kupo/command.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Kupo class Command < Clamp::Command def pastel diff --git a/lib/kupo/config.rb b/lib/kupo/config.rb index 842e510e6..d85c1b805 100644 --- a/lib/kupo/config.rb +++ b/lib/kupo/config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'dry-struct' require_relative 'types' require_relative 'configuration/host' @@ -18,11 +20,11 @@ class Config < Dry::Struct # @return [Integer] def dns_replicas if network.dns_replicas - return network.dns_replicas + network.dns_replicas elsif hosts.length == 1 - return 1 + 1 else - return 1 + (hosts.length / HOSTS_PER_DNS_REPLICA.to_f).ceil + 1 + (hosts.length / HOSTS_PER_DNS_REPLICA.to_f).ceil end end end diff --git a/lib/kupo/config_schema.rb b/lib/kupo/config_schema.rb index 910887043..1508b7f3b 100644 --- a/lib/kupo/config_schema.rb +++ b/lib/kupo/config_schema.rb @@ -1,17 +1,17 @@ +# frozen_string_literal: true + require 'fugit' require 'dry-validation' module Kupo - class ConfigSchema - # @return [Dry::Validation::Schema] def self.build Dry::Validation.Form do configure do def self.messages super.merge( - en: { errors: {network_dns_replicas: "network.dns_replicas cannot be larger than the number of hosts"}} + en: { errors: { network_dns_replicas: "network.dns_replicas cannot be larger than the number of hosts" } } ) end end diff --git a/lib/kupo/configuration/cpu_arch.rb b/lib/kupo/configuration/cpu_arch.rb index caca63faf..bf9671e01 100644 --- a/lib/kupo/configuration/cpu_arch.rb +++ b/lib/kupo/configuration/cpu_arch.rb @@ -1,28 +1,30 @@ +# frozen_string_literal: true + module Kupo::Configuration class CpuArch < Dry::Struct constructor_type :schema - SUPPORTED_IDS = [ - 'amd64', 'x86_64', - 'arm64', 'aarch64' - ].freeze + SUPPORTED_IDS = %w( + amd64 x86_64 + arm64 aarch64 + ).freeze attribute :id, Kupo::Types::Strict::String # @return [Boolean] def supported? - SUPPORTED_IDS.include?(self.id) + SUPPORTED_IDS.include?(id) end def name - case self.id + case id when 'x86_64' 'amd64' when 'aarch64' 'arm64' else - self.id + id end end end -end \ No newline at end of file +end diff --git a/lib/kupo/configuration/etcd.rb b/lib/kupo/configuration/etcd.rb index e01e36267..54c0cadcd 100644 --- a/lib/kupo/configuration/etcd.rb +++ b/lib/kupo/configuration/etcd.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Kupo::Configuration class Etcd < Dry::Struct constructor_type :schema diff --git a/lib/kupo/configuration/host.rb b/lib/kupo/configuration/host.rb index 4cb2a5b6a..9a7b2af77 100644 --- a/lib/kupo/configuration/host.rb +++ b/lib/kupo/configuration/host.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'os_release' require_relative 'cpu_arch' @@ -16,4 +18,4 @@ class Host < Dry::Struct attr_accessor :os_release attr_accessor :cpu_arch end -end \ No newline at end of file +end diff --git a/lib/kupo/configuration/network.rb b/lib/kupo/configuration/network.rb index aa1822ea5..2110b8a8e 100644 --- a/lib/kupo/configuration/network.rb +++ b/lib/kupo/configuration/network.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Kupo::Configuration class Network < Dry::Struct constructor_type :schema diff --git a/lib/kupo/configuration/os_release.rb b/lib/kupo/configuration/os_release.rb index 07d207832..8ff542d50 100644 --- a/lib/kupo/configuration/os_release.rb +++ b/lib/kupo/configuration/os_release.rb @@ -1,23 +1,24 @@ +# frozen_string_literal: true + module Kupo::Configuration class OsRelease < Dry::Struct constructor_type :schema SUPPORTED = { 'ubuntu' => ['16.04'] - } + }.freeze attribute :id, Kupo::Types::Strict::String attribute :id_like, Kupo::Types::Strict::String attribute :name, Kupo::Types::Strict::String attribute :version, Kupo::Types::Strict::String - def supported? - distro = SUPPORTED[self.id] + distro = SUPPORTED[id] return false unless distro distro.any? { |v| - self.version == v + version == v } end end -end \ No newline at end of file +end diff --git a/lib/kupo/erb.rb b/lib/kupo/erb.rb index e08c46dea..6c40d0e51 100644 --- a/lib/kupo/erb.rb +++ b/lib/kupo/erb.rb @@ -1,9 +1,10 @@ +# frozen_string_literal: true + require 'erb' require 'ostruct' module Kupo class Erb - def initialize(template) @template = template end diff --git a/lib/kupo/error.rb b/lib/kupo/error.rb index bdac92616..18f77df25 100644 --- a/lib/kupo/error.rb +++ b/lib/kupo/error.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + module Kupo class Error < StandardError; end class InvalidHostError < Error; end class ScriptExecError < Error; end -end \ No newline at end of file +end diff --git a/lib/kupo/kube.rb b/lib/kupo/kube.rb index 22b8c4382..da68e8d84 100644 --- a/lib/kupo/kube.rb +++ b/lib/kupo/kube.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'kubeclient' require 'deep_merge' module Kupo::Kube - class Client < ::Kubeclient::Client def entities if @entities.empty? @@ -19,7 +20,7 @@ def entity_for_resource(resource) definition end - def apis(options= {}) + def apis(options = {}) response = rest_client.get(@headers) format_response(options[:as] || @as, response.body) end @@ -28,10 +29,10 @@ def apis(options= {}) # @return [Kubeclient::Resource] def update_resource(resource) definition = entity_for_resource(resource) - + old_resource = get_entity(definition.resource_name, resource.metadata.name, resource.metadata.namespace) resource.metadata.resourceVersion = old_resource.metadata.resourceVersion - merged_resource = Kubeclient::Resource.new(old_resource.to_h.deep_merge!(resource.to_h, {overwrite_arrays: true})) + merged_resource = Kubeclient::Resource.new(old_resource.to_h.deep_merge!(resource.to_h, overwrite_arrays: true)) update_entity(definition.resource_name, merged_resource) end @@ -44,8 +45,8 @@ def create_resource(resource) end end - RESOURCE_LABEL = 'kupo.kontena.io/stack'.freeze - RESOURCE_ANNOTATION = 'kupo.kontena.io/stack-checksum'.freeze + RESOURCE_LABEL = 'kupo.kontena.io/stack' + RESOURCE_ANNOTATION = 'kupo.kontena.io/stack-checksum' # @param host [String] # @return [Kubeclient::Client] @@ -53,19 +54,13 @@ def self.client(host, version = 'v1') @kube_client ||= {} unless @kube_client[version] config = Kubeclient::Config.read(File.join(Dir.home, ".kupo/#{host}")) - if version == 'v1' - path_prefix = 'api' - else - path_prefix = 'apis' - end + path_prefix = version == 'v1' ? 'api' : 'apis' api_version, api_group = version.split('/').reverse @kube_client[version] = Kupo::Kube::Client.new( (config.context.api_endpoint + "/#{path_prefix}/#{api_group}"), api_version, - { - ssl_options: config.context.ssl_options, - auth_options: config.context.auth_options - } + ssl_options: config.context.ssl_options, + auth_options: config.context.auth_options ) end @kube_client[version] @@ -107,16 +102,15 @@ def self.prune_stack(host, stack, checksum) client(host, '').apis.groups.each do |api_group| group_client = client(host, api_group.preferredVersion.groupVersion) group_client.entities.each do |type, meta| - unless type.end_with?('_review') - objects = group_client.get_entities(type, meta.resource_name, {label_selector: "#{RESOURCE_LABEL}=#{stack}"}) - objects.select { |obj| - obj.metadata.annotations.nil? || obj.metadata.annotations[RESOURCE_ANNOTATION] != checksum - }.each { |obj| - obj.apiVersion = api_group.preferredVersion.groupVersion - delete_resource(host, obj) - pruned << obj - } - end + next if type.end_with?('_review') + objects = group_client.get_entities(type, meta.resource_name, label_selector: "#{RESOURCE_LABEL}=#{stack}") + objects.select { |obj| + obj.metadata.annotations.nil? || obj.metadata.annotations[RESOURCE_ANNOTATION] != checksum + }.each { |obj| + obj.apiVersion = api_group.preferredVersion.groupVersion + delete_resource(host, obj) + pruned << obj + } end end @@ -127,7 +121,7 @@ def self.prune_stack(host, stack, checksum) # @param resource [Kubeclient::Resource] # @return [Kubeclient::Resource] def self.apply_resource(host, resource) - resource_client = self.client(host, resource.apiVersion) + resource_client = client(host, resource.apiVersion) begin resource_client.update_resource(resource) @@ -140,7 +134,7 @@ def self.apply_resource(host, resource) # @param resource [Kubeclient::Resource] # @return [Kubeclient::Resource] def self.update_resource(host, resource) - resource_client = self.client(host, resource.apiVersion) + resource_client = client(host, resource.apiVersion) resource_client.update_resource(resource) end @@ -148,7 +142,7 @@ def self.update_resource(host, resource) # @param resource [Kubeclient::Resource] # @return [Kubeclient::Resource] def self.delete_resource(host, resource) - resource_client = self.client(host, resource.apiVersion) + resource_client = client(host, resource.apiVersion) begin if resource.metadata.selfLink api_group = resource.metadata.selfLink.split("/")[1] @@ -157,11 +151,12 @@ def self.delete_resource(host, resource) else definition = resource_client.entities[underscore_entity(resource.kind.to_s)] resource_client.get_entity(definition.resource_name, resource.metadata.name, resource.metadata.namespace) - resource_client.delete_entity(definition.resource_name, resource.metadata.name, resource.metadata.namespace, { + resource_client.delete_entity( + definition.resource_name, resource.metadata.name, resource.metadata.namespace, kind: 'DeleteOptions', apiVersion: 'v1', propagationPolicy: 'Foreground' - }) + ) end rescue Kubeclient::ResourceNotFoundError false @@ -174,7 +169,7 @@ def self.parse_resource_file(path, vars = {}) yaml = File.read(File.realpath(File.join(__dir__, 'resources', path))) parsed_yaml = Kupo::Erb.new(yaml).render(vars) - Kubeclient::Resource.new(YAML.load(parsed_yaml)) + Kubeclient::Resource.new(YAML.safe_load(parsed_yaml)) end # @param kind [String] diff --git a/lib/kupo/phases/base.rb b/lib/kupo/phases/base.rb index c9eec5caf..db6cfde64 100644 --- a/lib/kupo/phases/base.rb +++ b/lib/kupo/phases/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'logging' module Kupo::Phases diff --git a/lib/kupo/phases/component.rb b/lib/kupo/phases/component.rb index 774b8e27d..c703e6a56 100644 --- a/lib/kupo/phases/component.rb +++ b/lib/kupo/phases/component.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'dry-struct' module Kupo::Phases @@ -8,4 +10,4 @@ class Component < Dry::Struct attribute :version, Kupo::Types::String attribute :license, Kupo::Types::String end -end \ No newline at end of file +end diff --git a/lib/kupo/phases/configure_client.rb b/lib/kupo/phases/configure_client.rb index 13a3ebc13..d89b168f3 100644 --- a/lib/kupo/phases/configure_client.rb +++ b/lib/kupo/phases/configure_client.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true + require_relative 'base' module Kupo::Phases class ConfigureClient < Base - # @param master [Kupo::Configuration::Host] def initialize(master) @master = master @@ -10,13 +11,13 @@ def initialize(master) def call ssh = Kupo::SSH::Client.for_host(@master) - Dir.mkdir(config_dir, 0700) unless Dir.exists?(config_dir) + Dir.mkdir(config_dir, 0o700) unless Dir.exist?(config_dir) config_file = File.join(config_dir, @master.address) logger.info { "Fetching kubectl config ..." } config_data = ssh.file_contents("/etc/kubernetes/admin.conf") - + File.write(config_file, config_data.gsub(/(server: https:\/\/)(.+)(:6443)/, "\\1#{@master.address}\\3")) - logger.info { "Configuration saved to #{config_file}"} + logger.info { "Configuration saved to #{config_file}" } end def config_dir diff --git a/lib/kupo/phases/configure_dns.rb b/lib/kupo/phases/configure_dns.rb index a57e5d1c6..71ca0ce72 100644 --- a/lib/kupo/phases/configure_dns.rb +++ b/lib/kupo/phases/configure_dns.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'base' module Kupo::Phases @@ -12,8 +14,8 @@ def initialize(master, config) def call patch_kubedns( replicas: @config.dns_replicas, - max_surge: self.max_surge, - max_unavailable: self.max_unavailable, + max_surge: max_surge, + max_unavailable: max_unavailable ) end @@ -49,51 +51,54 @@ def max_unavailable # @param replicas [Integer] # @param nodes [Integer] - def patch_kubedns(replicas: , max_surge: , max_unavailable: ) + def patch_kubedns(replicas:, max_surge:, max_unavailable:) logger.info(@master.address) { "Patching kube-dns addon with #{replicas} replicas (max-surge #{max_surge}, max-unavailable #{max_unavailable})..." } - kube_client = Kupo::Kube.update_resource(@master.address, Kubeclient::Resource.new({ - apiVersion: 'extensions/v1beta1', - kind: 'Deployment', - metadata: { - namespace: 'kube-system', - name: 'kube-dns', - }, - spec: { - replicas: replicas, - strategy: { - type: "RollingUpdate", - rollingUpdate: { - maxSurge: max_surge, # must be zero for a two-node cluster - maxUnavailable: max_unavailable, # must be at least one, even for a single-node cluster - }, + kube_client = Kupo::Kube.update_resource( + @master.address, + Kubeclient::Resource.new( + apiVersion: 'extensions/v1beta1', + kind: 'Deployment', + metadata: { + namespace: 'kube-system', + name: 'kube-dns' }, - template: { - spec: { - affinity: { - podAntiAffinity: { - requiredDuringSchedulingIgnoredDuringExecution: [ - { - labelSelector: { - matchExpressions: [ - { - key: "k8s-app", - operator: "In", - values: [ - "kube-dns", - ], - }, - ], - }, - topologyKey: "kubernetes.io/hostname", - }, - ], - }, - }, + spec: { + replicas: replicas, + strategy: { + type: "RollingUpdate", + rollingUpdate: { + maxSurge: max_surge, # must be zero for a two-node cluster + maxUnavailable: max_unavailable, # must be at least one, even for a single-node cluster + } }, - }, - }, - })) + template: { + spec: { + affinity: { + podAntiAffinity: { + requiredDuringSchedulingIgnoredDuringExecution: [ + { + labelSelector: { + matchExpressions: [ + { + key: "k8s-app", + operator: "In", + values: [ + "kube-dns" + ] + } + ] + }, + topologyKey: "kubernetes.io/hostname" + } + ] + } + } + } + } + } + ) + ) end end end diff --git a/lib/kupo/phases/configure_host.rb b/lib/kupo/phases/configure_host.rb index 59431931c..55588df0a 100644 --- a/lib/kupo/phases/configure_host.rb +++ b/lib/kupo/phases/configure_host.rb @@ -1,21 +1,30 @@ +# frozen_string_literal: true + require_relative 'base' module Kupo::Phases class ConfigureHost < Base + CRIO_VERSION = '1.9' + KUBE_VERSION = '1.9.4' + DOCKER_VERSION = '1.13.1' + + register_component( + Kupo::Phases::Component.new( + name: 'docker', version: DOCKER_VERSION, license: 'Apache License 2.0' + ) + ) - CRIO_VERSION = '1.9'.freeze - KUBE_VERSION = '1.9.4'.freeze - DOCKER_VERSION = '1.13.1'.freeze + register_component( + Kupo::Phases::Component.new( + name: 'cri-o', version: CRIO_VERSION, license: 'Apache License 2.0' + ) + ) - register_component(Kupo::Phases::Component.new( - name: 'docker', version: DOCKER_VERSION, license: 'Apache License 2.0' - )) - register_component(Kupo::Phases::Component.new( - name: 'cri-o', version: CRIO_VERSION, license: 'Apache License 2.0' - )) - register_component(Kupo::Phases::Component.new( - name: 'kubernetes', version: KUBE_VERSION, license: 'Apache License 2.0' - )) + register_component( + Kupo::Phases::Component.new( + name: 'kubernetes', version: KUBE_VERSION, license: 'Apache License 2.0' + ) + ) # @param host [Kupo::Configuration::Host] def initialize(host) @@ -35,26 +44,25 @@ def call if docker? logger.info { "Configuring container runtime (docker) packages ..." } - exec_script('configure-docker.sh', { - docker_package: 'docker.io', - docker_version: "#{DOCKER_VERSION}-0ubuntu1~16.04.2" - }) + exec_script('configure-docker.sh', + docker_package: 'docker.io', + docker_version: "#{DOCKER_VERSION}-0ubuntu1~16.04.2") elsif crio? logger.info { "Configuring container runtime (cri-o) packages ..." } - exec_script('configure-cri-o.sh', { - crio_version: CRIO_VERSION, - host: @host - }) + exec_script('configure-cri-o.sh', + crio_version: CRIO_VERSION, + host: @host) else raise Kupo::Error, "Unknown container runtime: #{@host.container_runtime}" end logger.info { "Configuring Kubernetes packages ..." } - exec_script('configure-kube.sh', { + exec_script( + 'configure-kube.sh', kube_version: KUBE_VERSION, kubeadm_version: ENV['KUBEADM_VERSION'] || KUBE_VERSION, arch: @host.cpu_arch.name - }) + ) end def configure_repos diff --git a/lib/kupo/phases/configure_kubelet.rb b/lib/kupo/phases/configure_kubelet.rb index d8f43886e..70029682e 100644 --- a/lib/kupo/phases/configure_kubelet.rb +++ b/lib/kupo/phases/configure_kubelet.rb @@ -1,9 +1,10 @@ +# frozen_string_literal: true + require_relative 'base' module Kupo::Phases class ConfigureKubelet < Base - - DROPIN_PATH = "/etc/systemd/system/kubelet.service.d/5-kupo.conf".freeze + DROPIN_PATH = "/etc/systemd/system/kubelet.service.d/5-kupo.conf" # @param host [Kupo::Configuration::Host] def initialize(host) diff --git a/lib/kupo/phases/configure_master.rb b/lib/kupo/phases/configure_master.rb index 90cdb1c38..5b3775d08 100644 --- a/lib/kupo/phases/configure_master.rb +++ b/lib/kupo/phases/configure_master.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true + require_relative 'base' module Kupo::Phases class ConfigureMaster < Base - # @param master [Kupo::Configuration::Host] # @param config [Kupo::Configuration::Network] def initialize(master, config) @@ -33,7 +34,7 @@ def upgrade? client = Kupo::Kube.client(@master.address) configmap = client.get_config_map('kubeadm-config', 'kube-system') - config = YAML.load(configmap.data[:MasterConfiguration]) + config = YAML.safe_load(configmap.data[:MasterConfiguration]) config['kubernetesVersion'] != "v#{kube_component.version}" end @@ -43,12 +44,14 @@ def install @ssh.upload(StringIO.new(cfg.to_yaml), tmp_file) # Copy etcd certs over if needed - exec_script('configure-etcd-certs.sh', { - ca_certificate: File.read(@config.etcd.ca_certificate), - certificate: File.read(@config.etcd.certificate), - certificate_key: File.read(@config.etcd.key) - - }) if @config.etcd && @config.etcd.certificate + if @config.etcd&.certificate + exec_script( + 'configure-etcd-certs.sh', + ca_certificate: File.read(@config.etcd.ca_certificate), + certificate: File.read(@config.etcd.certificate), + certificate_key: File.read(@config.etcd.key) + ) + end logger.info(@master.address) { "Initializing control plane ..." } @@ -62,7 +65,6 @@ def install end def generate_config - config = { 'apiVersion' => 'kubeadm.k8s.io/v1alpha1', 'kind' => 'MasterConfiguration', @@ -74,18 +76,14 @@ def generate_config } } - if @master.private_address - config['api'] = {'advertiseAddress' => @master.private_address} - else - config['api'] = {'advertiseAddress' => @master.address} - end + config['api'] = { 'advertiseAddress' => @master.private_address || @master.address } if @master.container_runtime == 'cri-o' config['criSocket'] = '/var/run/crio/crio.sock' end # Only configure etcd if the external endpoints are given - if @config.etcd && @config.etcd.endpoints + if @config.etcd&.endpoints config['etcd'] = { 'endpoints' => @config.etcd.endpoints } @@ -97,7 +95,6 @@ def generate_config config end - def upgrade @ssh.exec!("sudo kubeadm upgrade apply #{kube_component.version} -y") diff --git a/lib/kupo/phases/configure_metrics.rb b/lib/kupo/phases/configure_metrics.rb index 6768256a4..a128de869 100644 --- a/lib/kupo/phases/configure_metrics.rb +++ b/lib/kupo/phases/configure_metrics.rb @@ -1,14 +1,15 @@ +# frozen_string_literal: true + require_relative 'base' module Kupo::Phases class ConfigureMetrics < Base - register_component(Kupo::Phases::Component.new( - name: 'metrics-server', version: '0.2.1', license: 'Apache License 2.0' + name: 'metrics-server', version: '0.2.1', license: 'Apache License 2.0' )) register_component(Kupo::Phases::Component.new( - name: 'heapster', version: '1.5.1', license: 'Apache License 2.0' + name: 'heapster', version: '1.5.1', license: 'Apache License 2.0' )) # @param master [Kupo::Configuration::Host] @@ -18,13 +19,18 @@ def initialize(master) def call logger.info { "Configuring metrics-server ..." } - Kupo::Kube.apply_stack(@master.address, 'metrics-server', { - version: '0.2.1', arch: @master.cpu_arch - }) + Kupo::Kube.apply_stack( + @master.address, 'metrics-server', + version: '0.2.1', + arch: @master.cpu_arch + ) + logger.info { "Configuring heapster ..." } - Kupo::Kube.apply_stack(@master.address, 'heapster', { - version: '1.5.1', arch: @master.cpu_arch - }) + Kupo::Kube.apply_stack( + @master.address, 'heapster', + version: '1.5.1', + arch: @master.cpu_arch + ) end end end diff --git a/lib/kupo/phases/configure_network.rb b/lib/kupo/phases/configure_network.rb index 4ee0af658..fe1d4089b 100644 --- a/lib/kupo/phases/configure_network.rb +++ b/lib/kupo/phases/configure_network.rb @@ -1,12 +1,13 @@ +# frozen_string_literal: true + require_relative 'base' module Kupo::Phases class ConfigureNetwork < Base - WEAVE_VERSION = '2.2.1' register_component(Kupo::Phases::Component.new( - name: 'weave-net', version: WEAVE_VERSION, license: 'Apache License 2.0' + name: 'weave-net', version: WEAVE_VERSION, license: 'Apache License 2.0' )) # @param master [Kupo::Configuration::Host] @@ -27,7 +28,7 @@ def ensure_passwd kube_client.get_secret('weave-passwd', 'kube-system') rescue Kubeclient::ResourceNotFoundError logger.info { "Configuring overlay network shared secret ..." } - weave_passwd = Kubeclient::Resource.new({ + weave_passwd = Kubeclient::Resource.new( metadata: { name: 'weave-passwd', namespace: 'kube-system' @@ -35,7 +36,7 @@ def ensure_passwd data: { 'weave-passwd': Base64.strict_encode64(generate_password) } - }) + ) kube_client.create_secret(weave_passwd) end end @@ -43,12 +44,13 @@ def ensure_passwd def ensure_resources trusted_subnets = @config.trusted_subnets || [] logger.info { "Configuring overlay network ..." } - Kupo::Kube.apply_stack(@master.address, 'weave', { + Kupo::Kube.apply_stack( + @master.address, 'weave', trusted_subnets: trusted_subnets, ipalloc_range: @config.pod_network_cidr, arch: @master.cpu_arch, version: WEAVE_VERSION - }) + ) end def generate_password diff --git a/lib/kupo/phases/join_node.rb b/lib/kupo/phases/join_node.rb index 4c839851a..a5a12b3f2 100644 --- a/lib/kupo/phases/join_node.rb +++ b/lib/kupo/phases/join_node.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true + require_relative 'base' module Kupo::Phases class JoinNode < Base - # @param host [Kupo::Configuration::Host] # @param master [Kupo::Configuration::Host] def initialize(host, master) diff --git a/lib/kupo/phases/label_node.rb b/lib/kupo/phases/label_node.rb index 80a73e287..123e334c5 100644 --- a/lib/kupo/phases/label_node.rb +++ b/lib/kupo/phases/label_node.rb @@ -1,8 +1,9 @@ +# frozen_string_literal: true + require_relative 'base' module Kupo::Phases class LabelNode < Base - def initialize(host, master) @host = host @master = master @@ -22,11 +23,12 @@ def call # @param node [Kubeclient::Resource] def patch_node(node) - kube.patch_node(node.metadata.name, { + kube.patch_node( + node.metadata.name, metadata: { labels: @host.labels } - }) + ) end def find_node @@ -50,4 +52,4 @@ def kube @kube ||= Kupo::Kube.client(@master.address) end end -end \ No newline at end of file +end diff --git a/lib/kupo/phases/logging.rb b/lib/kupo/phases/logging.rb index 9e02972fb..dd4746f06 100644 --- a/lib/kupo/phases/logging.rb +++ b/lib/kupo/phases/logging.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'logger' module Kupo::Phases::Logging @@ -5,7 +7,7 @@ def self.initialize_logger(log_target = $stdout, log_level = Logger::INFO) @logger = Logger.new(log_target) @logger.progname = 'API' @logger.level = ENV["DEBUG"] ? Logger::DEBUG : log_level - logger.formatter = proc do |severity, datetime, progname, msg| + logger.formatter = proc do |_severity, _datetime, _progname, msg| " #{msg}\n" end diff --git a/lib/kupo/phases/validate_host.rb b/lib/kupo/phases/validate_host.rb index a844c683a..9e428aca5 100644 --- a/lib/kupo/phases/validate_host.rb +++ b/lib/kupo/phases/validate_host.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'logging' module Kupo::Phases @@ -52,7 +54,7 @@ def os_release(ssh) os_info = {} ssh.file_contents('/etc/os-release').split("\n").each do |line| match = line.match(/^(.+)=(.+)$/) - os_info[match[1]] = match[2].gsub('"', '') + os_info[match[1]] = match[2].delete('"') end Kupo::Configuration::OsRelease.new( id: os_info['ID'], diff --git a/lib/kupo/root_command.rb b/lib/kupo/root_command.rb index 69bf25053..f17660cb4 100644 --- a/lib/kupo/root_command.rb +++ b/lib/kupo/root_command.rb @@ -1,9 +1,10 @@ +# frozen_string_literal: true + require_relative 'up_command' require_relative 'version_command' module Kupo class RootCommand < Clamp::Command - banner "kupo (クポ) - Kontena Kubernetes distribution installer, kupo!" subcommand ["build", "up"], "Initialize/upgrade cluster", UpCommand @@ -11,9 +12,9 @@ class RootCommand < Clamp::Command def self.run super - rescue => exc - $stderr.puts exc.message - $stderr.puts exc.backtrace.join("\n") + rescue StandardError => exc + warn exc.message + warn exc.backtrace.join("\n") end end end diff --git a/lib/kupo/ssh/client.rb b/lib/kupo/ssh/client.rb index 7fdcb1c3e..457f50a2a 100644 --- a/lib/kupo/ssh/client.rb +++ b/lib/kupo/ssh/client.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true + require 'net/ssh' require 'net/scp' module Kupo::SSH - class Error < StandardError + Error = Class.new(StandardError) - end class ExecError < Error attr_reader :cmd, :exit_status, :output @@ -62,7 +63,7 @@ def start(channel) debug_stdout(data) if debug? end - channel.on_extended_data do |c, type, data| + channel.on_extended_data do |_c, _type, data| @stderr += data @output += data @@ -105,14 +106,14 @@ def debug_cmd(cmd) def debug_stdout(data) data.each_line do |line| - $stdout.write(INDENT + pastel.dim("#{line}")) + $stdout.write(INDENT + pastel.dim(line.to_s)) end end def debug_stderr(data) data.each_line do |line| # TODO: stderr is not line-buffered, this indents each write - $stdout.write(INDENT + pastel.red("#{line}")) + $stdout.write(INDENT + pastel.red(line.to_s)) end end @@ -126,9 +127,7 @@ class Client def self.for_host(host) @connections ||= {} unless @connections[host] - @connections[host] = new(host.address, host.user, { - keys: [host.ssh_key_path] - }) + @connections[host] = new(host.address, host.user, keys: [host.ssh_key_path]) @connections[host].connect end @@ -138,7 +137,7 @@ def self.for_host(host) def self.disconnect_all return unless @connections - @connections.each do |host, connection| + @connections.each do |_host, connection| connection.disconnect end end diff --git a/lib/kupo/types.rb b/lib/kupo/types.rb index 124783e32..f46def431 100644 --- a/lib/kupo/types.rb +++ b/lib/kupo/types.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + require 'dry-types' module Kupo module Types include Dry::Types.module end -end \ No newline at end of file +end diff --git a/lib/kupo/up_command.rb b/lib/kupo/up_command.rb index b77381e42..0e2fb67b7 100644 --- a/lib/kupo/up_command.rb +++ b/lib/kupo/up_command.rb @@ -1,6 +1,7 @@ +# frozen_string_literal: true + module Kupo class UpCommand < Kupo::Command - option ['-c', '--config'], 'PATH', 'Path to config file (default: cluster.yml)', attribute_name: :config_file do |config_path| begin File.realpath(config_path) @@ -25,9 +26,10 @@ def execute puts pastel.green("==> Reading instructions ...") configure(load_config(config_content)) end + def configure(config) master_hosts = master_hosts(config) - signal_usage_error 'No master hosts defined' if master_hosts.size == 0 + signal_usage_error 'No master hosts defined' if master_hosts.empty? signal_usage_error 'Only one host can be in master role' if master_hosts.size > 1 begin @@ -67,7 +69,7 @@ def config_content # @param [String] configuration content # @return [Kupo::Config] def load_config(content) - yaml = YAML.load(content) + yaml = YAML.safe_load(content) if yaml.is_a?(String) signal_usage_error "File #{config_file} is not in YAML format" exit 10 @@ -87,9 +89,7 @@ def load_config(content) # @return [Kupo::AddonManager] def addon_manager - @addon_manager ||= Kupo::AddonManager.new([ - __dir__ + '/addons/' - ]) + @addon_manager ||= Kupo::AddonManager.new([__dir__ + '/addons/']) end def load_phases diff --git a/lib/kupo/version.rb b/lib/kupo/version.rb index 1fb200c64..22de19ffc 100644 --- a/lib/kupo/version.rb +++ b/lib/kupo/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Kupo VERSION = "0.3.0-beta.1" end diff --git a/lib/kupo/version_command.rb b/lib/kupo/version_command.rb index ab06cf84d..2a3dfb683 100644 --- a/lib/kupo/version_command.rb +++ b/lib/kupo/version_command.rb @@ -1,6 +1,7 @@ +# frozen_string_literal: true + module Kupo class VersionCommand < Kupo::Command - option "--all", :flag, "Show all versions" def execute @@ -22,4 +23,4 @@ def load_phases Dir.glob(__dir__ + '/phases/*.rb').each { |f| require(f) } end end -end \ No newline at end of file +end