Skip to content

Commit

Permalink
Merge pull request #35 from kanmu/fix_cluster_opt
Browse files Browse the repository at this point in the history
Fix cluster option bug
  • Loading branch information
winebarrel committed May 27, 2023
2 parents 33144e5 + 62dc33d commit 64b7723
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions definition/definition.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package definition

import (
"encoding/json"
"fmt"
"path/filepath"

Expand Down Expand Up @@ -42,6 +43,7 @@ func (opts *DefinitionOpts) Load(profile string, command string, image string, c
if profile != "" {
confDir = filepath.Join(confDir, profile)
}

ecspressoConf, err := loadEcsecspressoConf(confDir, opts)

if err != nil {
Expand Down Expand Up @@ -88,16 +90,10 @@ func (opts *DefinitionOpts) Load(profile string, command string, image string, c
return nil, err
}

var cluster string

if opts.Cluster != "" {
cluster = opts.Cluster
} else {
cluster, err = ecspressoConf.get("cluster")
cluster, err := ecspressoConf.get("cluster")

if err != nil {
return nil, err
}
if err != nil {
return nil, err
}

return &Definition{
Expand All @@ -115,6 +111,22 @@ func loadEcsecspressoConf(confDir string, opts *DefinitionOpts) (*EcspressoConfi
return nil, err
}

if opts.Cluster != "" {
js, err := json.Marshal(map[string]string{
"cluster": opts.Cluster,
})

if err != nil {
panic(err)
}

err = ecspressoConf.patch(string(js))

if err != nil {
return nil, err
}
}

err = ecspressoConf.patch(opts.ConfigOverrides)

if err != nil {
Expand Down

0 comments on commit 64b7723

Please sign in to comment.