Skip to content

Commit 73e6bcc

Browse files
committed
feat(external-deps): external dependencies for release resources
Added a way to express external dependencies for the new release resource, so that we will wait until the external dependency resource is ready and only after that we will try to deploy the new release resource. Example usage: ```yaml metadata: annotations: app1.external-dependency.werf.io/resource: "deployment/app1" app1.external-dependency.werf.io/namespace: "default" # optional ``` Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
1 parent a64d682 commit 73e6bcc

File tree

17 files changed

+384
-39
lines changed

17 files changed

+384
-39
lines changed

cmd/werf/bundle/apply/apply.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,15 @@ func runApply() error {
214214
ChartExtender: bundle,
215215
}
216216

217+
stagesExternalDepsGenerator, err := helm.NewStagesExternalDepsGenerator(actionConfig.RESTClientGetter)
218+
if err != nil {
219+
return fmt.Errorf("error creating external deps generator: %w", err)
220+
}
221+
217222
helmUpgradeCmd, _ := helm_v3.NewUpgradeCmd(actionConfig, logboek.Context(ctx).OutStream(), helm_v3.UpgradeCmdOptions{
218-
StagesSplitter: helm.StagesSplitter{},
219-
ChainPostRenderer: bundle.ChainPostRenderer,
223+
StagesSplitter: helm.NewStagesSplitter(),
224+
StagesExternalDepsGenerator: stagesExternalDepsGenerator,
225+
ChainPostRenderer: bundle.ChainPostRenderer,
220226
ValueOpts: &values.Options{
221227
ValueFiles: common.GetValues(&commonCmdData),
222228
StringValues: common.GetSetString(&commonCmdData),

cmd/werf/bundle/render/render.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func runRender(ctx context.Context) error {
221221
}
222222

223223
helmTemplateCmd, _ := helm_v3.NewTemplateCmd(actionConfig, output, helm_v3.TemplateCmdOptions{
224-
StagesSplitter: helm.StagesSplitter{},
224+
StagesSplitter: helm.NewStagesSplitter(),
225225
ChainPostRenderer: bundle.ChainPostRenderer,
226226
ValueOpts: &values.Options{
227227
ValueFiles: common.GetValues(&commonCmdData),

cmd/werf/converge/converge.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,15 +444,21 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
444444
return err
445445
}
446446

447+
stagesExternalDepsGenerator, err := helm.NewStagesExternalDepsGenerator(actionConfig.RESTClientGetter)
448+
if err != nil {
449+
return fmt.Errorf("error creating external deps generator: %w", err)
450+
}
451+
447452
helmUpgradeCmd, _ := helm_v3.NewUpgradeCmd(actionConfig, logboek.OutStream(), helm_v3.UpgradeCmdOptions{
448-
StagesSplitter: helm.StagesSplitter{},
449-
ChainPostRenderer: wc.ChainPostRenderer,
450-
ValueOpts: valueOpts,
451-
CreateNamespace: common.NewBool(true),
452-
Install: common.NewBool(true),
453-
Wait: common.NewBool(true),
454-
Atomic: common.NewBool(cmdData.AutoRollback),
455-
Timeout: common.NewDuration(time.Duration(cmdData.Timeout) * time.Second),
453+
StagesSplitter: helm.NewStagesSplitter(),
454+
StagesExternalDepsGenerator: stagesExternalDepsGenerator,
455+
ChainPostRenderer: wc.ChainPostRenderer,
456+
ValueOpts: valueOpts,
457+
CreateNamespace: common.NewBool(true),
458+
Install: common.NewBool(true),
459+
Wait: common.NewBool(true),
460+
Atomic: common.NewBool(cmdData.AutoRollback),
461+
Timeout: common.NewDuration(time.Duration(cmdData.Timeout) * time.Second),
456462
})
457463

458464
return command_helpers.LockReleaseWrapper(ctx, releaseName, lockManager, func() error {
@@ -525,7 +531,7 @@ func migrateHelm2ToHelm3(ctx context.Context, releaseName, namespace string, mai
525531
}
526532

527533
helmTemplateCmd, _ := helm_v3.NewTemplateCmd(actionConfig, ioutil.Discard, helm_v3.TemplateCmdOptions{
528-
StagesSplitter: helm.StagesSplitter{},
534+
StagesSplitter: helm.NewStagesSplitter(),
529535
ChainPostRenderer: chainPostRenderer,
530536
ValueOpts: valueOpts,
531537
Validate: common.NewBool(true),

cmd/werf/dismiss/dismiss.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func runDismiss(ctx context.Context) error {
232232

233233
dontFailIfNoRelease := true
234234
helmUninstallCmd := helm_v3.NewUninstallCmd(actionConfig, logboek.Context(ctx).OutStream(), helm_v3.UninstallCmdOptions{
235-
StagesSplitter: helm.StagesSplitter{},
235+
StagesSplitter: helm.NewStagesSplitter(),
236236
DeleteNamespace: &cmdData.WithNamespace,
237237
DeleteHooks: &cmdData.WithHooks,
238238
DontFailIfNoRelease: &dontFailIfNoRelease,

cmd/werf/helm/helm.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func NewCmd() *cobra.Command {
7070

7171
cmd.AddCommand(
7272
helm_v3.NewUninstallCmd(actionConfig, os.Stdout, helm_v3.UninstallCmdOptions{
73-
StagesSplitter: helm.StagesSplitter{},
73+
StagesSplitter: helm.NewStagesSplitter(),
7474
}),
7575
helm_v3.NewDependencyCmd(actionConfig, os.Stdout),
7676
helm_v3.NewGetCmd(actionConfig, os.Stdout),
@@ -80,7 +80,9 @@ func NewCmd() *cobra.Command {
8080
NewTemplateCmd(actionConfig, wc),
8181
helm_v3.NewRepoCmd(os.Stdout),
8282
helm_v3.NewRollbackCmd(actionConfig, os.Stdout, helm_v3.RollbackCmdOptions{
83-
StagesSplitter: helm.StagesSplitter{},
83+
StagesSplitter: helm.NewStagesSplitter(),
84+
// TODO: actionConfig.RESTClientGetter not initialized at this point, but we need it.
85+
StagesExternalDepsGenerator: nil,
8486
}),
8587
NewInstallCmd(actionConfig, wc),
8688
NewUpgradeCmd(actionConfig, wc),

cmd/werf/helm/install.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ var installCmdData common.CmdData
1919

2020
func NewInstallCmd(actionConfig *action.Configuration, wc *chart_extender.WerfChartStub) *cobra.Command {
2121
cmd, helmAction := helm_v3.NewInstallCmd(actionConfig, os.Stdout, helm_v3.InstallCmdOptions{
22-
StagesSplitter: helm.StagesSplitter{},
23-
ChainPostRenderer: wc.ChainPostRenderer,
22+
StagesSplitter: helm.NewStagesSplitter(),
23+
// TODO: actionConfig.RESTClientGetter not initialized at this point, but we need it.
24+
StagesExternalDepsGenerator: nil,
25+
ChainPostRenderer: wc.ChainPostRenderer,
2426
})
2527
SetupRenderRelatedWerfChartParams(cmd, &installCmdData)
2628

cmd/werf/helm/template.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ var templateCmdData common.CmdData
1717

1818
func NewTemplateCmd(actionConfig *action.Configuration, wc *chart_extender.WerfChartStub) *cobra.Command {
1919
cmd, _ := helm_v3.NewTemplateCmd(actionConfig, os.Stdout, helm_v3.TemplateCmdOptions{
20-
StagesSplitter: helm.StagesSplitter{},
21-
ChainPostRenderer: wc.ChainPostRenderer,
20+
StagesSplitter: helm.NewStagesSplitter(),
21+
// TODO: actionConfig.RESTClientGetter not initialized at this point, but we need it.
22+
StagesExternalDepsGenerator: nil,
23+
ChainPostRenderer: wc.ChainPostRenderer,
2224
})
2325
SetupRenderRelatedWerfChartParams(cmd, &templateCmdData)
2426

cmd/werf/helm/upgrade.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ var upgradeCmdData common.CmdData
1919

2020
func NewUpgradeCmd(actionConfig *action.Configuration, wc *chart_extender.WerfChartStub) *cobra.Command {
2121
cmd, _ := helm_v3.NewUpgradeCmd(actionConfig, os.Stdout, helm_v3.UpgradeCmdOptions{
22-
StagesSplitter: helm.StagesSplitter{},
23-
ChainPostRenderer: wc.ChainPostRenderer,
22+
StagesSplitter: helm.NewStagesSplitter(),
23+
// TODO: actionConfig.RESTClientGetter not initialized at this point, but we need it.
24+
StagesExternalDepsGenerator: nil,
25+
ChainPostRenderer: wc.ChainPostRenderer,
2426
})
2527
SetupRenderRelatedWerfChartParams(cmd, &upgradeCmdData)
2628

cmd/werf/render/render.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ func runRender(ctx context.Context) error {
411411
}
412412

413413
templateOpts := helm_v3.TemplateCmdOptions{
414-
StagesSplitter: helm.StagesSplitter{},
414+
StagesSplitter: helm.NewStagesSplitter(),
415415
ChainPostRenderer: wc.ChainPostRenderer,
416416
ValueOpts: &values.Options{
417417
ValueFiles: common.GetValues(&commonCmdData),

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,6 @@ replace k8s.io/helm => github.com/werf/helm v0.0.0-20210202111118-81e74d46da0f
307307

308308
replace github.com/deislabs/oras => github.com/werf/third-party-oras v0.9.1-0.20210927171747-6d045506f4c8
309309

310-
replace helm.sh/helm/v3 => github.com/werf/3p-helm/v3 v3.0.0-20220615081302-d5ffa8d30462
310+
replace helm.sh/helm/v3 => github.com/werf/3p-helm/v3 v3.0.0-20220616090736-b002d47fddea
311311

312312
replace github.com/go-git/go-git/v5 => github.com/ZauberNerd/go-git/v5 v5.4.3-0.20220315170230-29ec1bc1e5db

0 commit comments

Comments
 (0)