-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6557a7
commit 5ecf9a6
Showing
8 changed files
with
132 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"yaml.schemas": { | ||
"./schema.json": ".runny.yaml" | ||
"./schema/runny.schema.json": ".runny.yaml" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
//go:generate go run . ./runny.schema.json | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/invopop/jsonschema" | ||
"github.com/simonwhitaker/runny/runny" | ||
) | ||
|
||
func main() { | ||
schema := jsonschema.Reflect(&runny.Config{}) | ||
bytes, err := schema.MarshalJSON() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// jsonschema doesn't support indenting, so we need to unmarshal/marshal with the json package | ||
var tempJsonObj map[string]interface{} | ||
err = json.Unmarshal(bytes, &tempJsonObj) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
indentedSchema, err := json.MarshalIndent(tempJsonObj, "", " ") | ||
schemaString := string(indentedSchema[:]) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
if len(os.Args) > 1 { | ||
filename := os.Args[1] | ||
f, err := os.Create(filename) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer f.Close() | ||
f.WriteString(schemaString) | ||
} else { | ||
fmt.Println(schemaString) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"$defs": { | ||
"CommandDef": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"env": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"if": { | ||
"type": "string" | ||
}, | ||
"needs": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"run": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object" | ||
}, | ||
"Config": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"commands": { | ||
"additionalProperties": { | ||
"$ref": "#/$defs/CommandDef" | ||
}, | ||
"type": "object" | ||
}, | ||
"env": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
}, | ||
"shell": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"commands" | ||
], | ||
"type": "object" | ||
} | ||
}, | ||
"$id": "https://github.com/simonwhitaker/runny/runny/config", | ||
"$ref": "#/$defs/Config", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema" | ||
} |