From 6ec9555a693916bcb9d6604b79a4c3734ec54c4d Mon Sep 17 00:00:00 2001 From: Corey Osman Date: Mon, 1 Jul 2019 20:53:47 -0400 Subject: [PATCH] Adds validate task * Adds basic tests for ra10ke * Adds a text based Puppetfile parser module * Adds a monkey patch file for string colors * Adds a new validate task that checks all the refs of all the git urls. * Adds table_print gem for pretty output with validate task --- .gitignore | 2 + .ruby-version | 2 + README.md | 35 +++++++++ Rakefile | 9 ++- lib/ra10ke.rb | 6 +- lib/ra10ke/monkey_patches.rb | 29 +++++++ lib/ra10ke/puppetfile_parser.rb | 84 ++++++++++++++++++++ lib/ra10ke/validate.rb | 97 +++++++++++++++++++++++ ra10ke.gemspec | 3 + spec/fixtures/Puppetfile | 41 ++++++++++ spec/fixtures/Puppetfile_with_bad_refs | 9 +++ spec/ra10ke/puppetfile_parser_spec.rb | 104 +++++++++++++++++++++++++ spec/ra10ke/validate_spec.rb | 69 ++++++++++++++++ spec/ra10ke_spec.rb | 75 ++++++++++++++++++ spec/spec_helper.rb | 5 ++ 15 files changed, 568 insertions(+), 2 deletions(-) create mode 100644 .ruby-version create mode 100644 lib/ra10ke/monkey_patches.rb create mode 100644 lib/ra10ke/puppetfile_parser.rb create mode 100644 lib/ra10ke/validate.rb create mode 100644 spec/fixtures/Puppetfile create mode 100644 spec/fixtures/Puppetfile_with_bad_refs create mode 100644 spec/ra10ke/puppetfile_parser_spec.rb create mode 100644 spec/ra10ke/validate_spec.rb create mode 100644 spec/ra10ke_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/.gitignore b/.gitignore index b844b14..e09cea3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ Gemfile.lock +pkg +.bundle diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..1f78bde --- /dev/null +++ b/.ruby-version @@ -0,0 +1,2 @@ +2.5.3 + diff --git a/README.md b/README.md index b9b2f6a..76dc34a 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,41 @@ runs faster. Reads the Puppetfile in the current directory and installs them under the `path` provided as an argument. +### r10k:validate[path] +The validate rake task will determine if the url is a valid url by connecting +to the repository and verififying it actually exists and can be accessed. +Additional if a branch, tag, or ref is specified in the Puppetfile the validate +task will also verify that that branch/tag/ref exists in the remote repository. + +If you have ever deployed r10k to production only to find out a tag or branch is +missing this validate task will catch that issue. + +A exit status of 0 is returned if there are no faults, while a 1 is returned if +any module has a bad status. + +Status emojis can be customized by setting the following environment variables. + +Example + + * `GOOD_EMOJI='👍'` + * `BAD_EMOJI='😨'` + + +``` +NAME | URL | REF | STATUS +---------|-----------------------------------------------|--------------------------------|------- +splunk | https://github.com/cudgel/splunk.git | prod | 👍 +r10k | https://github.com/acidprime/r10k | v3.1.1 | 👍 +gms | https://github.com/npwalker/abrader-gms | gitlab_disable_ssl_verify_s... | 👍 +rbac | https://github.com/puppetlabs/pltraining-rbac | 2f60e1789a721ce83f8df061e13... | 👍 +acl | https://github.com/dobbymoodge/puppet-acl.git | master | 👍 +deploy | https://github.com/cudgel/deploy.git | master | 👍 +dotfiles | https://github.com/cudgel/puppet-dotfiles.git | master | 👍 +gitlab | https://github.com/vshn/puppet-gitlab | 00397b86dfb3487d9df768cbd36... | 👍 + +👍👍 Puppetfile looks good.👍👍 +``` + #### Limitations * It works only with modules from the [Forge](https://forge.puppetlabs.com), and Git. diff --git a/Rakefile b/Rakefile index 19b5c5d..5715ba3 100644 --- a/Rakefile +++ b/Rakefile @@ -3,8 +3,15 @@ require 'rake/clean' require 'rubygems' require 'bundler/gem_tasks' require 'fileutils' +require 'rspec/core' +require 'rspec/core/rake_task' CLEAN.include("pkg/", "tmp/") CLOBBER.include("Gemfile.lock") -task :default => [:clean, :build] +task :default => [:spec] + +RSpec::Core::RakeTask.new(:spec) do |spec| + spec.pattern = FileList['spec/**/*_spec.rb'] +end + diff --git a/lib/ra10ke.rb b/lib/ra10ke.rb index 75fad96..45e6bc8 100644 --- a/lib/ra10ke.rb +++ b/lib/ra10ke.rb @@ -5,15 +5,17 @@ require 'ra10ke/syntax' require 'ra10ke/dependencies' require 'ra10ke/install' +require 'ra10ke/validate' require 'git' require 'semverse' - +require 'r10k/puppetfile' module Ra10ke class RakeTask < ::Rake::TaskLib include Ra10ke::Solve include Ra10ke::Syntax include Ra10ke::Dependencies include Ra10ke::Install + include Ra10ke::Validate attr_accessor :basedir, :moduledir, :puppetfile_path, :puppetfile_name, :force, :purge @@ -32,6 +34,7 @@ def initialize(*args) define_task_syntax(*args) define_task_dependencies(*args) define_task_install(*args) + define_task_validate(*args) end end @@ -40,3 +43,4 @@ def get_puppetfile end end end + diff --git a/lib/ra10ke/monkey_patches.rb b/lib/ra10ke/monkey_patches.rb new file mode 100644 index 0000000..6824d20 --- /dev/null +++ b/lib/ra10ke/monkey_patches.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class String + # colorization + def colorize(color_code) + "\e[#{color_code}m#{self}\e[0m" + end + + def red + colorize(31) + end + + def green + colorize(32) + end + + def yellow + colorize(33) + end + + # removes specified markes from string. + # @return [String] - the string with markers removed + def strip_comment(markers = ['#', "\n"]) + re = Regexp.union(markers) + index = (self =~ re) + index.nil? ? rstrip : self[0, index].rstrip + end +end + diff --git a/lib/ra10ke/puppetfile_parser.rb b/lib/ra10ke/puppetfile_parser.rb new file mode 100644 index 0000000..02293ab --- /dev/null +++ b/lib/ra10ke/puppetfile_parser.rb @@ -0,0 +1,84 @@ +# it might be desirable to parse the Puppetfile as a string instead of evaling it. +# this module allows you to do just that. +require 'ra10ke/monkey_patches' + +module Ra10ke + module PuppetfileParser + + # @return [Array] - returns a array of hashes that contain modules with a git source + def git_modules(file = puppetfile) + modules(file).find_all do |mod| + mod[:args].key?(:git) + end + end + + # @param puppetfile [String] - the absolute path to the puppetfile + # @return [Array] - returns an array of module hashes that represent the puppetfile + # @example + # [{:namespace=>"puppetlabs", :name=>"stdlib", :args=>[]}, + # {:namespace=>"petems", :name=>"swap_file", :args=>["'4.0.0'"]}] + def modules(puppetfile) + @modules ||= begin + return [] unless File.exist?(puppetfile) + + all_lines = File.read(puppetfile).lines.map(&:strip_comment) + # remove comments from all the lines + lines_without_comments = all_lines.reject { |line| line.match(/#.*\n/) }.join("\n").delete("\n") + lines_without_comments.split('mod').map do |line| + next nil if line =~ /^forge/ + next nil if line.empty? + + parse_module_args(line) + end.compact.uniq + end + end + + # @param data [String] - the string to parse the puppetfile args out of + # @return [Array] - an array of arguments in hash form + # @example + # {:namespace=>"puppetlabs", :name=>"stdlib", :args=>[]} + # {:namespace=>"petems", :name=>"swap_file", :args=>["'4.0.0'"]} + def parse_module_args(data) + return {} if data.empty? + args = data.split(',').map(&:strip) + # we can't guarantee that there will be a namespace when git is used + # remove quotes and dash and slash + namespace, name = args.shift.gsub(/'|"/, '').split(%r{-|/}) + name ||= namespace + namespace = nil if namespace == name + { + namespace: namespace, + name: name, + args: process_args(args) + } + end + + # @return [Array] - returns an array of hashes with the args in key value pairs + # @param [Array] - the arguments processed from each entry in the puppetfile + # @example + # [{:args=>[], :name=>"razor", :namespace=>"puppetlabs"}, + # {:args=>[{:version=>"0.0.3"}], :name=>"ntp", :namespace=>"puppetlabs"}, + # {:args=>[], :name=>"inifile", :namespace=>"puppetlabs"}, + # {:args=> + # [{:git=>"https://github.com/nwops/reportslack.git"}, {:ref=>"1.0.20"}], + # :name=>"reportslack", + # :namespace=>"nwops"}, + # {:args=>{:git=>"git://github.com/puppetlabs/puppetlabs-apt.git"}, + # :name=>"apt", + # :namespace=>nil} + # ] + def process_args(args) + results = {} + args.each do |arg| + a = arg.gsub(/'|"/, '').split(/\A\:|\:\s|\=\>/).map(&:strip).reject(&:empty?) + if a.count < 2 + results[:version] = a.first + else + results[a.first.to_sym] = a.last + end + end + results + end + end +end + diff --git a/lib/ra10ke/validate.rb b/lib/ra10ke/validate.rb new file mode 100644 index 0000000..06cb501 --- /dev/null +++ b/lib/ra10ke/validate.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +require 'ra10ke/monkey_patches' +require 'tempfile' +require 'table_print' +require 'ra10ke/puppetfile_parser' +require 'English' + +module Ra10ke + module Validate + + GOOD_EMOJI = ENV['GOOD_EMOJI'] || '👍' + BAD_EMOJI = ENV['BAD_EMOJI'] || '😨' + + # Validate the git urls and refs + def define_task_validate(*args) + desc 'Validate the git urls and branches, refs, or tags' + task :validate do + gitvalididation = Ra10ke::Validate::Validation.new(puppetfile_path) + exit_code = 0 + if gitvalididation.bad_mods? + exit_code = 1 + message = BAD_EMOJI + ' Not all modules in the Puppetfile are valid. '.red + BAD_EMOJI + else + message = GOOD_EMOJI + ' Puppetfile looks good. '.green + GOOD_EMOJI + end + tp gitvalididation.sorted_mods, :name, { url: { width: 50 } }, :ref, :status + abort(message) if exit_code.positive? + puts message + end + end + + class Validation + include Ra10ke::PuppetfileParser + + attr_reader :puppetfile + + def initialize(file) + file ||= './Puppetfile' + @puppetfile = File.expand_path(file) + abort("Puppetfile does not exist at #{puppetfile}") unless File.readable?(puppetfile) + end + + # @return [Boolean] - return true if the ref is valid + # @param url [String] - the git string either https or ssh url + # @param ref [String] - the ref object, branch name, tag name, or commit sha, defaults to HEAD + def valid_ref?(url, ref = 'HEAD') + raise ArgumentError unless ref + + `git ls-remote --symref #{url} | grep #{ref}` + $CHILD_STATUS.success? + end + + # @return [Boolean] - return true if the commit sha is valid + # @param url [String] - the git string either https or ssh url + # @param ref [String] - the sha id + def valid_commit?(url, sha) + return false if sha.nil? || sha.empty? + puts "Warning: consider pinning #{url} to tag if possible.".yellow + Dir.mktmpdir do |dir| + `git clone --no-tags #{url} #{dir} 2>&1 > /dev/null` + Dir.chdir(dir) do + `git show #{sha} 2>&1 > /dev/null` + $CHILD_STATUS.success? + end + end + end + + # @return [Array[Hash]] array of module information and git status + def all_modules + @all_modules ||= begin + git_modules(puppetfile).map do |mod| + ref = mod[:args][:ref] || mod[:args][:tag] || mod[:args][:branch] + valid_ref = valid_ref?(mod[:args][:git], ref) || valid_commit?(mod[:args][:git], mod[:args][:ref]) + { + name: mod[:name], + url: mod[:args][:git], + ref: ref, + valid_ref?: valid_ref, + status: valid_ref ? Ra10ke::Validate::GOOD_EMOJI : Ra10ke::Validate::BAD_EMOJI + } + end + end + end + + # @return [Boolean] - true if there are any bad mods + def bad_mods? + all_modules.find_all { |mod| !mod[:valid_ref?] }.count > 0 + end + + # @return [Hash] - sorts the mods based on good/bad + def sorted_mods + @sorted_mods ||= all_modules.sort_by { |a| a[:valid_ref?] ? 1 : 0 } + end + end + end +end diff --git a/ra10ke.gemspec b/ra10ke.gemspec index 9b28117..fd54e3f 100644 --- a/ra10ke.gemspec +++ b/ra10ke.gemspec @@ -22,4 +22,7 @@ Gem::Specification.new do |spec| spec.add_dependency "git" spec.add_dependency "solve" spec.add_dependency 'semverse', '~> 2.0' + spec.add_dependency 'table_print', '~> 1.5.6' + spec.add_development_dependency 'rspec', '~> 3.6' end + diff --git a/spec/fixtures/Puppetfile b/spec/fixtures/Puppetfile new file mode 100644 index 0000000..96beb8b --- /dev/null +++ b/spec/fixtures/Puppetfile @@ -0,0 +1,41 @@ +forge "http://forge.puppetlabs.com" + +mod "puppetlabs/inifile", '2.2.0' +mod "puppetlabs/stdlib", '4.24.0' +mod "puppetlabs/concat", '4.0.0' +mod "puppetlabs/ntp", '6.4.1' + +# introduced for tomcat module collaboration with uws +mod 'puppet-archive', '3.1.1' + +mod 'gitlab', + :git => 'https://github.com/vshn/puppet-gitlab', + :ref => '00397b86dfb3487d9df768cbd3698d362132b5bf' # master + +mod 'r10k', + :git => 'https://github.com/acidprime/r10k', + :tag => 'v3.1.1' + +mod 'gms', + :git => 'https://github.com/npwalker/abrader-gms', + :branch => 'gitlab_disable_ssl_verify_support' + +mod 'pltraining-rbac', + :git => 'https://github.com/puppetlabs/pltraining-rbac', + :ref => '2f60e1789a721ce83f8df061e13f8bf81cd4e4ce' + +mod 'puppet-acl', + :git => 'https://github.com/dobbymoodge/puppet-acl.git', + :branch => 'master' + +mod 'deploy', + :git => 'https://github.com/cudgel/deploy.git', + :branch => 'master' + +mod 'dotfiles', + :git => 'https://github.com/cudgel/puppet-dotfiles.git', + :branch => 'master' + +mod 'splunk', + :git => 'https://github.com/cudgel/splunk.git', + :branch => 'prod' diff --git a/spec/fixtures/Puppetfile_with_bad_refs b/spec/fixtures/Puppetfile_with_bad_refs new file mode 100644 index 0000000..078d561 --- /dev/null +++ b/spec/fixtures/Puppetfile_with_bad_refs @@ -0,0 +1,9 @@ +forge "http://forge.puppetlabs.com" + +mod 'gitlab', + :git => 'https://github.com/vshn/puppet-gitlab', + :ref => '00397b86dfb3487d9df768cbd3698d362132b5bf' # master + +mod 'r10k', + :git => 'https://github.com/acidprime/r10k', + :tag => 'bad' diff --git a/spec/ra10ke/puppetfile_parser_spec.rb b/spec/ra10ke/puppetfile_parser_spec.rb new file mode 100644 index 0000000..b27fcff --- /dev/null +++ b/spec/ra10ke/puppetfile_parser_spec.rb @@ -0,0 +1,104 @@ +require 'spec_helper' +require 'ra10ke/puppetfile_parser' + +RSpec.describe 'Ra10ke::PuppetfileParser' do + include Ra10ke::PuppetfileParser + + let(:puppetfile) do + File.join(fixtures_dir, 'Puppetfile') + end + + let(:puppetfile_modules) do + [{:args=>{:version=>"2.2.0"}, :name=>"inifile", :namespace=>"puppetlabs"}, + {:args=>{:version=>"4.24.0"}, :name=>"stdlib", :namespace=>"puppetlabs"}, + {:args=>{:version=>"4.0.0"}, :name=>"concat", :namespace=>"puppetlabs"}, + {:args=>{:version=>"6.4.1"}, :name=>"ntp", :namespace=>"puppetlabs"}, + {:args=>{:version=>"3.1.1"}, :name=>"archive", :namespace=>"puppet"}, + {:args=> + {:git=>"https://github.com/vshn/puppet-gitlab", + :ref=>"00397b86dfb3487d9df768cbd3698d362132b5bf"}, + :name=>"gitlab", + :namespace=>nil}, + {:args=>{:git=>"https://github.com/acidprime/r10k", :tag=>"v3.1.1"}, + :name=>"r10k", + :namespace=>nil}, + {:args=> + {:branch=>"gitlab_disable_ssl_verify_support", + :git=>"https://github.com/npwalker/abrader-gms"}, + :name=>"gms", + :namespace=>nil}, + {:args=> + {:git=>"https://github.com/puppetlabs/pltraining-rbac", + :ref=>"2f60e1789a721ce83f8df061e13f8bf81cd4e4ce"}, + :name=>"rbac", + :namespace=>"pltraining"}, + {:args=> + {:branch=>"master", :git=>"https://github.com/dobbymoodge/puppet-acl.git"}, + :name=>"acl", + :namespace=>"puppet"}, + {:args=>{:branch=>"master", :git=>"https://github.com/cudgel/deploy.git"}, + :name=>"deploy", + :namespace=>nil}, + {:args=> + {:branch=>"master", :git=>"https://github.com/cudgel/puppet-dotfiles.git"}, + :name=>"dotfiles", + :namespace=>nil}, + {:args=>{:branch=>"prod", :git=>"https://github.com/cudgel/splunk.git"}, + :name=>"splunk", + :namespace=>nil}] + end + + + it '#modules' do + expect(modules(puppetfile)).to eq(puppetfile_modules) + end + + it '#git_modules' do + expected = [{:args=> + {:git=>"https://github.com/vshn/puppet-gitlab", + :ref=>"00397b86dfb3487d9df768cbd3698d362132b5bf"}, + :name=>"gitlab", + :namespace=>nil}, + {:args=>{:git=>"https://github.com/acidprime/r10k", :tag=>"v3.1.1"}, + :name=>"r10k", + :namespace=>nil}, + {:args=> + {:branch=>"gitlab_disable_ssl_verify_support", + :git=>"https://github.com/npwalker/abrader-gms"}, + :name=>"gms", + :namespace=>nil}, + {:args=> + {:git=>"https://github.com/puppetlabs/pltraining-rbac", + :ref=>"2f60e1789a721ce83f8df061e13f8bf81cd4e4ce"}, + :name=>"rbac", + :namespace=>"pltraining"}, + {:args=> + {:branch=>"master", :git=>"https://github.com/dobbymoodge/puppet-acl.git"}, + :name=>"acl", + :namespace=>"puppet"}, + {:args=>{:branch=>"master", :git=>"https://github.com/cudgel/deploy.git"}, + :name=>"deploy", + :namespace=>nil}, + {:args=> + {:branch=>"master", :git=>"https://github.com/cudgel/puppet-dotfiles.git"}, + :name=>"dotfiles", + :namespace=>nil}, + {:args=>{:branch=>"prod", :git=>"https://github.com/cudgel/splunk.git"}, + :name=>"splunk", + :namespace=>nil}] + expect(git_modules(puppetfile)).to eq(expected) + end + + it '#parse_modules_args' do + data = " 'puppet-acl', :git => 'https://github.com/dobbymoodge/puppet-acl.git', :branch => 'master'" + expect(parse_module_args(data)).to eq({:args=>{:branch=>"master", + :git=>"https://github.com/dobbymoodge/puppet-acl.git"}, + :name=>"acl", :namespace=>"puppet"}) + end + + it '#parse_modules_args when empty' do + data = "" + expect(parse_module_args(data)).to eq({}) + end +end + diff --git a/spec/ra10ke/validate_spec.rb b/spec/ra10ke/validate_spec.rb new file mode 100644 index 0000000..38e80cf --- /dev/null +++ b/spec/ra10ke/validate_spec.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'ra10ke/validate' +RSpec::Mocks.configuration.allow_message_expectations_on_nil = true + +RSpec.describe 'Ra10ke::Validate::Validation' do + let(:instance) do + Ra10ke::Validate::Validation.new(puppetfile) + end + + let(:result) do + double + end + + before(:each) do + allow(result).to receive(:success?).and_return(true) + allow(instance).to receive(:`).with(anything).and_return(result) + allow($CHILD_STATUS).to receive(:success?).and_return(true) + end + + let(:puppetfile) do + File.join(fixtures_dir, 'Puppetfile') + end + + it '#new' do + expect(instance).to be_a Ra10ke::Validate::Validation + end + + it '#valid_ref?' do + allow(instance).to receive(:`).with('git ls-remote --symref https://www.example.com | grep master') + .and_return(result) + expect(instance.valid_ref?('https://www.example.com', 'master')).to be true + end + + it '#valid_commit?' do + allow(instance).to receive(:`).with('git ls-remote --symref https://www.example.com | grep master') + .and_return(result) + expect(instance.valid_commit?('https://www.example.com', 'master')).to be true + end + + it '#bad_mods?' do + expect(instance.bad_mods?).to be false + end + + it '#all_modules is an array' do + expect(instance.all_modules).to be_a Array + end + + it '#sorted_mods is an array' do + expect(instance.sorted_mods).to be_a Array + end + + it '#data is a hash' do + expect(instance.all_modules.first).to be_a Hash + end + + it '#data is a hash with keys' do + keys = instance.all_modules.first.keys + expect(keys).to eq(%i[name url ref valid_ref? status]) + end + + it '#data is a hash with values' do + keys = instance.all_modules.first.values + expect(keys).to eq(['gitlab', 'https://github.com/vshn/puppet-gitlab', + '00397b86dfb3487d9df768cbd3698d362132b5bf', true, '👍']) + end +end + diff --git a/spec/ra10ke_spec.rb b/spec/ra10ke_spec.rb new file mode 100644 index 0000000..235b408 --- /dev/null +++ b/spec/ra10ke_spec.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true + +require 'ra10ke' +require 'spec_helper' + +RSpec.describe 'Ra10ke::RakeTask' do + let(:instance) do + r = Ra10ke::RakeTask.new + r.puppetfile_path = puppetfile + r + end + + let(:puppetfile) do + File.join(fixtures_dir, 'Puppetfile') + end + + let(:args) do + [] + end + + describe 'validate tasks' do + it '#new' do + expect(instance).to be_a Ra10ke::RakeTask + end + + it '#define_task_validate' do + expect(instance.define_task_validate(args)).to be_a Rake::Task + end + + it '#define_task_solve_dependencies' do + expect(instance.define_task_solve_dependencies(args)).to be_a Rake::Task + end + + it '#define_task_syntax' do + expect(instance.define_task_syntax(args)).to be_a Rake::Task + end + + it '#define_task_dependencies' do + expect(instance.define_task_dependencies(args)).to be_a Rake::Task + end + + it '#define_task_install' do + expect(instance.define_task_install(args)).to be_a Rake::Task + end + + it '#get_puppetfile' do + expect(instance.get_puppetfile).to be_a R10K::Puppetfile + end + end + + describe 'run tasks with good refs' do + it '#run_validate_task' do + task = instance.define_task_validate(args) + expect(task.invoke).to be_a Array + end + end + + describe 'run tasks with bad refs' do + let(:puppetfile_path) do + File.join(fixtures_dir, 'Puppetfile_with_bad_refs') + end + + # I suspect rake is caching something here and the puppetfile is + # not being sent correctly as it is not using the file I specify. + # The output should be different. + # Testing this by itself works + it '#run_validate_task' do + t = Ra10ke::RakeTask.new + t.puppetfile_path = puppetfile_path + task2 = t.define_task_validate(args) + expect(task2.invoke).to be nil + end + end +end + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..0d0e01e --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,5 @@ +def fixtures_dir + File.join(__dir__, 'fixtures') +end + +