Skip to content

Improve how connections are defined in settings #135

@gjsjohnmurray

Description

@gjsjohnmurray

I am opening this issue to start a discussion.

Current situation

An extension's settings can be held in several locations, such as:

  • settings.json for the user
  • XYZ.code-workspace file if used
  • .vscode/settings.json in the current root folder

More details in VS Code docs here.

In this extension the settings for how to connect to an InterSystems server are currently (as at 0.8.6) held in a structure that can only define a single connection. Below is the JSON of the default instance of this structure:

"objectscript.conn": {
    "active": false,
    "host": "localhost",
    "port": 52773,
    "username": "_SYSTEM",
    "password": "SYS",
    "ns": "USER",
    "https": false,
    "docker-compose": {
        "service": "",
        "internalPort": 52773,
        "file": "docker-compose.yml"
    },
    "links": {}
}

This is a significant restriction at user level. On my workstation I can only define a single connection.

When the connection is defined per workspace (in XYZ.code-workspace or in .vscode/settings.json) the limitation is tolerable, but it obstructs the use of multi-root workspaces and the isfs scheme to span multiple servers.

Contrast this with how InterSystems IRIS Server Manager allows definition of multiple named connections.

Proposals

Below is intended as a discussion-starter.

  1. Use an array, subscripted by a user-defined name for each connection. The extension's definition of the settings it contributes can validate names against a pattern, e.g.
"intersystems.servers": {
    "type": "object",
    "description": "Target environments. Each property names a server and holds nested properties defining how to connect to it.\nServer names may only contain characters 'A' to 'Z', 'a' to 'z', digits, '.', '-' and '_' characters.",
    "scope": "resource",
    "default": {
        "localhost": {
            "host": "localhost"
        }
    },
    "patternProperties": {
        "^[A-Za-z0-9_\\.\\-]+$": {
            "type": "object",
            "description": "A server definition, with properties that specify how to connect to it",
            "properties": {
                "host": {
                    "type": "string",
                    "description": "Hostname or IP address of target InterSystems environment.",
                    "anyOf": [
                        {
                            "format": "hostname"
                        },
                        {
                            "format": "ipv4"
                        },
                        {
                            "format": "ipv6"
                        }
                    ],
                    "default": "localhost"
                },

                ...

            }
        }
    },
    "additionalProperties": false
},
  1. Align connection properties with the settings that the existing Server Manager lets users define. For example, these cater for:

    • Connecting to InterSystems superserver as well as to to web server
    • InterSystems servers located behind a shared web server (i.e. not using the private Apache)
  2. Separate the connection definition (which could be used by multiple extensions) from other settings (e.g. "links", and maybe also "docker-compose") that are extension-specific. Extensions should store connection-specific settings in their own array keyed by server name as defined in the intersystems.servers structure above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestreviewrequires discussion

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions