Skip to content

Commit

Permalink
kapp app-group deploy should order based on folder names carvel-dev#755
Browse files Browse the repository at this point in the history
  • Loading branch information
Hergy Fongue committed Oct 8, 2023
1 parent 5dc9ceb commit 7af7941
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/kapp/cmd/appgroup/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ func (o *DeployOptions) Run() error {

// TODO what if app is renamed? currently it
// will have conflicting resources with new-named app
updatedApps, err := o.appsToUpdate()
updatedApps, sortedApps, err := o.appsToUpdate()
if err != nil {
return err
}

var exitCode float64
// TODO is there some order between apps?
for _, appGroupApp := range updatedApps {
for _, appGroupApp := range sortedApps {
err := o.deployApp(appGroupApp)
if err != nil {
if deployErr, ok := err.(cmdapp.DeployDiffExitStatus); ok {
Expand Down Expand Up @@ -117,13 +117,15 @@ type appGroupApp struct {
Path string
}

func (o *DeployOptions) appsToUpdate() (map[string]appGroupApp, error) {
func (o *DeployOptions) appsToUpdate() (map[string]appGroupApp, []appGroupApp, error) {
result := map[string]appGroupApp{}
var applications []appGroupApp

dir := o.DeployFlags.Directory

fileInfos, err := os.ReadDir(dir)
if err != nil {
return nil, fmt.Errorf("Reading directory '%s': %w", dir, err)
return nil, nil, fmt.Errorf("Reading directory '%s': %w", dir, err)
}

for _, fi := range fileInfos {
Expand All @@ -134,10 +136,11 @@ func (o *DeployOptions) appsToUpdate() (map[string]appGroupApp, error) {
Name: fmt.Sprintf("%s-%s", o.AppGroupFlags.Name, fi.Name()),
Path: filepath.Join(dir, fi.Name()),
}
applications = append(applications, app)
result[app.Name] = app
}

return result, nil
return result, applications, nil
}

func (o *DeployOptions) deployApp(app appGroupApp) error {
Expand Down

0 comments on commit 7af7941

Please sign in to comment.