Skip to content

Commit 3c64bd9

Browse files
committed
feat(nelm): show NOTES.txt on release
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
1 parent 4547fa7 commit 3c64bd9

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

cmd/werf/converge/converge.go

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,8 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
637637
return fmt.Errorf("error constructing chart tree: %w", err)
638638
}
639639

640+
notes := chartTree.Notes()
641+
640642
var prevRelGeneralResources []*resrc.GeneralResource
641643
if prevReleaseFound {
642644
prevRelGeneralResources = prevRelease.GeneralResources()
@@ -679,7 +681,7 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
679681
}
680682

681683
log.Default.Info(ctx, "Constructing new release")
682-
newRel, err := rls.NewRelease(releaseName, releaseNamespace.Name(), newRevision, chartTree.ReleaseValues(), chartTree.LegacyChart(), resProcessor.ReleasableHookResources(), resProcessor.ReleasableGeneralResources(), chartTree.Notes(), rls.ReleaseOptions{
684+
newRel, err := rls.NewRelease(releaseName, releaseNamespace.Name(), newRevision, chartTree.ReleaseValues(), chartTree.LegacyChart(), resProcessor.ReleasableHookResources(), resProcessor.ReleasableGeneralResources(), notes, rls.ReleaseOptions{
683685
FirstDeployed: firstDeployed,
684686
Mapper: clientFactory.Mapper(),
685687
})
@@ -746,6 +748,7 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
746748
if useless, err := plan.Useless(); err != nil {
747749
return fmt.Errorf("error checking if deploy plan will do nothing useful: %w", err)
748750
} else if useless {
751+
printNotes(ctx, notes)
749752
log.Default.Info(ctx, color.Style{color.Bold, color.Green}.Render("Skipped release")+" %q (namespace: %q): cluster resources already as desired", releaseName, releaseNamespace.Name())
750753
return nil
751754
}
@@ -842,7 +845,7 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
842845
nonCriticalErrs = append(nonCriticalErrs, noncriterrs...)
843846

844847
if cmdData.AutoRollback && prevDeployedReleaseFound {
845-
wcompops, wfailops, wcancops, criterrs, noncriterrs = runRollbackPlan(
848+
wcompops, wfailops, wcancops, notes, criterrs, noncriterrs = runRollbackPlan(
846849
ctx,
847850
taskStore,
848851
logStore,
@@ -889,6 +892,10 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
889892
}
890893
}
891894

895+
if len(criticalErrs) == 0 {
896+
printNotes(ctx, notes)
897+
}
898+
892899
if len(criticalErrs) > 0 {
893900
return utls.Multierrorf("failed release %q (namespace: %q)", append(criticalErrs, nonCriticalErrs...), releaseName, releaseNamespace.Name())
894901
} else if len(nonCriticalErrs) > 0 {
@@ -1006,7 +1013,7 @@ func runRollbackPlan(
10061013
rollbackGraphPath string,
10071014
networkParallelism int,
10081015
) (
1009-
worthyCompletedOps, worthyFailedOps, worthyCanceledOps []opertn.Operation,
1016+
worthyCompletedOps, worthyFailedOps, worthyCanceledOps []opertn.Operation, notes string,
10101017
criticalErrs, nonCriticalErrs []error,
10111018
) {
10121019
log.Default.Info(ctx, "Processing rollback resources")
@@ -1042,7 +1049,7 @@ func runRollbackPlan(
10421049
)
10431050

10441051
if err := resProcessor.Process(ctx); err != nil {
1045-
return nil, nil, nil, []error{fmt.Errorf("error processing rollback resources: %w", err)}, nonCriticalErrs
1052+
return nil, nil, nil, "", []error{fmt.Errorf("error processing rollback resources: %w", err)}, nonCriticalErrs
10461053
}
10471054

10481055
rollbackRevision := failedRevision + 1
@@ -1063,7 +1070,7 @@ func runRollbackPlan(
10631070
},
10641071
)
10651072
if err != nil {
1066-
return nil, nil, nil, []error{fmt.Errorf("error constructing rollback release: %w", err)}, nonCriticalErrs
1073+
return nil, nil, nil, "", []error{fmt.Errorf("error constructing rollback release: %w", err)}, nonCriticalErrs
10671074
}
10681075

10691076
log.Default.Info(ctx, "Constructing rollback plan")
@@ -1094,7 +1101,7 @@ func runRollbackPlan(
10941101

10951102
rollbackPlan, err := rollbackPlanBuilder.Build(ctx)
10961103
if err != nil {
1097-
return nil, nil, nil, []error{fmt.Errorf("error building rollback plan: %w", err)}, nonCriticalErrs
1104+
return nil, nil, nil, "", []error{fmt.Errorf("error building rollback plan: %w", err)}, nonCriticalErrs
10981105
}
10991106

11001107
if saveRollbackGraph {
@@ -1104,10 +1111,10 @@ func runRollbackPlan(
11041111
}
11051112

11061113
if useless, err := rollbackPlan.Useless(); err != nil {
1107-
return nil, nil, nil, []error{fmt.Errorf("error checking if rollback plan will do nothing useful: %w", err)}, nonCriticalErrs
1114+
return nil, nil, nil, "", []error{fmt.Errorf("error checking if rollback plan will do nothing useful: %w", err)}, nonCriticalErrs
11081115
} else if useless {
11091116
log.Default.Info(ctx, color.Style{color.Bold, color.Green}.Render("Skipped rollback release")+" %q (namespace: %q): cluster resources already as desired", releaseName, releaseNamespace.Name())
1110-
return nil, nil, nil, criticalErrs, nonCriticalErrs
1117+
return nil, nil, nil, "", criticalErrs, nonCriticalErrs
11111118
}
11121119

11131120
log.Default.Info(ctx, "Executing rollback plan")
@@ -1166,7 +1173,7 @@ func runRollbackPlan(
11661173
nonCriticalErrs = append(nonCriticalErrs, noncriterrs...)
11671174
}
11681175

1169-
return worthyCompletedOps, worthyFailedOps, worthyCanceledOps, criticalErrs, nonCriticalErrs
1176+
return worthyCompletedOps, worthyFailedOps, worthyCanceledOps, rollbackRel.Notes(), criticalErrs, nonCriticalErrs
11701177
}
11711178

11721179
func printTables(ctx context.Context, tablesBuilder *track.TablesBuilder) {
@@ -1314,3 +1321,13 @@ func checkHelm3ReleaseExists(ctx context.Context, releaseName, namespace string,
13141321

13151322
return foundHelm3Release, nil
13161323
}
1324+
1325+
func printNotes(ctx context.Context, notes string) {
1326+
if notes == "" {
1327+
return
1328+
}
1329+
1330+
log.Default.InfoBlock(ctx, color.Style{color.Bold, color.Blue}.Render("Release notes")).Do(func() {
1331+
log.Default.Info(ctx, notes)
1332+
})
1333+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ require (
6565
github.com/werf/kubedog v0.12.4-0.20240229114338-b4b4fe4011fe
6666
github.com/werf/lockgate v0.1.1
6767
github.com/werf/logboek v0.6.1
68-
github.com/werf/nelm v0.0.0-20240307093820-a630e7887ba2
68+
github.com/werf/nelm v0.0.0-20240307103636-81088a0ff3f0
6969
go.opentelemetry.io/otel v1.21.0
7070
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0
7171
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,8 +1558,8 @@ github.com/werf/lockgate v0.1.1 h1:S400JFYjtWfE4i4LY9FA8zx0fMdfui9DPrBiTciCrx4=
15581558
github.com/werf/lockgate v0.1.1/go.mod h1:0yIFSLq9ausy6ejNxF5uUBf/Ib6daMAfXuCaTMZJzIE=
15591559
github.com/werf/logboek v0.6.1 h1:oEe6FkmlKg0z0n80oZjLplj6sXcBeLleCkjfOOZEL2g=
15601560
github.com/werf/logboek v0.6.1/go.mod h1:Gez5J4bxekyr6MxTmIJyId1F61rpO+0/V4vjCIEIZmk=
1561-
github.com/werf/nelm v0.0.0-20240307093820-a630e7887ba2 h1:RzJNNLwIDsLhdEXP9s9i0m6X7Td2fr636bXzhACCKw4=
1562-
github.com/werf/nelm v0.0.0-20240307093820-a630e7887ba2/go.mod h1:JJkG5txk0x4uV8oFh0J/Ow260K8bhe3QeOlaBCHWHJw=
1561+
github.com/werf/nelm v0.0.0-20240307103636-81088a0ff3f0 h1:KmVMyRSOET5mo1YuY3SmxAUvw5os5nXBWLGsyYAHa9s=
1562+
github.com/werf/nelm v0.0.0-20240307103636-81088a0ff3f0/go.mod h1:JJkG5txk0x4uV8oFh0J/Ow260K8bhe3QeOlaBCHWHJw=
15631563
github.com/xanzy/go-gitlab v0.31.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug=
15641564
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
15651565
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=

0 commit comments

Comments
 (0)