Skip to content
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

Add JSON schema for work-in-progress features.json #5980

Closed
joshspicer opened this issue Dec 1, 2021 · 13 comments
Closed

Add JSON schema for work-in-progress features.json #5980

joshspicer opened this issue Dec 1, 2021 · 13 comments
Assignees
Labels
containers Issue in vscode-remote containers plan-item A plan item
Milestone

Comments

@joshspicer
Copy link
Member

Authors of "feature-sets" will need to know all of the properties available to them when crafting their own features.json. Adding a JSON schema to the configurationSupport to be shared across the vscode-remote-containers and codespaces extensions will allow vscode to suggest hints, as well as provide user-facing documentation before the "real" documentation is released/finalized.

@joshspicer
Copy link
Member Author

cc @Chuxel @chrmarti @2percentsilk

@joshspicer joshspicer self-assigned this Dec 1, 2021
@GavinRay97
Copy link

GavinRay97 commented Dec 6, 2021

Maybe this is useful, as a start?
I took the types I wrote by hand here:

And used quicktype to convert to JSON Schema. It needs comments (easier to comment the TS types and re-generate than write them in the JSON Schema IMO) but better than nothing:

user@MSI:~/tmp$ npx quicktype --src features.types.ts --src-lang ts --lang schema --top-level Feature --out features.json
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "Feature": {
            "title": "Feature",
            "type": "object",
            "properties": {
                "id": {
                    "type": "string",
                    "title": "id"
                },
                "name": {
                    "type": "string",
                    "title": "name"
                },
                "options": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    },
                    "title": "options"
                },
                "buildArg": {
                    "type": "string",
                    "title": "buildArg"
                },
                "entrypoint": {
                    "type": "string",
                    "title": "entrypoint"
                },
                "privileged": {
                    "type": "boolean",
                    "title": "privileged"
                },
                "init": {
                    "type": "boolean",
                    "title": "init"
                },
                "containerEnv": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    },
                    "title": "containerEnv"
                },
                "extensions": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "title": "extensions"
                },
                "mounts": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/Mount"
                    },
                    "title": "mounts"
                },
                "include": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "title": "include"
                },
                "settings": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    },
                    "title": "settings"
                },
                "capAdd": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "title": "capAdd"
                },
                "securityOpt": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "title": "securityOpt"
                }
            },
            "required": [
                "buildArg",
                "id",
                "include",
                "name",
                "options"
            ]
        },
        "Mount": {
            "title": "Mount",
            "type": "object",
            "properties": {
                "source": {
                    "type": "string",
                    "title": "source"
                },
                "target": {
                    "type": "string",
                    "title": "target"
                },
                "type": {
                    "type": "string",
                    "title": "type"
                }
            },
            "required": [
                "source",
                "target",
                "type"
            ]
        }
    }
}

@joshspicer
Copy link
Member Author

Thanks @GavinRay97 - I used a similar tool with my first pass, too :)

@chrmarti chrmarti added this to the January 2022 milestone Jan 18, 2022
@chrmarti chrmarti added containers Issue in vscode-remote containers plan-item A plan item labels Jan 18, 2022
@chrmarti chrmarti self-assigned this Jan 18, 2022
@chrmarti
Copy link
Contributor

Adding the JSON schema for devcontainer-features.json to avoid having it apply to other random features.json files. Is that name fine or would dev-container-features.json (or something else) be better? Since devcontainer.json doesn't have a dash, I didn't want to add one, in documentation we use 'dev container'.

I haven't changed the filename we read from in code, but will do so when agree on the name.

+ @bamurtaugh

@bamurtaugh
Copy link
Member

bamurtaugh commented Jan 19, 2022

devcontainer-features.json makes sense to me and is in-line with our naming convention for the devcontainer CLI (where we also don't introduce a dash or use a space).

@Chuxel
Copy link
Member

Chuxel commented Jan 24, 2022

@joshspicer @chrmarti Isn't this a breaking change? Or will we emit both files?

EDIT: Nevermind - see that we're emitting both in code. 👍

@chrmarti
Copy link
Contributor

chrmarti commented Jan 24, 2022

@Chuxel Emitting both (features.env and devcontainer-features.env I assume) is temporary. @joshspicer is updating test features and vscode-dev-containers.

@joshspicer
Copy link
Member Author

joshspicer commented Jan 24, 2022

I've merged the changes for the action and the template, so we're in kinda of a weird position right now (but better get people on the right path, then have it "work" for now and have it break tomorrow)

@chrmarti
Copy link
Contributor

I assumed we could just do the rename everywhere and be done. Are there others involved who would need to update too?

@joshspicer
Copy link
Member Author

It's just that codespaces will need to be updated with your CLI change, so before that the GitHub Action and template aren't totally aligning with what codespaces will try to do.

@Chuxel
Copy link
Member

Chuxel commented Jan 25, 2022

@Chuxel Emitting both (features.env and devcontainer-features.env I assume) is temporary. @joshspicer is updating test features and vscode-dev-containers.

I've merged the changes for the action and the template, so we're in kinda of a weird position right now (but better get people on the right path, then have it "work" for now and have it break tomorrow)

@chrmarti @joshspicer Yep - agreed. I just don't want to punish early adopters if we can help it.

@chrmarti
Copy link
Contributor

Are there early adopters beyond ourselves? (I see @joshspicer updating explorations for GitHub.)

@Chuxel
Copy link
Member

Chuxel commented Jan 26, 2022

See community/community#7807 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
containers Issue in vscode-remote containers plan-item A plan item
Projects
None yet
Development

No branches or pull requests

5 participants