Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pkg/app/pipectl/cmd/planpreview/planpreview.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ type ApplicationInfo struct {
func (r ReadableResult) String() string {
var b strings.Builder
if len(r.Applications)+len(r.FailureApplications)+len(r.FailurePipeds) == 0 {
fmt.Fprintf(&b, "\nThere are no applications to build plan-preview\n")
fmt.Fprintf(&b, "\nThere are no updated applications. It means no deployment will be triggered once this pull request got merged.\n")
return b.String()
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/app/pipectl/cmd/planpreview/planpreview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestReadableResultString(t *testing.T) {
name: "empty",
results: []*model.PlanPreviewCommandResult{},
expected: `
There are no applications to build plan-preview
There are no updated applications. It means no deployment will be triggered once this pull request got merged.
`,
},
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/piped/cloudprovider/kubernetes/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (r *DiffListResult) DiffString() string {
renderer := diff.NewRenderer(opts...)

index++
b.WriteString(fmt.Sprintf("* %d. %s\n\n", index, key.ReadableString()))
b.WriteString(fmt.Sprintf("# %d. %s\n\n", index, key.ReadableString()))
b.WriteString(renderer.Render(change.Diff.Nodes()))
b.WriteString("\n")

Expand Down
17 changes: 16 additions & 1 deletion pkg/app/piped/cmd/piped/piped.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,23 @@ func (p *piped) run(ctx context.Context, t cli.Telemetry) (runErr error) {

// Start running planpreview handler.
if p.enablePlanPreview {
// Initialize a dedicated git client for plan-preview feature.
// Basically, this feature is an utility so it should not share any resource with the main components of piped.
gc, err := git.NewClient(cfg.Git.Username, cfg.Git.Email, t.Logger)
if err != nil {
t.Logger.Error("failed to initialize git client for plan-preview", zap.Error(err))
return err
}
defer func() {
if err := gc.Clean(); err != nil {
t.Logger.Error("had an error while cleaning gitClient for plan-preview", zap.Error(err))
} else {
t.Logger.Info("successfully cleaned gitClient for plan-preview")
}
Comment thread
nghialv marked this conversation as resolved.
}()

h := planpreview.NewHandler(
gitClient,
gc,
apiClient,
commandLister,
applicationLister,
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/piped/planpreview/kubernetesdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (b *builder) kubernetesDiff(
}

summary := fmt.Sprintf("%d added manifests, %d changed manifests, %d deleted manifests", len(result.Adds), len(result.Changes), len(result.Deletes))
fmt.Fprintf(buf, "---Head Commit\n+++Last Deploy\n\n%s\n", result.DiffString())
fmt.Fprintf(buf, "--- Last Deploy\n+++ Head Commit\n\n%s\n", result.DiffString())

return summary, nil
}
Expand Down