From 1e61c09f6d8d8cae64946da130b9fc4aae628fcd Mon Sep 17 00:00:00 2001 From: Jens Harbott Date: Tue, 23 Apr 2019 10:19:09 +0000 Subject: [PATCH] Add recipe to create bash completions for OSC The new recipe "completions" can be executed in order to create a file with command completions for the "openstack" command in bash. We want this to be dynamic because the set of available commands depends on the set of python plugins installed on the host. Bump minor version for stable branch. Change-Id: Ib6549c00596f6560dab74491309b6b580ae7b312 (cherry picked from commit 9170a08c7c4c427438d4353ff82438376d3ea3ac) --- attributes/default.rb | 3 +++ metadata.rb | 2 +- recipes/completions.rb | 25 +++++++++++++++++++++++++ spec/completions_spec.rb | 12 ++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 recipes/completions.rb create mode 100644 spec/completions_spec.rb diff --git a/attributes/default.rb b/attributes/default.rb index 22dd66ef..47dc9fec 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -303,6 +303,9 @@ when 'debian' } end +# The location of the OSC bash completion file +default['openstack']['common']['bash_complete'] = '/etc/bash_completion.d/osc.bash_completion' + # The name of the Chef role that installs the Keystone Service API default['openstack']['identity_service_chef_role'] = 'os-identity' diff --git a/metadata.rb b/metadata.rb index de81ab05..50d2e871 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ maintainer_email 'openstack-dev@lists.openstack.org' license 'Apache-2.0' description 'Common OpenStack attributes, libraries and recipes.' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '17.0.1' +version '17.1.0' recipe 'openstack-common', 'Installs/Configures common recipes' recipe 'openstack-common::logging', 'Installs/Configures common logging' diff --git a/recipes/completions.rb b/recipes/completions.rb new file mode 100644 index 00000000..861c2280 --- /dev/null +++ b/recipes/completions.rb @@ -0,0 +1,25 @@ +# encoding: UTF-8 +# +# Cookbook Name:: openstack-common +# Recipe:: completions +# +# Copyright 2019, x-ion GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +bash_complete = node['openstack']['common']['bash_complete'] +execute 'create OSC bash completions' do + command "openstack complete > #{bash_complete}" + creates bash_complete +end diff --git a/spec/completions_spec.rb b/spec/completions_spec.rb new file mode 100644 index 00000000..63867cdb --- /dev/null +++ b/spec/completions_spec.rb @@ -0,0 +1,12 @@ +# encoding: UTF-8 +require_relative 'spec_helper' + +describe 'openstack-common::completions' do + describe 'ubuntu' do + let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } + let(:node) { runner.node } + let(:chef_run) do + runner.converge(described_recipe) + end + end +end