mirror of
https://github.com/foomo/squadron.git
synced 2025-10-16 12:35:42 +00:00
docs: update comments
This commit is contained in:
parent
8aeecad33f
commit
f9718e7220
@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
type Build struct {
|
||||
// Build context
|
||||
Context string `json:"context,omitempty" yaml:"context,omitempty"`
|
||||
// AddHost add a custom host-to-IP mapping (format: "host:ip")
|
||||
AddHost []string `json:"add_host,omitempty" yaml:"add_host,omitempty"`
|
||||
@ -58,7 +59,8 @@ type Build struct {
|
||||
// SSH agent socket or keys to expose to the build (format: "default|<id>[=<socket>|<key>[,<key>]]")
|
||||
SSH string `json:"ssh,omitempty" yaml:"ssh,omitempty"`
|
||||
// Tag name and optionally a tag (format: "name:tag")
|
||||
Tag string `json:"tag,omitempty" yaml:"tag,omitempty"`
|
||||
Tag string `json:"tag,omitempty" yaml:"tag,omitempty"`
|
||||
// Image name
|
||||
Image string `json:"image,omitempty" yaml:"image,omitempty"`
|
||||
// Target set the target build stage to build
|
||||
Target string `json:"target,omitempty" yaml:"target,omitempty"`
|
||||
|
||||
@ -13,11 +13,16 @@ import (
|
||||
)
|
||||
|
||||
type Chart struct {
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
// Chart name
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
// Chart repository
|
||||
Repository string `json:"repository,omitempty" yaml:"repository,omitempty"`
|
||||
Schema string `json:"schema,omitempty" yaml:"schema,omitempty"`
|
||||
Version string `json:"version,omitempty" yaml:"version,omitempty"`
|
||||
Alias string `json:"alias,omitempty" yaml:"alias,omitempty"`
|
||||
// Values schema json
|
||||
Schema string `json:"schema,omitempty" yaml:"schema,omitempty"`
|
||||
// Chart version
|
||||
Version string `json:"version,omitempty" yaml:"version,omitempty"`
|
||||
// Chart alias
|
||||
Alias string `json:"alias,omitempty" yaml:"alias,omitempty"`
|
||||
}
|
||||
|
||||
func (d *Chart) UnmarshalYAML(value *yaml.Node) error {
|
||||
|
||||
@ -14,11 +14,16 @@ import (
|
||||
)
|
||||
|
||||
type Unit struct {
|
||||
Chart Chart `json:"chart,omitempty" yaml:"chart,omitempty" jsonschema:"anyof_type=string,anyof_ref=#/$defs/Chart"`
|
||||
Kustomize string `json:"kustomize,omitempty" yaml:"kustomize,omitempty"`
|
||||
Tags Tags `json:"tags,omitempty" yaml:"tags,omitempty"`
|
||||
Builds map[string]Build `json:"builds,omitempty" yaml:"builds,omitempty"`
|
||||
Values map[string]any `json:"values,omitempty" yaml:"values,omitempty"`
|
||||
// Chart settings
|
||||
Chart Chart `json:"chart,omitempty" yaml:"chart,omitempty" jsonschema:"anyof_type=string,anyof_ref=#/$defs/Chart"`
|
||||
// Kustomize files path
|
||||
Kustomize string `json:"kustomize,omitempty" yaml:"kustomize,omitempty"`
|
||||
// List of tags
|
||||
Tags Tags `json:"tags,omitempty" yaml:"tags,omitempty"`
|
||||
// Map of containers to build
|
||||
Builds map[string]Build `json:"builds,omitempty" yaml:"builds,omitempty"`
|
||||
// Chart values
|
||||
Values map[string]any `json:"values,omitempty" yaml:"values,omitempty"`
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -18,7 +18,7 @@ func New() *JSONSchema {
|
||||
}
|
||||
|
||||
func (js *JSONSchema) LoadBaseSchema(ctx context.Context, url string) error {
|
||||
baseSchema, err := Fetch(ctx, url)
|
||||
baseSchema, err := LoadMap(ctx, url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -48,7 +48,7 @@ func (js *JSONSchema) SetSquadronUnitSchema(ctx context.Context, squardon, unit,
|
||||
|
||||
// add definition
|
||||
if _, ok := defsMap[ref]; !ok {
|
||||
valuesMap, err := Fetch(ctx, url)
|
||||
valuesMap, err := LoadMap(ctx, url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Fetch fetches the JSON schema from a given URL
|
||||
func Fetch(ctx context.Context, url string) (map[string]any, error) {
|
||||
// LoadMap fetches the JSON schema from a given URL
|
||||
func LoadMap(ctx context.Context, url string) (map[string]any, error) {
|
||||
var err error
|
||||
var body []byte
|
||||
|
||||
@ -9,8 +9,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_fetchJSONSchema(t *testing.T) {
|
||||
actual, err := jsonschema.Fetch(context.TODO(), "https://raw.githubusercontent.com/foomo/squadron/refs/heads/main/squadron.schema.json")
|
||||
func TestLoadMap(t *testing.T) {
|
||||
actual, err := jsonschema.LoadMap(context.TODO(), "https://raw.githubusercontent.com/foomo/squadron/refs/heads/main/squadron.schema.json")
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, actual)
|
||||
assert.Equal(t, "https://github.com/foomo/squadron/internal/config/config", actual["$id"])
|
||||
@ -6,7 +6,8 @@
|
||||
"Build": {
|
||||
"properties": {
|
||||
"context": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"description": "Build context"
|
||||
},
|
||||
"add_host": {
|
||||
"items": {
|
||||
@ -125,7 +126,8 @@
|
||||
"description": "Tag name and optionally a tag (format: \"name:tag\")"
|
||||
},
|
||||
"image": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"description": "Image name"
|
||||
},
|
||||
"target": {
|
||||
"type": "string",
|
||||
@ -149,19 +151,24 @@
|
||||
"Chart": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"description": "Chart name"
|
||||
},
|
||||
"repository": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"description": "Chart repository"
|
||||
},
|
||||
"schema": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"description": "Values schema json"
|
||||
},
|
||||
"version": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"description": "Chart version"
|
||||
},
|
||||
"alias": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"description": "Chart alias"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
@ -222,22 +229,27 @@
|
||||
{
|
||||
"$ref": "#/$defs/Chart"
|
||||
}
|
||||
]
|
||||
],
|
||||
"description": "Chart settings"
|
||||
},
|
||||
"kustomize": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"description": "Kustomize files path"
|
||||
},
|
||||
"tags": {
|
||||
"$ref": "#/$defs/Tags"
|
||||
"$ref": "#/$defs/Tags",
|
||||
"description": "List of tags"
|
||||
},
|
||||
"builds": {
|
||||
"additionalProperties": {
|
||||
"$ref": "#/$defs/Build"
|
||||
},
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"description": "Map of containers to build"
|
||||
},
|
||||
"values": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"description": "Chart values"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user