Skip to content

Instantly share code, notes, and snippets.

@branan
Last active August 29, 2015 14:27
Show Gist options
  • Save branan/1f8a1d953926c40e5b43 to your computer and use it in GitHub Desktop.
Save branan/1f8a1d953926c40e5b43 to your computer and use it in GitHub Desktop.
require 'uri'
module Puppet
newtype(:uri_provider) do
@doc = "A type which determines its provider based on the scheme of a URI passed as a parameter"
ensurable
newparam(:name) do
end
newparam(:uri) do
desc "The URI we should attempt to provide for"
end
def self.fixup_default_provider
@paramhash[:provider].defaultto {
uri = URI(@resource[:uri])
uri.scheme
}
end
# Normally providify gets called automatically when a
# provider is added for a type. We call it explicitly
# here so that we know for sure that the parameter
# exists before we try to change it.
providify
fixup_default_provider
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment