Skip to content

(PDOC-95) Properly group and display multiple provider defaultfors #111

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

Merged

Conversation

whopper
Copy link
Contributor

@whopper whopper commented Oct 11, 2016

Prior to this commit, strings did not properly handle providers
which had multiple related defaultfors. In code, these are written
as comma-separated constraints. This commit updates strings' puppet
provider handler, as well as the template which generates HTML for
defaultfor statements.

Note that it was necessary to make a breaking change to the JSON
schema to accomodate multiple AND'ed defaults. Previously, provider
defaults were contained in a single key-value map. Now, they are
contained in an array of key-value maps, which allows multiple
constraints to be associated with each other.

@whopper
Copy link
Contributor Author

whopper commented Oct 11, 2016

Here's a before and after for the systemd provider, which has the following defaults:

  defaultfor :osfamily => [:archlinux]
  defaultfor :osfamily => :redhat, :operatingsystemmajrelease => "7"
  defaultfor :osfamily => :redhat, :operatingsystem => :fedora
  defaultfor :osfamily => :suse
  defaultfor :operatingsystem => :debian, :operatingsystemmajrelease => "8"
  defaultfor :operatingsystem => :ubuntu, :operatingsystemmajrelease => ["15.04","15.10","16.04","16.10"]
  defaultfor :operatingsystem => :cumuluslinux, :operatingsystemmajrelease => ["3"]

Before:

screen shot 2016-10-11 at 12 57 22 pm

After:
screen shot 2016-10-11 at 12 57 37 pm

The JSON looks like:

      "defaults": [
        [
          [
            "osfamily",
            "[:archlinux]"
          ]
        ],
        [
          [
            "osfamily",
            "redhat"
          ],
          [
            "operatingsystemmajrelease",
            "7"
          ]
        ],
        [
          [
            "osfamily",
            "redhat"
          ],
          [
            "operatingsystem",
            "fedora"
          ]
        ],
        [
          [
            "osfamily",
            "suse"
          ]
        ],
        [
          [
            "operatingsystem",
            "debian"
          ],
          [
            "operatingsystemmajrelease",
            "8"
          ]
        ],
        [
          [
            "operatingsystem",
            "ubuntu"
          ],
          [
            "operatingsystemmajrelease",
            "[\"15.04\",\"15.10\",\"16.04\",\"16.10\"]"
          ]
        ],
        [
          [
            "operatingsystem",
            "cumuluslinux"
          ],
          [
            "operatingsystemmajrelease",
            "[\"3\"]"
          ]
        ]
      ],

@peterhuene
Copy link
Contributor

👍

@peterhuene
Copy link
Contributor

peterhuene commented Oct 11, 2016

Question though: is defaultfor osfamily: 'RedHat', osfamily: 'Gentoo' valid with respect to Puppet? That is to say, should it be an array of key-value pairs rather than a map for storing this data?

@whopper
Copy link
Contributor Author

whopper commented Oct 11, 2016

@peterhuene defaultfor osfamily: 'RedHat', osfamily: 'Gentoo' would be a conflicting defaultfor and would make the provider not the default of anything.

@whopper whopper force-pushed the PDOC-95/master/multiple_defaultfor branch from 434060f to bf5ecd1 Compare October 11, 2016 20:54
@whopper
Copy link
Contributor Author

whopper commented Oct 11, 2016

@peterhuene updated to use list of lists and verified the case of defaultfor osfamily: 'RedHat', osfamily: 'Gentoo' is displayed correctly (and that everything else still works)

Prior to this commit, strings did not properly handle providers
which had multiple related `defaultfor`s. In code, these are written
as comma-separated constraints. This commit updates strings' puppet
provider handler, as well as the template which generates HTML for
`defaultfor` statements.

Note that it was necessary to make a breaking change to the JSON
schema to accomodate multiple AND'ed defaults. Previously, provider
defaults were contained in a single key-value map. Now, they are
contained in an array of key-value lists, which allows multiple
constraints to be associated with each other.
@whopper whopper force-pushed the PDOC-95/master/multiple_defaultfor branch from bf5ecd1 to a5a3d6b Compare October 11, 2016 20:57
@peterhuene peterhuene merged commit 4f3f1e6 into puppetlabs:master Oct 11, 2016
@chelnak chelnak added the bugfix label Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants