(#15106) Propagate catalog env to resources

A number of Puppet classes need to have a reference to an environment.
However environments are not explicitly passed into objects upon
creation, and selecting the correct environment is a bit magic. If
objects are in the wrong environment unexpected things could happen.

One of the points that was causing environment to be 'forgotten' is the
Puppet::Resource::Catalog#resource method, which generates a new
Puppet::Resource. The catalog operates in a single environment but that
information was not being passed to newly created resources.

This commit resolves this issue by explicitly setting the environment on
the resource if the catalog has been given an explicit environment
itself. This has to be done conditionally because the environment
variable can be nil which maps to the production environment.