Please review pull request #275: Add stdin parsing to puppet parser validate opened by (zsprackett)

Description:

Git pre-commit hooks everywhere relied on the stdin parsing that existed before faces. This restores that behavior if stdin is not a tty.

  • Opened: Thu Dec 15 04:53:33 UTC 2011
  • Based on: puppetlabs:master (9b7c73a74d5d03ea157e1e4d5ae7a6eba99fd24e)
  • Requested merge: zsprackett:feature-parserface (77bf5f21054bcd66700282a13204d2aa1d544e2c)

Diff follows:

diff --git a/lib/puppet/face/parser.rb b/lib/puppet/face/parser.rb
index c99cbb7..3242fac 100644
--- a/lib/puppet/face/parser.rb
+++ b/lib/puppet/face/parser.rb
@@ -24,13 +24,22 @@
       Validate two arbitrary manifest files:
 
       $ puppet parser validate init.pp vhost.pp
+
+      Validate from STDIN:
+
+      $ cat init.pp | puppet parser validate
     EOT
     when_invoked do |*args|
       args.pop
       files = args
       if files.empty?
-        files << Puppet[:manifest]
-        Puppet.notice "No manifest specified. Validating the default manifest #{Puppet[:manifest]}"
+        if not STDIN.tty?
+          Puppet[:code] = STDIN.read
+          Puppet::Node::Environment.new(Puppet[:environment]).known_resource_types.clear
+        else
+           files << Puppet[:manifest]
+           Puppet.notice "No manifest specified. Validating the default manifest #{Puppet[:manifest]}"
+        end
       end
       files.each do |file|
         Puppet[:manifest] = file

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppet-dev@googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to