Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kapp app-group deploy should order based on folder names #755 #829

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
rjtch marked this conversation as resolved.
Show resolved Hide resolved
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