这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
40ab941
Add exit codes for cancellation and failure scenarios in collect, com…
Priyanka-Chatterjee-2000 Aug 28, 2025
d587da9
Merge branch 'develop' into add-exit-codes
Priyanka-Chatterjee-2000 Sep 10, 2025
f8e4f6f
chore: update dependencies in go.mod
Priyanka-Chatterjee-2000 Sep 11, 2025
5c421d4
update
Priyanka-Chatterjee-2000 Sep 11, 2025
893df65
Revert "update"
Priyanka-Chatterjee-2000 Sep 11, 2025
8447bce
fix: improve error handling for exit codes in collect, compact, and c…
Priyanka-Chatterjee-2000 Sep 11, 2025
6656fc1
update error handling for exit codes in partition and plugin commands
Priyanka-Chatterjee-2000 Sep 11, 2025
7f9a4dc
update error handling for exit codes across various commands
Priyanka-Chatterjee-2000 Sep 12, 2025
07aacf1
refactor: replace error_helpers with internal error_display in comman…
Priyanka-Chatterjee-2000 Sep 12, 2025
be0e237
Merge branch 'develop' into add-exit-codes
Priyanka-Chatterjee-2000 Sep 12, 2025
efbbada
update import for error_display to use alias in diagnostics.go
Priyanka-Chatterjee-2000 Sep 12, 2025
882748f
update
Priyanka-Chatterjee-2000 Sep 12, 2025
5af73b5
update go.sum
Priyanka-Chatterjee-2000 Sep 12, 2025
8b20245
chore: downgrade github.com/turbot/pipe-fittings/v2 to v2.6.0 in go.mod
Priyanka-Chatterjee-2000 Sep 12, 2025
c029b96
Revert "chore: downgrade github.com/turbot/pipe-fittings/v2 to v2.6.0…
Priyanka-Chatterjee-2000 Sep 12, 2025
2787181
Revert "update go.sum"
Priyanka-Chatterjee-2000 Sep 12, 2025
60971d7
fix: update go.mod to correctly reference github.com/turbot/pipe-fitt…
Priyanka-Chatterjee-2000 Sep 15, 2025
ff101b5
chore: update dependencies in go.mod to latest versions
Priyanka-Chatterjee-2000 Sep 15, 2025
7b190b1
fix
pskrbasu Sep 15, 2025
3670015
refactor: rename TransformErrorToSteampipe to TransformErrorToTailpip…
Priyanka-Chatterjee-2000 Sep 15, 2025
32daf01
refactor: enhance error display functions to use output stream based …
Priyanka-Chatterjee-2000 Sep 15, 2025
41ceaf7
remove unused context variable in partitionDeleteCmd function
Priyanka-Chatterjee-2000 Sep 15, 2025
f693fbc
chore: update github.com/turbot/pipe-fittings/v2 to v2.7.0-rc.0 in go…
Priyanka-Chatterjee-2000 Sep 15, 2025
74c536a
rename pkg
pskrbasu Sep 15, 2025
b462437
fix
pskrbasu Sep 15, 2025
3fa26bb
fix: update cancellation messages in collect, compact, and connect co…
Priyanka-Chatterjee-2000 Sep 15, 2025
8b86a0f
fix: improve cancellation messages in table commands for better user …
Priyanka-Chatterjee-2000 Sep 15, 2025
59d6b9c
fix: enhance cancellation messages across various commands for improv…
Priyanka-Chatterjee-2000 Sep 16, 2025
1931c0b
update comment
Priyanka-Chatterjee-2000 Sep 16, 2025
6d198d1
Merge branch 'develop' into add-exit-codes
Priyanka-Chatterjee-2000 Sep 16, 2025
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
15 changes: 7 additions & 8 deletions cmd/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import (
"github.com/turbot/pipe-fittings/v2/cmdconfig"
pconstants "github.com/turbot/pipe-fittings/v2/constants"
"github.com/turbot/pipe-fittings/v2/contexthelpers"
"github.com/turbot/pipe-fittings/v2/error_helpers"
"github.com/turbot/pipe-fittings/v2/modconfig"
"github.com/turbot/pipe-fittings/v2/parse"
localcmdconfig "github.com/turbot/tailpipe/internal/cmdconfig"
"github.com/turbot/tailpipe/internal/collector"
"github.com/turbot/tailpipe/internal/config"
"github.com/turbot/tailpipe/internal/constants"
"github.com/turbot/tailpipe/internal/database"
error_helpers "github.com/turbot/tailpipe/internal/error_helpers"
"github.com/turbot/tailpipe/internal/plugin"
"golang.org/x/exp/maps"
)
Expand Down Expand Up @@ -71,8 +71,8 @@ func runCollectCmd(cmd *cobra.Command, args []string) {
}

if err != nil {
if errors.Is(err, context.Canceled) {
fmt.Println("Collection cancelled.") //nolint:forbidigo // ui output
if error_helpers.IsCancelledError(err) {
fmt.Println("tailpipe collect command cancelled.") //nolint:forbidigo // ui output
} else {
error_helpers.ShowError(ctx, err)
}
Expand Down Expand Up @@ -364,14 +364,13 @@ func setExitCodeForCollectError(err error) {
if exitCode != 0 || err == nil {
return
}
// TODO Set exit code for cancellation
if errors.Is(err, context.Canceled) {
exitCode = 0
// set exit code for cancellation
if error_helpers.IsCancelledError(err) {
exitCode = pconstants.ExitCodeOperationCancelled
return
}

// TODO #errors - assign exit codes https://github.com/turbot/tailpipe/issues/496
exitCode = 1
exitCode = pconstants.ExitCodeCollectionFailed
}

// parse the from time
Expand Down
15 changes: 10 additions & 5 deletions cmd/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"context"
"errors"
"fmt"
"log/slog"
"os"
Expand All @@ -15,11 +14,11 @@ import (
"github.com/turbot/pipe-fittings/v2/cmdconfig"
pconstants "github.com/turbot/pipe-fittings/v2/constants"
"github.com/turbot/pipe-fittings/v2/contexthelpers"
"github.com/turbot/pipe-fittings/v2/error_helpers"
localcmdconfig "github.com/turbot/tailpipe/internal/cmdconfig"
"github.com/turbot/tailpipe/internal/config"
"github.com/turbot/tailpipe/internal/constants"
"github.com/turbot/tailpipe/internal/database"
error_helpers "github.com/turbot/tailpipe/internal/error_helpers"
"golang.org/x/exp/maps"
)

Expand Down Expand Up @@ -49,9 +48,9 @@ func runCompactCmd(cmd *cobra.Command, args []string) {
if err != nil {
setExitCodeForCompactError(err)

if errors.Is(err, context.Canceled) {
if error_helpers.IsCancelledError(err) {
//nolint:forbidigo // ui
fmt.Println("Compact cancelled")
fmt.Println("tailpipe compact command cancelled.")
} else {
error_helpers.ShowError(ctx, err)
}
Expand Down Expand Up @@ -126,5 +125,11 @@ func setExitCodeForCompactError(err error) {
if exitCode != 0 || err == nil {
return
}
exitCode = 1
// set exit code for cancellation
if error_helpers.IsCancelledError(err) {
exitCode = pconstants.ExitCodeOperationCancelled
return
}

exitCode = pconstants.ExitCodeCompactFailed
}
25 changes: 19 additions & 6 deletions cmd/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,29 @@ import (
"context"
"encoding/json"
"fmt"
"golang.org/x/exp/maps"
"log"
"os"
"path/filepath"
"strings"
"time"

"golang.org/x/exp/maps"

"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/thediveo/enumflag/v2"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/v2/cmdconfig"
"github.com/turbot/pipe-fittings/v2/connection"
pconstants "github.com/turbot/pipe-fittings/v2/constants"
"github.com/turbot/pipe-fittings/v2/error_helpers"
"github.com/turbot/pipe-fittings/v2/contexthelpers"
pfilepaths "github.com/turbot/pipe-fittings/v2/filepaths"
"github.com/turbot/pipe-fittings/v2/parse"
localcmdconfig "github.com/turbot/tailpipe/internal/cmdconfig"
"github.com/turbot/tailpipe/internal/config"
"github.com/turbot/tailpipe/internal/constants"
"github.com/turbot/tailpipe/internal/database"
error_helpers "github.com/turbot/tailpipe/internal/error_helpers"
)

// variable used to assign the output mode flag
Expand Down Expand Up @@ -94,13 +96,21 @@ The generated script can be used with DuckDB:
func runConnectCmd(cmd *cobra.Command, _ []string) {
var err error
var initFilePath string
ctx := cmd.Context()
ctx, cancel := context.WithCancel(cmd.Context())
contexthelpers.StartCancelHandler(cancel)

defer func() {
if r := recover(); r != nil {
err = helpers.ToError(r)
}
setExitCodeForConnectError(err)
if err != nil {
if error_helpers.IsCancelledError(err) {
fmt.Println("tailpipe connect command cancelled.") //nolint:forbidigo // ui output
} else {
error_helpers.ShowError(ctx, err)
}
setExitCodeForConnectError(err)
}
displayOutput(ctx, initFilePath, err)
}()

Expand Down Expand Up @@ -409,8 +419,11 @@ func setExitCodeForConnectError(err error) {
if exitCode != 0 || err == nil || viper.GetString(pconstants.ArgOutput) == pconstants.OutputFormatJSON {
return
}

exitCode = 1
if error_helpers.IsCancelledError(err) {
exitCode = pconstants.ExitCodeOperationCancelled
return
}
exitCode = pconstants.ExitCodeConnectFailed
}

// generateInitFilename generates a temporary filename with a timestamp
Expand Down
50 changes: 41 additions & 9 deletions cmd/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
"github.com/turbot/pipe-fittings/v2/cmdconfig"
pconstants "github.com/turbot/pipe-fittings/v2/constants"
"github.com/turbot/pipe-fittings/v2/contexthelpers"
"github.com/turbot/pipe-fittings/v2/error_helpers"
"github.com/turbot/pipe-fittings/v2/printers"
"github.com/turbot/pipe-fittings/v2/utils"
localcmdconfig "github.com/turbot/tailpipe/internal/cmdconfig"
"github.com/turbot/tailpipe/internal/constants"
"github.com/turbot/tailpipe/internal/display"
error_helpers "github.com/turbot/tailpipe/internal/error_helpers"
)

// variable used to assign the output mode flag
Expand Down Expand Up @@ -73,11 +73,20 @@ func runFormatListCmd(cmd *cobra.Command, args []string) {
ctx, cancel := context.WithCancel(cmd.Context())
contexthelpers.StartCancelHandler(cancel)
utils.LogTime("runFormatListCmd start")
var err error
defer func() {
utils.LogTime("runFormatListCmd end")
if r := recover(); r != nil {
error_helpers.ShowError(ctx, helpers.ToError(r))
exitCode = pconstants.ExitCodeUnknownErrorPanic
err = helpers.ToError(r)
}
if err != nil {
if error_helpers.IsCancelledError(err) {
//nolint:forbidigo // ui output
fmt.Println("tailpipe format list command cancelled.")
} else {
error_helpers.ShowError(ctx, err)
}
setExitCodeForFormatError(err,1)
}
}()

Expand All @@ -99,8 +108,8 @@ func runFormatListCmd(cmd *cobra.Command, args []string) {
// Print
err = printer.PrintResource(ctx, printableResource, cmd.OutOrStdout())
if err != nil {
error_helpers.ShowError(ctx, err)
exitCode = pconstants.ExitCodeUnknownErrorPanic
exitCode = pconstants.ExitCodeOutputRenderingFailed
return
}
}

Expand Down Expand Up @@ -128,11 +137,20 @@ func runFormatShowCmd(cmd *cobra.Command, args []string) {
ctx, cancel := context.WithCancel(cmd.Context())
contexthelpers.StartCancelHandler(cancel)
utils.LogTime("runFormatShowCmd start")
var err error
defer func() {
utils.LogTime("runFormatShowCmd end")
if r := recover(); r != nil {
error_helpers.ShowError(ctx, helpers.ToError(r))
exitCode = pconstants.ExitCodeUnknownErrorPanic
err = helpers.ToError(r)
}
if err != nil {
if error_helpers.IsCancelledError(err) {
//nolint:forbidigo // ui output
fmt.Println("tailpipe format show command cancelled.")
} else {
error_helpers.ShowError(ctx, err)
}
setExitCodeForFormatError(err, 1)
}
}()

Expand All @@ -149,7 +167,21 @@ func runFormatShowCmd(cmd *cobra.Command, args []string) {
// Print
err = printer.PrintResource(ctx, printableResource, cmd.OutOrStdout())
if err != nil {
error_helpers.ShowError(ctx, err)
exitCode = pconstants.ExitCodeUnknownErrorPanic
exitCode = pconstants.ExitCodeOutputRenderingFailed
return
}
}

func setExitCodeForFormatError(err error, nonCancelCode int) {
// set exit code only if an error occurred and no exit code is already set
if exitCode != 0 || err == nil {
return
}
// set exit code for cancellation
if error_helpers.IsCancelledError(err) {
exitCode = pconstants.ExitCodeOperationCancelled
return
}
// no dedicated format exit code exists yet; use generic nonzero failure
exitCode = nonCancelCode
}
Loading