-
Notifications
You must be signed in to change notification settings - Fork 292
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
cmd/cue: import on a valid JSONSchema file fails #2654
Comments
cue import
ing a valid JSONSchema file failsThis change adds a new piece of content which shows how to manage a GitLab repo's CI/CD pipeline file in CUE, instead of YAML. Because GitLab still needs to see a YAML file serialised in the repo, the guide includes a CUE _tool that turns the CUE back into YAML on demand. It also includes a schema for the pipeline's representation, but this schema is pretty lightweight and could do with improving. Part of the problem is that I had to manually write the schema, as GitLab's JSONSchema schema currently confuses `cue import`. I opened cue-lang/cue#2654 to track this. Closes cue-labs#19
This change adds a new piece of content which shows how to manage a GitLab repo's CI/CD pipeline file in CUE, instead of YAML. Because GitLab still needs to see a YAML file serialised in the repo, the guide includes a CUE _tool that turns the CUE back into YAML on demand. It also includes a schema for the pipeline's representation, but this schema is pretty lightweight and could do with improving. Part of the problem is that I had to manually write the schema, as GitLab's JSONSchema schema currently confuses `cue import`. I opened cue-lang/cue#2654 to track this. Closes cue-labs#19
This change adds a new piece of content which shows how to manage a GitLab repo's CI/CD pipeline file in CUE, instead of YAML. Because GitLab still needs to see a YAML file serialised in the repo, the guide includes a CUE _tool that turns the CUE back into YAML on demand. It also includes a schema for the pipeline's representation, but this schema is pretty lightweight and could do with improving. Part of the problem is that I had to manually write the schema, as GitLab's JSONSchema schema currently confuses `cue import`. I opened cue-lang/cue#2654 to track this. Closes cue-labs#19
This change adds a new piece of content which shows how to manage a GitLab repo's CI/CD pipeline file in CUE, instead of YAML. Because GitLab still needs to see a YAML file serialised in the repo, the guide includes a CUE _tool that turns the CUE back into YAML on demand. It also includes a schema for the pipeline's representation, but this schema is pretty lightweight and could do with improving. Part of the problem is that I had to manually write the schema, as GitLab's JSONSchema schema currently confuses `cue import`. I opened cue-lang/cue#2654 to track this. Closes cue-labs#19
This change adds a new piece of content which shows how to manage a GitLab repo's CI/CD pipeline file in CUE, instead of YAML. Because GitLab still needs to see a YAML file serialised in the repo, the guide includes a CUE _tool that turns the CUE back into YAML on demand. It also includes a schema for the pipeline's representation, but this schema is pretty lightweight and could do with improving. Part of the problem is that I had to manually write the schema, as GitLab's JSONSchema schema currently confuses `cue import`. I opened cue-lang/cue#2654 to track this. Closes #19
Ran into the same blocker trying to import the JSON Schema for Renovate configuration. $ curl https://docs.renovatebot.com/renovate-schema.json > renovate-schema.json
$ cue import jsonschema renovate-schema.json --verbose --trace -E
constraint not allowed because type array is excluded:
./renovate-schema.json:648:7
constraint not allowed because type array is excluded:
./renovate-schema.json:2497:7
$ cue version
cue version v0.7.0
go version go1.21.5
-buildmode exe
-compiler gc
-trimpath true
DefaultGODEBUG panicnil=1
CGO_ENABLED 1
GOARCH arm64
GOOS darwin For some context, here are the items at lines 648 and 2497: Line 648 is {
"properties": {
"customDatasources": {
"items": {
"allOf": [
{
"type": "object",
"properties": {
"description": {
"type": "string",
"description": "A custom description for this configuration object"
},
"defaultRegistryUrlTemplate": {
"description": "Template for generating a `defaultRegistryUrl` for custom datasource.",
"type": "string",
"default": ""
},
"format": {
"description": "Format of the custom datasource.",
"type": "string",
"enum": [
"json",
"plain"
],
"default": "json"
},
"transformTemplates": {
"description": "List of jsonata transformation rules.",
"type": "array",
"items": {
"type": "string"
},
"default": []
}
}
}
]
}
}
}
} Line 2497 is {
"properties": {
"postUpgradeTasks": {
"items": {
"allOf": [
{
"type": "object",
"properties": {
"description": {
"type": "string",
"description": "A custom description for this configuration object"
},
"commands": {
"description": "A list of post-upgrade commands that are executed before a commit is made by Renovate.",
"type": "array",
"items": {
"type": "string"
},
"default": []
},
"executionMode": {
"description": "Controls when the post upgrade tasks run: on every update, or once per upgrade branch.",
"type": "string",
"enum": [
"update",
"branch"
],
"default": "update"
},
"fileFilters": {
"description": "Files that match the glob pattern will be committed after running a post-upgrade task.",
"type": "array",
"items": {
"type": "string"
},
"default": [
"**/*"
]
}
}
}
]
}
}
} |
GitLab's CI Schema can't be used: cue-lang/cue#2654 ```text $ cue import --verbose --force --path '#GitLabCi:' --package gitlab jsonschema: ./gitlab-ci.json constraint not allowed because type string is excluded: ./gitlab-ci.json:145:17 constraint not allowed because type string is excluded: ./gitlab-ci.json:951:13 constraint not allowed because type string is excluded: ./gitlab-ci.json:1003:13 schema expects mapping node, found bool: ./gitlab-ci.json:1084:9 schema expects mapping node, found bool: ./gitlab-ci.json:1115:9 schema expects mapping node, found bool: ./gitlab-ci.json:1129:9 constraint not allowed because type string is excluded: ./gitlab-ci.json:1698:15 constraint not allowed because type string is excluded: ./gitlab-ci.json:2287:7 constraint not allowed because type string is excluded: ./gitlab-ci.json:2297:13 exit code: 1 ```
It is due to "customDatasources" and "postUpgradeTasks" being declared as objects, but they are both arrays. In my opinion the errors are correct in this case. |
Closing, as either the fix outlined in #1939 (https://gitlab.com/gitlab-org/gitlab/-/merge_requests/148555), or some preceding change to GitLab's schema, now permits GitLab's tip-of-master JSON Schema (https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json) to be successfully imported by |
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest stable release?
Yes, 0.6.0.
What did you do?
I attempted to import the (current) tip-of-main (JSON)schema for GitLab CI/CD pipelines:
What did you expect to see?
I expected
cue
to succeed, emitting a CUE version of the schema.What did you see instead?
Using https://www.jsonschemavalidator.net/, I was able to successfully validate the GitLab file against the appropriate JSONSchema meta-schema, suggesting that
cue
's objections aren't fundamental to the file's contents.An earlier version of the same GitLab schema was flagged in an seemingly unrelated issue, here: #1487
The text was updated successfully, but these errors were encountered: