1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

fix: jsonschema

very hacky, fixes #3238 for good

refs https://github.com/invopop/jsonschema/issues/26

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos A Becker 2022-08-17 23:50:14 -03:00
parent aa12ad014e
commit ce264f1fca
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
3 changed files with 29 additions and 4 deletions

View File

@ -27,6 +27,7 @@ func newSchemaCmd() *schemaCmd {
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
schema := jsonschema.Reflect(&config.Project{})
schema.Definitions["FileInfo"] = jsonschema.Reflect(&config.FileInfo{})
schema.Description = "goreleaser configuration definition file"
bts, err := json.MarshalIndent(schema, " ", " ")
if err != nil {

View File

@ -427,18 +427,16 @@ type FileInfo struct {
MTime time.Time `yaml:"mtime,omitempty" json:"mtime,omitempty"`
}
// type alias to prevent stack overflow
type fileAlias File
// UnmarshalYAML is a custom unmarshaler that wraps strings in arrays.
func (f *File) UnmarshalYAML(unmarshal func(interface{}) error) error {
type t File
var str string
if err := unmarshal(&str); err == nil {
*f = File{Source: str}
return nil
}
var file fileAlias
var file t
if err := unmarshal(&file); err != nil {
return err
}

26
www/docs/static/schema.json generated vendored
View File

@ -731,6 +731,32 @@
}
]
},
"FileInfo": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/goreleaser/goreleaser/pkg/config/file-info",
"$ref": "#/$defs/FileInfo",
"$defs": {
"FileInfo": {
"properties": {
"owner": {
"type": "string"
},
"group": {
"type": "string"
},
"mode": {
"type": "integer"
},
"mtime": {
"type": "string",
"format": "date-time"
}
},
"additionalProperties": false,
"type": "object"
}
}
},
"Filters": {
"properties": {
"exclude": {