Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

generate a json-schema file #45

Closed
jstrachan opened this issue Jun 20, 2017 · 16 comments
Closed

generate a json-schema file #45

jstrachan opened this issue Jun 20, 2017 · 16 comments

Comments

@jstrachan
Copy link

it'd be nice to generate a json schema file so we can include support for kapp inside tools like this: https://github.com/gorkem/vscode-k8s/ so that we can get automatic completion and validation in VS Code / Che / Eclipse.

I wonder if we maybe need to add a line like:

kind: App

to make it easier to know what schema to use in the IDE plugin?

@jstrachan
Copy link
Author

since the schema is gonna change, I'm hoping we can automate the generation of the schema as part of the build from the source - am sure the kubernetes project does something like this for its swagger stuff?

@surajssd
Copy link
Member

For reference:

We need to figure out how do we create a swagger API or openAPI.

@pradeepto
Copy link
Member

pradeepto commented Jun 26, 2017

@surajssd Thanks for recording all the links here. Will be helpful.

@jstrachan I think, we will take this up this sprint in small pieces. This will help PM validation as well.

  • Understand how this is being done
  • Generate json-scheme for our app-spec
  • LSP bits - integration with vscode and che

@jstrachan
Copy link
Author

BTW here's the project which we use to generate Java DTOs & JSON Schemas for kubernetes and openshift
https://github.com/fabric8io/kubernetes-model - though its Java centric; there's probably an easier way in golang to go straight from the go code -> json schema

@kadel kadel assigned kadel and unassigned kadel Jun 29, 2017
@surajssd
Copy link
Member

surajssd commented Jul 4, 2017

Right now the work is being done in https://github.com/surajssd/kedgeSchema

It can generate the schema but not sure if the schema is complete or correct

@surajssd
Copy link
Member

surajssd commented Jul 4, 2017

removing the image field

$ cat ./example/db.json 
{
  "name": "database",
  "containers": [
    {
      "name": "db",
      "env": [
        {
          "name": "MYSQL_ROOT_PASSWORD",
          "value": "rootpasswd"
        },
        {
          "name": "MYSQL_PASSWORD",
          "value": "wordpress"
        }
      ],
      "envFrom": [
        {
          "configMapRef": {
            "name": "database"
          }
        }
      ]
    }
  ],
...

trying to validate

$ jsonschema -F "{error.message}" -i ./example/db.json ./configs/appspec.json 
u'image' is a required property

errors out


changing the field type of name

$ cat ./example/db.json 
{
  "name": 1,
  "containers": [
    {
...

errors out as:

$ jsonschema -F "{error.message}" -i ./example/db.json ./configs/appspec.json 
1 is not of type u'string'

The file configs/appspec.json is the schema for kedge if I am not mistaken.

@pradeepto
Copy link
Member

@surajssd This is a great start. We should break this issue into multiple issues and have checklist. WDYT?

@surajssd
Copy link
Member

surajssd commented Jul 5, 2017

@surajssd This is a great start. We should break this issue into multiple issues and have checklist. WDYT?

Yes I think so we can create a checklist to do that

@surajssd
Copy link
Member

surajssd commented Jul 5, 2017

  • Find the right place to place this jsonschema generation code
  • Put some explanation of how this generation works
  • Everytime we update anything in spec.go there has to be a parallel update in the base schema.
  • What K8s version do we base off of?
  • Versioning of the jsonschema

@kadel
Copy link
Member

kadel commented Jul 31, 2017

Find the right place to place this jsonschema generation code

could we create new subcommand for generating current jsonschema? Something like kedge jsonschema that will output json schema to stdout?

Everytime we update anything in spec.go there has to be a parallel update in the base schema.

solved by above ;-)

What K8s version do we base off of?

depends on how we solve #141
I think that there should be command line option to specify the version.

kedge generate --k8s-version=1.6 and same for kedge jsonschema --k8s-version=1.6

Versioning of the jsonschema

if we have sub command for outputting JSON schema we don't need that.

@kadel
Copy link
Member

kadel commented Aug 2, 2017

how will #119 impact Json schema generation?

@surajssd
Copy link
Member

@kadel not sure how it will impact the jsonschema I wil need to find that because now we won't have one struct but multiple ones, so can't say anything now!

@kadel kadel added this to the 0.2.0 milestone Aug 10, 2017
@pradeepto
Copy link
Member

We need to make sure the generated json schema are stored as artifacts some where in the repository. And this file should be generated by CI for every release for now.

@surajssd
Copy link
Member

Find the right place to place this jsonschema generation code

Generation code resides in https://github.com/kedgeproject/kedge-jsonschema

Put some explanation of how this generation works

The repo has documentation of how to generate the configs, also the way code works can be understood by reading comments in code

Everytime we update anything in spec.go there has to be a parallel update in the base schema

This needs to be done filed an issue for this one #280

What K8s version do we base off of?

right now it is based on k8s 1.7 https://github.com/kedgeproject/kedge-jsonschema/blob/master/scripts/k8s-release

Versioning of the jsonschema

this needs to be evaluated

@kadel
Copy link
Member

kadel commented Sep 19, 2017

Is there a place where I can find JSON schema for the latest release?

@surajssd
Copy link
Member

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants