Skip to content

Commit

Permalink
Merge pull request #693 from DavidS/revert-pdk-new-transport
Browse files Browse the repository at this point in the history
Revert "Merge pull request #666 from DavidS/fm-8081-pdk-new-transport"
  • Loading branch information
scotje authored Jul 1, 2019
2 parents e346560 + b52a666 commit 2a66f44
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 267 deletions.
1 change: 0 additions & 1 deletion lib/pdk/cli/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ module PDK::CLI
require 'pdk/cli/new/module'
require 'pdk/cli/new/provider'
require 'pdk/cli/new/task'
require 'pdk/cli/new/transport'
25 changes: 0 additions & 25 deletions lib/pdk/cli/new/transport.rb

This file was deleted.

4 changes: 0 additions & 4 deletions lib/pdk/cli/util/option_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ def self.valid_module_name?(string)
# Let's assume that only strings similar to module names can actually be resolved by the puppet language.
singleton_class.send(:alias_method, :valid_provider_name?, :valid_module_name?)

# The name has to be a ruby symbol.
# While overly strict, let's apply the provider and module name rules for consistency.
singleton_class.send(:alias_method, :valid_transport_name?, :valid_provider_name?)

# Validate a Puppet namespace against the regular expression in the
# documentation: https://docs.puppet.com/puppet/4.10/lang_reserved.html#classes-and-defined-resource-types
def self.valid_namespace?(string)
Expand Down
1 change: 0 additions & 1 deletion lib/pdk/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require 'pdk/generate/provider'
require 'pdk/generate/puppet_class'
require 'pdk/generate/task'
require 'pdk/generate/transport'
require 'pdk/module/metadata'
require 'pdk/module/templatedir'

Expand Down
5 changes: 5 additions & 0 deletions lib/pdk/generate/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ def target_spec_path
def target_type_spec_path
@target_type_spec_path ||= File.join(module_dir, 'spec', 'unit', 'puppet', 'type', object_name) + '_spec.rb'
end

# transform a object name into a ruby class name
def self.class_name_from_object_name(object_name)
object_name.to_s.split('_').map(&:capitalize).join
end
end
end
end
19 changes: 3 additions & 16 deletions lib/pdk/generate/puppet_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ def target_type_spec_path
nil
end

# @abstract Subclass and implement {#target_device_path}. Implementations
# of this method should return a String containing the destination path
# of the device class being generated.
def target_device_path
nil
end

# Retrieves the type of the object being generated, e.g. :class,
# :defined_type, etc. This is specified in the subclass' OBJECT_TYPE
# constant.
Expand All @@ -106,7 +99,7 @@ def object_type
#
# @api public
def check_preconditions
[target_object_path, target_type_path, target_device_path, target_spec_path, target_type_spec_path].compact.each do |target_file|
[target_object_path, target_type_path, target_spec_path, target_type_spec_path].compact.each do |target_file|
next unless File.exist?(target_file)

raise PDK::CLI::ExitWithError, _("Unable to generate %{object_type}; '%{file}' already exists.") % {
Expand All @@ -132,7 +125,6 @@ def run

render_file(target_object_path, template_path[:object], data)
render_file(target_type_path, template_path[:type], data) if template_path[:type]
render_file(target_device_path, template_path[:device], data) if template_path[:device]
render_file(target_spec_path, template_path[:spec], data) if template_path[:spec]
render_file(target_type_spec_path, template_path[:type_spec], data) if template_path[:type_spec]
end
Expand Down Expand Up @@ -227,9 +219,9 @@ def with_templates
# TODO: refactor to a search-and-execute form instead
return # work is done # rubocop:disable Lint/NonLocalExitFromIterator
elsif template[:allow_fallback]
PDK.logger.debug(_('Unable to find a %{type} template in %{url}; trying next template directory.') % { type: object_type, url: template[:uri] })
PDK.logger.debug(_('Unable to find a %{type} template in %{url}; trying next template directory.') % { type: object_type, url: template[:url] })
else
raise PDK::CLI::FatalError, _('Unable to find the %{type} template in %{url}.') % { type: object_type, url: template[:uri] }
raise PDK::CLI::FatalError, _('Unable to find the %{type} template in %{url}.') % { type: object_type, url: template[:url] }
end
end
end
Expand Down Expand Up @@ -287,11 +279,6 @@ def module_metadata
raise PDK::CLI::FatalError, _("'%{dir}' does not contain valid Puppet module metadata: %{msg}") % { dir: module_dir, msg: e.message }
end
end

# transform a object name into a ruby class name
def self.class_name_from_object_name(object_name)
object_name.to_s.split('_').map(&:capitalize).join
end
end
end
end
87 changes: 0 additions & 87 deletions lib/pdk/generate/transport.rb

This file was deleted.

2 changes: 0 additions & 2 deletions lib/pdk/module/templatedir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,13 @@ def render
def object_template_for(object_type)
object_path = File.join(@object_dir, "#{object_type}.erb")
type_path = File.join(@object_dir, "#{object_type}_type.erb")
device_path = File.join(@object_dir, "#{object_type}_device.erb")
spec_path = File.join(@object_dir, "#{object_type}_spec.erb")
type_spec_path = File.join(@object_dir, "#{object_type}_type_spec.erb")

if File.file?(object_path) && File.readable?(object_path)
result = { object: object_path }
result[:type] = type_path if File.file?(type_path) && File.readable?(type_path)
result[:spec] = spec_path if File.file?(spec_path) && File.readable?(spec_path)
result[:device] = device_path if File.file?(device_path) && File.readable?(device_path)
result[:type_spec] = type_spec_path if File.file?(type_spec_path) && File.readable?(type_spec_path)
result
else
Expand Down
131 changes: 0 additions & 131 deletions spec/acceptance/new_transport_spec.rb

This file was deleted.

0 comments on commit 2a66f44

Please sign in to comment.