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