Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store puppet translation DSL in mgmt #19

Open
purpleidea opened this issue Apr 4, 2019 · 1 comment
Open

Store puppet translation DSL in mgmt #19

purpleidea opened this issue Apr 4, 2019 · 1 comment

Comments

@purpleidea
Copy link
Contributor

Here's a thought:

In mgmt, resources can have "traits". This means they get an extra function with a specific signature attached to it. What if we added a "transformer" trait, which was a special thing that returned the translation DSL for that resource? That way, when we add/change resources, it will always be in sync? The only difference is that at runtime, the puppet side would have to request that stuff at runtime. Would that work?

Eg:

We'd add:

func (obj *PkgRes) PuppetTransformer() (string, error) {
return ```
PuppetX::CatalogTranslation::Type.new :package do
  emit :pkg

  spawn :name do
    @resource[:name]
  end

  rename :ensure, :state do |value|
    case value
    when :installed, :present
      :installed
    when :purged, :absent
      :uninstalled
    else
      translation_failure "uses an ensure value that currently cannot be translated for mgmt (defaulting to 'installed')", value
      :installed
    end
  end
end

)


Or similar. Perhaps there's even a more logical or better API.

TBD
@ffrank
Copy link
Owner

ffrank commented Nov 10, 2019

...and then I can mgmt translate-from-puppet package or ... file and it prints the DSL?

I'm not sure at the moment...the Puppet module relies on autoloading magic from Puppet proper. However, this is not to say that we could not replace that with a scheme like you describe.

I'd rather like it, it would sure make it easier to keep the "what version of mgmt works with which version of the translator" matrix in check 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants