Skip to content

Commit

Permalink
Remove plugins from the Devfile schema (#333)
Browse files Browse the repository at this point in the history
* Remove plugins from devfile schema by...

- adding an option in the jsonschema generator
to allow skipping Plugin union members
- setting this option to true on the Devfile jsonschema annotation.

Signed-off-by: David Festal <dfestal@redhat.com>

* Run the fixed generator ...

... to generate devfile schemas without `plugin` components
in both the devfile main body and parent overrides

Signed-off-by: David Festal <dfestal@redhat.com>

* Update samples and tests for removing plugin

Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>

Co-authored-by: Maysun J Faisal <maysunaneek@gmail.com>
  • Loading branch information
davidfestal and maysunfaisal committed Apr 8, 2021
1 parent 1f33556 commit a313872
Show file tree
Hide file tree
Showing 21 changed files with 17 additions and 2,823 deletions.
8 changes: 7 additions & 1 deletion generator/schemas/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ import (
// GenerateJSONSchema drives whether a Json schema should be generated from this GO Struct type
type GenerateJSONSchema struct {

// OmitCustomUnionMembers indicates that the Json schema gnerated from this type should omit Custom union members.
// OmitCustomUnionMembers indicates that the Json schema generated from this type should omit Custom union members.
OmitCustomUnionMembers bool `marker:",optional"`

// OmitPluginUnionMembers indicates that the Json schema generated from this type should omit Plugin component union members.
OmitPluginUnionMembers bool `marker:",optional"`

// Title indicates the content ot the Json Schema `title` attribute
Title string `marker:",optional"`
}
Expand Down Expand Up @@ -213,6 +216,9 @@ This is not the case in the "%s' API group:
if schemaGenerateMarker.OmitCustomUnionMembers {
fieldsToSkip = append(fieldsToSkip, "Custom")
}
if schemaGenerateMarker.OmitPluginUnionMembers {
fieldsToSkip = append(fieldsToSkip, "Plugin")
}

genutils.AddUnionOneOfConstraints(&currentJSONSchema, toDo.unionDiscriminators, true, fieldsToSkip...)

Expand Down
6 changes: 5 additions & 1 deletion generator/schemas/zz_generated.markerhelp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/workspaces/v1alpha2/devfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

// Devfile describes the structure of a cloud-native devworkspace and development environment.
// +k8s:deepcopy-gen=false
// +devfile:jsonschema:generate:omitCustomUnionMembers=true
// +devfile:jsonschema:generate:omitCustomUnionMembers=true,omitPluginUnionMembers=true
type Devfile struct {
devfile.DevfileHeader `json:",inline"`

Expand Down
6 changes: 0 additions & 6 deletions samples/devfiles/job-apply-example.devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ components:
command: ["some", "command", "with", "parameters"]
restartPolicy: Never
backoffLimit: 4
- name: go-support
plugin:
id: ms-vscode/go/latest
- name: editor
plugin:
id: eclipse/che-theia/latest
commands:
- id: cleanup-job
apply:
Expand Down
13 changes: 0 additions & 13 deletions samples/devfiles/nodejs-stack.devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,6 @@ projects:
remotes:
origin: "https://github.com/che-samples/web-nodejs-sample.git"
components:
- name: editor
plugin:
id: eclipse/che-theia/7.1.0
- name: terminal
plugin:
id: eclipse/che-machine-exec-plugin/7.1.0
- name: typescript-plugin
plugin:
id: che-incubator/typescript/1.30.2
components:
- name: "somename"
container:
memoryLimit: 512Mi
- name: nodejs
container:
image: quay.io/eclipse/che-nodejs10-ubi:nightly
Expand Down
14 changes: 0 additions & 14 deletions samples/devfiles/sample-devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ projects:
revision: "main"
remote: origin
components:
- name: editor
attributes:
kjkh: "128M"
kjhkjh:
"": ""
plugin:
id: eclipse/che-theia/latest
- name: "ownplugin"
plugin:
id: acme/newPlugin/latest
registryUrl: "https://acme.com/registry/"
- name: "myplugin"
plugin:
uri: "https://github.com/johndoe/che-plugins/blob/master/cool-plugin/0.0.1/meta.yaml"
- name: "mycontainer"
container:
image: "busybox"
Expand Down
10 changes: 0 additions & 10 deletions samples/devfiles/simple-devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ events:
postStart:
- "build-schema-and-open-devfile"
components:
- name: yaml-support
plugin:
id: redhat/vscode-yaml/latest
- name: go-support
plugin:
id: ms-vscode/go/latest
- name: editor
plugin:
id: eclipse/che-theia/latest
registryUrl: "external-registry-url"
- name: "build-tools"
container:
image: some container image with required build tools
Expand Down
18 changes: 4 additions & 14 deletions samples/devfiles/spring-boot-http-booster-devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,7 @@ projects:
checkoutFrom:
revision: master
components:
- name: java-support
plugin:
id: redhat/java8/latest
components:
- name: vscode-java
container:
memoryLimit: 2Gi
- name: m2
volume:
size: 2G
- name: dependency-analytics
plugin:
id: redhat/dependency-analytics/latest
- name: maven-tooling
- name: maven
container:
image: registry.redhat.io/codeready-workspaces/stacks-java-rhel8:2.1
mountSources: true
Expand All @@ -45,6 +32,9 @@ components:
volumeMounts:
- name: m2
path: /home/jboss/.m2
- name: m2
volume:
size: 2G
commands:
- id: build
exec:
Expand Down

0 comments on commit a313872

Please sign in to comment.