mirror of
https://github.com/foomo/squadron.git
synced 2025-10-16 12:35:42 +00:00
feat: allow overriding release name
This commit is contained in:
parent
5866731e84
commit
f18a6240e7
@ -17,20 +17,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Unit struct {
|
type Unit struct {
|
||||||
|
// Optional release name
|
||||||
|
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||||
// Chart settings
|
// Chart settings
|
||||||
Chart Chart `json:"chart,omitempty" yaml:"chart,omitempty" jsonschema:"anyof_type=string,anyof_ref=#/$defs/Chart"`
|
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
|
// List of tags
|
||||||
Tags Tags `json:"tags,omitempty" yaml:"tags,omitempty"`
|
Tags Tags `json:"tags,omitempty" yaml:"tags,omitempty"`
|
||||||
// Installation priority, higher comes first
|
// Installation priority, higher comes first
|
||||||
Priority int `json:"priority,omitempty" yaml:"priority,omitempty"`
|
Priority int `json:"priority,omitempty" yaml:"priority,omitempty"`
|
||||||
|
// Extend chart values
|
||||||
|
Extends string `json:"extends,omitempty" yaml:"extends,omitempty"`
|
||||||
|
// Kustomize files path
|
||||||
|
Kustomize string `json:"kustomize,omitempty" yaml:"kustomize,omitempty"`
|
||||||
// Map of containers to build
|
// Map of containers to build
|
||||||
Builds map[string]Build `json:"builds,omitempty" yaml:"builds,omitempty"`
|
Builds map[string]Build `json:"builds,omitempty" yaml:"builds,omitempty"`
|
||||||
// Chart values
|
// Chart values
|
||||||
Values map[string]any `json:"values,omitempty" yaml:"values,omitempty"`
|
Values map[string]any `json:"values,omitempty" yaml:"values,omitempty"`
|
||||||
// Extend chart values
|
|
||||||
Extends string `json:"extends,omitempty" yaml:"extends,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
19
squadron.go
19
squadron.go
@ -32,6 +32,7 @@ const (
|
|||||||
|
|
||||||
type Squadron struct {
|
type Squadron struct {
|
||||||
basePath string
|
basePath string
|
||||||
|
nameFn func() string
|
||||||
namespace string
|
namespace string
|
||||||
files []string
|
files []string
|
||||||
config string
|
config string
|
||||||
@ -389,7 +390,7 @@ func (sq *Squadron) Down(ctx context.Context, helmArgs []string, parallel int) e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
name := fmt.Sprintf("%s-%s", key, k)
|
name := sq.getReleaseName(key, k, v)
|
||||||
namespace, err := sq.Namespace(ctx, key, k)
|
namespace, err := sq.Namespace(ctx, key, k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -471,7 +472,7 @@ func (sq *Squadron) Diff(ctx context.Context, helmArgs []string, parallel int) (
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
name := fmt.Sprintf("%s-%s", key, k)
|
name := sq.getReleaseName(key, k, v)
|
||||||
namespace, err := sq.Namespace(ctx, key, k)
|
namespace, err := sq.Namespace(ctx, key, k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -590,7 +591,7 @@ func (sq *Squadron) Status(ctx context.Context, helmArgs []string, parallel int)
|
|||||||
_ = sq.Config().Squadrons.Iterate(ctx, func(ctx context.Context, key string, value config.Map[*config.Unit]) error {
|
_ = sq.Config().Squadrons.Iterate(ctx, func(ctx context.Context, key string, value config.Map[*config.Unit]) error {
|
||||||
return value.Iterate(ctx, func(ctx context.Context, k string, v *config.Unit) error {
|
return value.Iterate(ctx, func(ctx context.Context, k string, v *config.Unit) error {
|
||||||
var status statusType
|
var status statusType
|
||||||
name := fmt.Sprintf("%s-%s", key, k)
|
name := sq.getReleaseName(key, k, v)
|
||||||
namespace, err := sq.Namespace(ctx, key, k)
|
namespace, err := sq.Namespace(ctx, key, k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("failed to retrieve namsspace: %s/%s", key, k)
|
return errors.Errorf("failed to retrieve namsspace: %s/%s", key, k)
|
||||||
@ -701,7 +702,7 @@ func (sq *Squadron) Rollback(ctx context.Context, revision string, helmArgs []st
|
|||||||
|
|
||||||
_ = sq.Config().Squadrons.Iterate(ctx, func(ctx context.Context, key string, value config.Map[*config.Unit]) error {
|
_ = sq.Config().Squadrons.Iterate(ctx, func(ctx context.Context, key string, value config.Map[*config.Unit]) error {
|
||||||
return value.Iterate(ctx, func(ctx context.Context, k string, v *config.Unit) error {
|
return value.Iterate(ctx, func(ctx context.Context, k string, v *config.Unit) error {
|
||||||
name := fmt.Sprintf("%s-%s", key, k)
|
name := sq.getReleaseName(key, k, v)
|
||||||
namespace, err := sq.Namespace(ctx, key, k)
|
namespace, err := sq.Namespace(ctx, key, k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -854,7 +855,6 @@ func (sq *Squadron) Up(ctx context.Context, helmArgs []string, username, version
|
|||||||
// install chart
|
// install chart
|
||||||
cmd := util.NewHelmCommand().
|
cmd := util.NewHelmCommand().
|
||||||
Stdin(bytes.NewReader(valueBytes)).
|
Stdin(bytes.NewReader(valueBytes)).
|
||||||
// Stdout(os.Stdout).
|
|
||||||
Args("upgrade", name, "--install").
|
Args("upgrade", name, "--install").
|
||||||
Args("--set", "global.foomo.squadron.name="+a.squadron).
|
Args("--set", "global.foomo.squadron.name="+a.squadron).
|
||||||
Args("--set", "global.foomo.squadron.unit="+a.unit).
|
Args("--set", "global.foomo.squadron.unit="+a.unit).
|
||||||
@ -924,7 +924,7 @@ func (sq *Squadron) Template(ctx context.Context, helmArgs []string, parallel in
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
name := fmt.Sprintf("%s-%s", key, k)
|
name := sq.getReleaseName(key, k, v)
|
||||||
namespace, err := sq.Namespace(ctx, key, k)
|
namespace, err := sq.Namespace(ctx, key, k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
spinner.Fail(err.Error())
|
spinner.Fail(err.Error())
|
||||||
@ -956,3 +956,10 @@ func (sq *Squadron) Template(ctx context.Context, helmArgs []string, parallel in
|
|||||||
|
|
||||||
return ret.String(), nil
|
return ret.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sq *Squadron) getReleaseName(squadron, unit string, u *config.Unit) string {
|
||||||
|
if u.Name != "" {
|
||||||
|
return u.Name
|
||||||
|
}
|
||||||
|
return squadron + "-" + unit
|
||||||
|
}
|
||||||
|
|||||||
@ -233,6 +233,10 @@
|
|||||||
},
|
},
|
||||||
"Unit": {
|
"Unit": {
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Optional release name"
|
||||||
|
},
|
||||||
"chart": {
|
"chart": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
@ -244,10 +248,6 @@
|
|||||||
],
|
],
|
||||||
"description": "Chart settings"
|
"description": "Chart settings"
|
||||||
},
|
},
|
||||||
"kustomize": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Kustomize files path"
|
|
||||||
},
|
|
||||||
"tags": {
|
"tags": {
|
||||||
"$ref": "#/$defs/Tags",
|
"$ref": "#/$defs/Tags",
|
||||||
"description": "List of tags"
|
"description": "List of tags"
|
||||||
@ -256,6 +256,14 @@
|
|||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "Installation priority, higher comes first"
|
"description": "Installation priority, higher comes first"
|
||||||
},
|
},
|
||||||
|
"extends": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Extend chart values"
|
||||||
|
},
|
||||||
|
"kustomize": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Kustomize files path"
|
||||||
|
},
|
||||||
"builds": {
|
"builds": {
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"$ref": "#/$defs/Build"
|
"$ref": "#/$defs/Build"
|
||||||
@ -266,10 +274,6 @@
|
|||||||
"values": {
|
"values": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "Chart values"
|
"description": "Chart values"
|
||||||
},
|
|
||||||
"extends": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Extend chart values"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user