Sha256: ad45dc05633d547400b10d27fe3f55d1fec5da042bb8c2ca02e86e4a2ef5b447

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

# 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.
#
require File.expand_path('../digital_ocean_base', __FILE__)

class Chef
  class Knife
    class DigitalOceanSshkeyList < Knife
      include Knife::DigitalOceanBase

      banner 'knife digital_ocean sshkey list'

      def run
        $stdout.sync = true

        validate!

        sshkey_list = [
          h.color('ID',   :bold),
          h.color('Name', :bold),
        ]

        sshkeys = client.ssh_keys.list.ssh_keys

        sshkeys.sort! do |a, b|
          a.name <=> b.name
        end

        sshkeys.each do |sshkey|
          sshkey_list << sshkey.id.to_s
          sshkey_list << sshkey.name.to_s
        end

        puts h.list(sshkey_list, :uneven_columns_across, 2)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
knife-digital_ocean-0.0.5 lib/chef/knife/digital_ocean_sshkey_list.rb
knife-digital_ocean-0.0.4 lib/chef/knife/digital_ocean_sshkey_list.rb
knife-digital_ocean-0.0.2 lib/chef/knife/digital_ocean_sshkey_list.rb
knife-digital_ocean-0.0.1 lib/chef/knife/digital_ocean_sshkey_list.rb