Uploaded image for project: 'Coopr'
  1. Coopr
  2. COOPR-629

Update template APIs to support extending templates and including partials

    Details

      Description

      Example template using new features:

      {
        "name": "cdap-distributed",
        "description": "Cask DAP (CDAP) with Security and Hadoop cluster with single master",
        “extends”: {
          “name”: “cdap-distributed-insecure”
        },
        "includes": [
          { "name" : "monitoring-thing" },
          { "name" : "monitoring-thing-2" }
        ],
        "defaults": {
          "services": [
            "cdap-security"
          ],
          "config": {
            "security.enabled": "true",
            "security.authentication.handlerClassName": "co.cask.cdap.security.server.LDAPAuthenticationHandler",
             "security.authentication.loginmodule.className": "org.eclipse.jetty.plus.jaas.spi.LdapLoginModule",
             "security.authentication.handler.debug": "true",
             "security.authentication.handler.hostname": "ldap.example.com",
             "security.authentication.handler.port": "389",
             "security.authentication.handler.userBaseDn": "ou=people,dc=example,dc=com",
             "security.authentication.handler.userRdnAttribute": "cn",
             "security.authentication.handler.userObjectClass": "inetorgperson",
             "security.server.ssl.enabled": "false",      
          }
        },
        "compatibility": {
          "services": [
            "cdap-security"
          ]
        },
      }
      

      In other words, templates can now specify two new options: "extends" and "includes". You can provide a template as the value for "extends" and a list of partials as the value for "includes". The parent template and partials will be combined with the following rules:

      1. the json hash structure is recursively merged
      2. when merging two hashes
        1. any new keys are added
        2. when values differ
          1. if they are both strings or both primitives, the child takes precedence
          2. if they are both arrays, the elements are combined
            1. hashes as array elements are just treated as array elements and not traversed further
            2. children are appended to end of parent array. order should not matter
          3. if they are both hashes, this logic recurses
          4. if values are of different types, throw exception

      NOTE: In case of combining arrays of services, we will use a set instead of an array to deduplicate services since it doesn't make sense to have multiple instances of the same service in a template. We may also apply this special case logic in other cases, but for now it's only for services.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rpedanov@cask.co Ruslan Pedanov
                Reporter:
                alvin Alvin Wang
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: