Skip to content

Commit f3a2b0b

Browse files
committed
feat(exp-engine): "werf plan" command, "werf converge" improvements
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
1 parent ba71df4 commit f3a2b0b

File tree

8 files changed

+838
-32
lines changed

8 files changed

+838
-32
lines changed

cmd/werf/converge/converge.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@ import (
99
"regexp"
1010
"time"
1111

12+
"github.com/gookit/color"
1213
"github.com/samber/lo"
1314
"github.com/spf13/cobra"
1415
helm_v3 "helm.sh/helm/v3/cmd/helm"
1516
"helm.sh/helm/v3/pkg/action"
1617
"helm.sh/helm/v3/pkg/chart"
1718
"helm.sh/helm/v3/pkg/chart/loader"
18-
"helm.sh/helm/v3/pkg/chartutil"
1919
"helm.sh/helm/v3/pkg/cli/values"
20-
kubefake "helm.sh/helm/v3/pkg/kube/fake"
2120
"helm.sh/helm/v3/pkg/postrender"
2221
"helm.sh/helm/v3/pkg/registry"
23-
"helm.sh/helm/v3/pkg/storage"
24-
"helm.sh/helm/v3/pkg/storage/driver"
2522
"helm.sh/helm/v3/pkg/werf/chrttree"
2623
helmcommon "helm.sh/helm/v3/pkg/werf/common"
2724
"helm.sh/helm/v3/pkg/werf/kubeclnt"
@@ -566,16 +563,17 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
566563
chartPathOptions := action.ChartPathOptions{}
567564
chartPathOptions.SetRegistryClient(actionConfig.RegistryClient)
568565

569-
// FIXME(ilya-lesikov): allow local mode
570-
// TODO(ilya-lesikov): allow specifying kube version and additional capabilities manually
571566
actionConfig.Releases.MaxHistory = *commonCmdData.ReleasesHistoryMax
572-
if false {
573-
actionConfig.Capabilities = chartutil.DefaultCapabilities.Copy()
574-
actionConfig.KubeClient = &kubefake.PrintingKubeClient{Out: ioutil.Discard}
575-
mem := driver.NewMemory()
576-
mem.SetNamespace(releaseNamespace.Name())
577-
actionConfig.Releases = storage.Init(mem)
578-
}
567+
568+
// FIXME(ilya-lesikov): for local commands (lint, ...)
569+
// if false {
570+
// // allow specifying kube version and additional capabilities manually
571+
// actionConfig.Capabilities = chartutil.DefaultCapabilities.Copy()
572+
// actionConfig.KubeClient = &kubefake.PrintingKubeClient{Out: ioutil.Discard}
573+
// mem := driver.NewMemory()
574+
// mem.SetNamespace(releaseNamespace.Name())
575+
// actionConfig.Releases = storage.Init(mem)
576+
// }
579577

580578
tracker := resrctracker.NewResourceTracker(clientFactory.Static(), clientFactory.Dynamic(), clientFactory.Discovery(), clientFactory.Mapper())
581579

@@ -727,7 +725,7 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
727725
if useless, err := plan.Useless(); err != nil {
728726
return fmt.Errorf("error checking if deploy plan will do nothing useful: %w", err)
729727
} else if useless {
730-
log.Default.Info(ctx, "Skipped release %q in namespace %q: cluster resources already as desired.", releaseName, releaseNamespace.Name())
728+
log.Default.Info(ctx, color.Style{color.Bold, color.Green}.Render("Skipped release")+" %q (namespace: %q): cluster resources already as desired", releaseName, releaseNamespace.Name())
731729
return nil
732730
}
733731

@@ -855,7 +853,7 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
855853
} else if len(finalErrs) > 0 {
856854
return utls.Multierrorf("succeeded release %q (namespace: %q), but errors encountered", finalErrs, releaseName, releaseNamespace.Name())
857855
} else {
858-
log.Default.Info(ctx, "Succeeded release %q (namespace: %q)", releaseName, releaseNamespace.Name())
856+
log.Default.Info(ctx, color.Style{color.Bold, color.Green}.Render("Succeeded release")+" %q (namespace: %q)", releaseName, releaseNamespace.Name())
859857
return nil
860858
}
861859
})

cmd/werf/main.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ import (
4343
managed_images_add "github.com/werf/werf/cmd/werf/managed_images/add"
4444
managed_images_ls "github.com/werf/werf/cmd/werf/managed_images/ls"
4545
managed_images_rm "github.com/werf/werf/cmd/werf/managed_images/rm"
46+
"github.com/werf/werf/cmd/werf/plan"
4647
"github.com/werf/werf/cmd/werf/purge"
4748
"github.com/werf/werf/cmd/werf/render"
4849
"github.com/werf/werf/cmd/werf/run"
4950
"github.com/werf/werf/cmd/werf/slugify"
5051
stage_image "github.com/werf/werf/cmd/werf/stage/image"
5152
"github.com/werf/werf/cmd/werf/synchronization"
5253
"github.com/werf/werf/cmd/werf/version"
54+
dhelm "github.com/werf/werf/pkg/deploy/helm"
5355
"github.com/werf/werf/pkg/process_exterminator"
5456
"github.com/werf/werf/pkg/telemetry"
5557
)
@@ -114,15 +116,27 @@ Find more information at https://werf.io`),
114116
SilenceErrors: true,
115117
})
116118

119+
var deliveryCmds []*cobra.Command
120+
if dhelm.IsExperimentalEngine() {
121+
deliveryCmds = []*cobra.Command{
122+
converge.NewCmd(ctx),
123+
plan.NewCmd(ctx),
124+
dismiss.NewCmd(ctx),
125+
bundleCmd(ctx),
126+
}
127+
} else {
128+
deliveryCmds = []*cobra.Command{
129+
converge.NewCmd(ctx),
130+
dismiss.NewCmd(ctx),
131+
bundleCmd(ctx),
132+
}
133+
}
134+
117135
groups := &templates.CommandGroups{}
118136
*groups = append(*groups, templates.CommandGroups{
119137
{
120-
Message: "Delivery commands",
121-
Commands: []*cobra.Command{
122-
converge.NewCmd(ctx),
123-
dismiss.NewCmd(ctx),
124-
bundleCmd(ctx),
125-
},
138+
Message: "Delivery commands",
139+
Commands: deliveryCmds,
126140
},
127141
{
128142
Message: "Cleaning commands",

0 commit comments

Comments
 (0)