Skip to content

Commit

Permalink
Merge pull request #2424 from pratikjagrut/sequential.dep.flag
Browse files Browse the repository at this point in the history
feat: add global flag for running dep sequentially
  • Loading branch information
FabianKramm authored Nov 16, 2022
2 parents c5aa51b + 4ecd80b commit 659fc12
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
16 changes: 10 additions & 6 deletions cmd/run_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package cmd
import (
"context"
"fmt"
"io"
"os"

"github.com/loft-sh/devspace/cmd/flags"
"github.com/loft-sh/devspace/pkg/devspace/build"
"github.com/loft-sh/devspace/pkg/devspace/config/loader"
Expand Down Expand Up @@ -30,8 +33,6 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
"io"
"os"
)

// RunPipelineCmd holds the command flags
Expand All @@ -44,8 +45,9 @@ type RunPipelineCmd struct {
SkipPush bool
SkipPushLocalKubernetes bool

Dependency []string
SkipDependency []string
Dependency []string
SkipDependency []string
SequentialDependencies bool

ForceBuild bool
SkipBuild bool
Expand All @@ -68,6 +70,7 @@ type RunPipelineCmd struct {
func (cmd *RunPipelineCmd) AddPipelineFlags(f factory.Factory, command *cobra.Command, pipeline *latest.Pipeline) {
command.Flags().StringSliceVar(&cmd.SkipDependency, "skip-dependency", cmd.SkipDependency, "Skips the following dependencies for deployment")
command.Flags().StringSliceVar(&cmd.Dependency, "dependency", cmd.Dependency, "Deploys only the specified named dependencies")
command.Flags().BoolVar(&cmd.SequentialDependencies, "sequential-dependencies", false, "If set set true dependencies will run sequentially")

command.Flags().BoolVarP(&cmd.ForceBuild, "force-build", "b", cmd.ForceBuild, "Forces to build every image")
command.Flags().BoolVar(&cmd.SkipBuild, "skip-build", cmd.SkipBuild, "Skips building of images")
Expand Down Expand Up @@ -413,8 +416,9 @@ func (cmd *RunPipelineCmd) BuildOptions(configOptions *loader.ConfigOptions) *Co
ForcePurge: cmd.ForcePurge,
},
DependencyOptions: types.DependencyOptions{
Exclude: cmd.SkipDependency,
Only: cmd.Dependency,
Exclude: cmd.SkipDependency,
Only: cmd.Dependency,
Sequential: cmd.SequentialDependencies,
},
},
ConfigOptions: configOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package commands

import (
"fmt"
"strings"

"github.com/jessevdk/go-flags"
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
types2 "github.com/loft-sh/devspace/pkg/devspace/dependency/types"
"github.com/loft-sh/devspace/pkg/devspace/hook"
"github.com/loft-sh/devspace/pkg/devspace/pipeline/types"
"github.com/loft-sh/devspace/pkg/util/stringutil"
"github.com/pkg/errors"
"strings"
)

// RunDependencyPipelinesOptions describe how dependencies should get deployed
Expand Down
3 changes: 3 additions & 0 deletions pkg/devspace/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,13 @@ func (p *pipeline) StartNewDependencies(ctx devspacecontext.Context, dependencie

// Start sequentially
if options.Sequential {
ctx.Log().Debug("Deploying dependencies sequentially")
for _, dependency := range deployDependencies {
err := p.startNewDependency(ctx, dependency, options)
if err != nil {
return errors.Wrapf(err, "run dependency %s", dependency.Name())
} else {
ctx.Log().Debugf("Dependency '%s' deployed", dependency.Name())
}
}

Expand Down

0 comments on commit 659fc12

Please sign in to comment.