Sha256: 9c8aa02b802c2ba8cb127574851b3c774875cc3861c4ca71dc33102621305e8b

Contents?: true

Size: 766 Bytes

Versions: 2

Compression:

Stored size: 766 Bytes

Contents

require 'cabal/util'
require 'cabal/api'
require 'cabal/api/common/services'

module Cabal
  module API
    module Common
      module PublicKey
        def self.included(base)
          base.class_eval do
            include Cabal::API::Common::Services

            formatter :txt, ->(object, env) {
              object[:public_ssh_key]
            }

            get '/key/:name' do
              name = Cabal::Util.normalize(params[:name])
              cluster_service.create(name) unless cluster_service.names.include?(name)
              key = cluster_service.public_key(name)
              
              {
                name: name,
                public_ssh_key: key
              }
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cabal-api-0.2.4 lib/cabal/api/common/public_key.rb
cabal-api-0.2.3 lib/cabal/api/common/public_key.rb