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 isKubernetes option to doHover #347

Merged
merged 1 commit into from
Nov 10, 2020
Merged

Add isKubernetes option to doHover #347

merged 1 commit into from
Nov 10, 2020

Conversation

JPinkney
Copy link
Contributor

@JPinkney JPinkney commented Nov 9, 2020

Signed-off-by: Josh Pinkney [email protected]

What does this PR do?

This PR adds isKubernetes option to doHover. Basically what isKubernetes does is allows you to use a special comparator when evaluating oneOf/anyOf. This is needed because the generic comparator provided works well in the general case but breaks down when you have a ton of anyOf/oneOf like in the kubernetes schema:

What issues does this PR fix or reference?

Part of https://bugzilla.redhat.com/show_bug.cgi?id=1888874

Is it tested? How?

You'll need to set isKubernetes=true in yamlHover.ts before building then set:

"yaml.schemas": {
 "https://gist.githubusercontent.com/JPinkney/fbbb95f3708e8b33f81267b243981ff6/raw/09af433aff3972f5d72cfe5c69951e94c1497875/kubernetes-console.json": "test.yaml"
}

and use:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

as the yaml. Then hover over replicas, selector, etc and see that the hover is working as expected

I can write a test but the json schema for kubernetes is 70000 lines long so I could either have the test pull from the URL specified above or bring the schema into the project though checkout times would increase.

@coveralls
Copy link

coveralls commented Nov 9, 2020

Coverage Status

Coverage decreased (-0.08%) to 77.861% when pulling 4708ed0 on console-hover-fix into 5862fe5 on master.

@eddiezane
Copy link

@JPinkney just curious how you generated the schema in the gist of your testing example.

@JPinkney
Copy link
Contributor Author

JPinkney commented Nov 9, 2020

@eddiezane The openshift console project creates the schema here: https://github.com/openshift/console/blob/master/frontend/public/module/k8s/openapi-to-json-schema.ts#L92 and I just saved it then uploaded it as a gist

@JPinkney JPinkney merged commit a3d5aab into master Nov 10, 2020
@JPinkney JPinkney deleted the console-hover-fix branch November 10, 2020 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants