summaryrefslogtreecommitdiff
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorKen Barber <ken@bob.sh>2011-08-05 08:46:38 +0100
committerKen Barber <ken@bob.sh>2011-08-05 08:46:38 +0100
commit1b73a66fc67af0e33fa41aacf50654d4a7a4903c (patch)
tree7810a9f5af68a74a6305f5db3c7d41330c8a85cc /lib/puppet/parser
parent681a1c7971d78c53dc9a0747ae4d983ff6b0d670 (diff)
* Moved kwalify to puppetlabs-kwalify project
* Re-arranged tests in line with puppetlabs-stdlib
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/functions/kwalify.rb35
-rw-r--r--lib/puppet/parser/functions/validate_resource.rb41
2 files changed, 0 insertions, 76 deletions
diff --git a/lib/puppet/parser/functions/kwalify.rb b/lib/puppet/parser/functions/kwalify.rb
deleted file mode 100644
index 49b9aeb..0000000
--- a/lib/puppet/parser/functions/kwalify.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# kwalify.rb
-#
-
-module Puppet::Parser::Functions
- newfunction(:kwalify, :type => :statement, :doc => <<-EOS
-This function uses kwalify to validate Puppet data structures against Kwalify
-schemas.
- EOS
- ) do |args|
-
- raise(Puppet::ParseError, "kwalify(): Wrong number of arguments " +
- "given (#{args.size} for 2)") if args.size != 2
-
- schema = args[0]
- document = args[1]
-
- require 'kwalify'
-
- validator = Kwalify::Validator.new(schema)
-
- errors = validator.validate(document)
-
- if errors && !errors.empty?
- error_out = []
- for e in errors
- error_out << "[#{e.path}] #{e.message}"
- end
- raise(Puppet::ParseError, "Failed kwalify schema validation:\n" + error_out.join("\n"))
- end
-
- end
-end
-
-# vim: set ts=2 sw=2 et :
diff --git a/lib/puppet/parser/functions/validate_resource.rb b/lib/puppet/parser/functions/validate_resource.rb
deleted file mode 100644
index d71ef3f..0000000
--- a/lib/puppet/parser/functions/validate_resource.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# validate_resource
-#
-
-module Puppet::Parser::Functions
- newfunction(:validate_resource, :type => :statement, :doc => <<-EOS
-This function when placed at the beginning of a class, will go looking for a
-valid kwalify schema by replacing the extension of the file with '.schema'.
-
-It will then validate the arguments passed to the function using that kwalify
-schema.
- EOS
- ) do |arguments|
-
- require 'kwalify'
-
- if (arguments.size != 0) then
- raise(Puppet::ParseError, "validate_resource(): Wrong number of arguments "+
- "given #{arguments.size} for 0")
- end
-
-
- classhash = to_hash(recursive=false)
- sourcepath = source.file
- schemapath = sourcepath.gsub(/\.(rb|pp)$/, ".schema")
- schema = Kwalify::Yaml.load_file(schemapath)
- validator = Kwalify::Validator.new(schema)
- errors = validator.validate(classhash)
-
- if errors && !errors.empty?
- error_output = "Resource validation failed:\n"
- for e in errors
- error_output += "[#{e.path}] #{e.message}\n"
- end
- raise(Puppet::ParseError, error_output)
- end
-
- end
-end
-
-# vim: set ts=2 sw=2 et :