Uploaded image for project: 'DC/OS'
  1. DC/OS
  2. DCOS_OSS-2223

Cosmos should extract defaults from schema intelligently

    Details

    • Sprint:
      Packaging - More S3
    • Story Points:
      1

      Description

      Cosmos currently extracts defaults from the schema and then merges the default options with the user provided options. The extraction of defaults from the schema hinders the powers of json schema. For e.g. this is a valid json schema but cannot be used  : 

      {
          "$schema": "http://json-schema.org/schema#",
          "properties": {
            "registry": {
              "properties": {
                "service-account-secret-path": {
                  "description": "Path to the service account in the Secret store",
                  "type": "string"
                },
                "s3": {
                  "type": "object",
                  "properties": {
                    "credential-file-secret-path": {
                      "type": "string",
                      "description": "The path to the s3 credential file to be used by registry",
                      "examples": [
                        "/path/to/s3/credential/file"
                      ]
                    },
                    "credential-profile-name": {
                      "type": "string",
                      "description": "The name of the profile to use from the credential file",
                      "examples": [
                        "my-profile-name"
                      ]
                    },
                    "bucket": {
                      "type": "string",
                      "description": "The bucket to be used by registry",
                      "examples": [
                        "downloads.organization.com"
                      ]
                    },
                    "path": {
                      "type": "string",
                      "description": "The path to be used in the bucket",
                      "examples": [
                        "custom/mydata"
                      ]
                    },
                    "region": {
                      "type": "string",
                      "description": "Sets the region to be used by the AWS s3 client",
                      "examples": [
                        "us-east-1"
                      ]
                    }
                  },
                  "required": [
                    "bucket",
                    "path",
                    "region"
                  ],
                  "additionalProperties": false
                }
              },
              "anyOf" : [
                {
                  "required" : [
                    "service-account-secret-path"
                  ]
                },
                {
                  "required" : [
                    "service-account-secret-path",
                    "s3"
                  ]
                }
              ],
              "type": "object",
              "additionalProperties": false
            }
          },
          "required": [
            "registry"
          ],
          "type": "object",
          "additionalProperties": false
        }
      

      The anyOf has valid structure but cosmos populate s3 with empty json object thus implying that there is an s3 element. One cannot use a simple test like wether s3 element is present or not in mustache template to build logic.

      https://github.com/dcos/cosmos/blob/master/cosmos-common/src/main/scala/com/mesosphere/cosmos/jsonschema/JsonSchema.scala#L90 is a good place to start.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tarunguptaakirala Tarun Gupta Akirala
                Reporter:
                tarunguptaakirala Tarun Gupta Akirala
                Watchers:
                José Armando García Sancio (Inactive), Tarun Gupta Akirala
              • Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: