Changing Attributes of Features

Created by Stuart Cowen, Modified on Thu, 22 Jun, 2023 at 6:38 PM by Stuart Cowen

Glossary

  • solutions architect/architect - a person who logs into Feature Studio UI and creates an architecture and deployment

  • feature author - a person who makes the feature and uploads it to Pratexo via feature-adapter

  • feature attribute - any of the attributes present in values.yaml

  • feature - an installable piece of software, like kibana, modbus2mqtt

Rationale

  • An architect that uses a feature should have an option to configure a feature. By configuring I mean changing their e.g. security or networking attributes .

  • On the other hand, the architect should not be aware of the complexity of the feature. They should only be presented with a subset of configurable attributes.

  • Feature author should be able to decide which attributes are configurable by the architect

  • Feature author should be able create logic to transform any file of that feature based on the input from the architect in the UI


The two files that configure all of this

kibana

└── 7.17.2

    ├── manifest.yaml

    └── replicaSet

        ├── helm

        │   └── values.yaml

        └── schemas

                -------- HERE -------

            ├── ui.schema.json              <---- 

            └── ui.schema.midlayer.json      <----

Reference in manifest.yaml

The files must be referenced in manifest.yaml as shown below.

id: kibana

name: kibana

organization: "com.pratexo"

version: 7.17.2

description: Kibana helm chart

deployments: 

  - kind: helm_chart

    featureId: kibana

    version: 7.17.2

    uiSchemaRef: schemas/ui.schema.json

    uiSchemaMidlayerRef: schemas/ui.schema.midlayer.json

    rest_removed: `for brevity`


ui.schema.json

  • the file represents the attributes configurable by the architect. These attributes translate 1:1 to the view in Feature Studio UI.

{

    "$schema": "http://json-schema.org/draft-07/schema#",

    "title": "Kibana",

    "properties": {

        "featureName": {

            "type": "string",

            "title": "Feature name",

            "enum": [

                "kibana"

            ],

            "default": "kibana"

        },

        "replicaCount": {

            "type": "number",

            "title": "Replica count",

            "default": 1

        },

        "servicePort": {

            "type": "number",

            "title": "Service Port",

            "default": 5601

        },

        "ingressEnabled": {

            "title": "Ingress enabled",

            "type": "boolean",

            "default": true

        },

        "ingressHostname": {

            "type": "string",

            "title": "Ingress hostname",

            "default": "kibana.pratexo.com"

        },

        "username": {

            "type": "string",

            "title": "Username",

            "default": "elastic"

        },

        "password": {

            "type": "string",

            "title": "Password",

            "default": "elastic"

        },

        "tlsEnabled": {

            "type": "boolean",

            "title": "TLS enabled",

            "default": true

        }

    }

}


It is possible to conditionally display attributes in the UI, like so:

"automaticUpgrade": {

    "type": "boolean",

    "title": "Automatic upgrade",

    "path": "/keel/enable",

    "default": false

},       

"keelTrigger": {

    "type": "string",

    "title": "AutomaticUpgrade trigger",

    "path": "/keel/trigger",

    "default": "poll",

    "enum": [

        "poll"

    ],

    "conditions": [

        {

            "path": "/keel/enable",

            "value": true

        }

    ]

}


ui.schema.midlayer.json

  • the file represents patches to files in output directory based on the input from the UI

  • the input from the user becomes a variable named userInput in the ui.schema.midlayer.json file

  • given the following property in the ui.schema.json

{

  "loggingPath":{

    "type": "string",

    "title": "Path where to store logs locally",

    "default": "/var/log/pratexo/mqtt-2-influxdb-adaptor"

  }

}

ui.schema.midlayer.json should follow the format:

{

  "Path where to store logs locally": {

    "values.yaml": [

      {

        "title": "Set Path where to store logs locally",

        "comparison": [

          {

            "type": "always"

          }

        ],

        "operations": [

          {

            "op": "copy",

            "from": "/externalVariables/userInput",

            "path": "/self/Logging/Path"

          }

        ]

      }

    ]

  }

}


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article