health-checker
health-checker copied to clipboard
Update code to be able to compile with latest modules
Patch used to be able to compile with latest modules, notably os, cli/v2
--- ./main.go.dist 2025-01-31 08:58:34.464600500 -0600
+++ ./main.go 2025-01-31 08:54:16.125657900 -0600
@@ -1,8 +1,8 @@
package main
import (
- "github.com/gruntwork-io/go-commons/entrypoint"
- "github.com/gruntwork-io/health-checker/commands"
+ "os"
+ "github.com/gruntwork-io/health-checker/commands"
)
// This variable is set at build time using -ldflags parameters. For example, we typically set this flag in circle.yml
@@ -15,6 +15,10 @@
// This is the main entry point for the app.
func main() {
- app := commands.CreateCli(VERSION)
- entrypoint.RunApp(app)
+ app := commands.CreateCli(VERSION)
+ err := app.Run(os.Args) // Use app.Run instead of entrypoint.RunApp
+ if err != nil {
+ // Handle error appropriately
+ os.Exit(1)
+ }
}
--- ./commands/cli.go.dist 2025-01-31 08:58:34.464600500 -0600
+++ ./commands/cli.go 2025-01-31 08:55:26.977245800 -0600
@@ -3,7 +3,7 @@
import (
"github.com/gruntwork-io/go-commons/errors"
"github.com/gruntwork-io/health-checker/server"
- "github.com/urfave/cli"
+ "github.com/urfave/cli/v2"
)
// Create the CLI app with all commands (in this case a single one!), flags, and usage text configured.
--- ./commands/flags.go.dist 2025-01-31 08:58:34.464600500 -0600
+++ ./commands/flags.go 2025-01-31 08:55:32.194264300 -0600
@@ -8,7 +8,7 @@
"github.com/gruntwork-io/go-commons/logging"
"github.com/gruntwork-io/health-checker/options"
"github.com/sirupsen/logrus"
- "github.com/urfave/cli"
+ "github.com/urfave/cli/v2"
)
const DEFAULT_LISTENER_IP_ADDRESS = "0.0.0.0"
@@ -16,34 +16,34 @@
const DEFAULT_SCRIPT_TIMEOUT_SEC = 5
const ENV_VAR_NAME_DEBUG_MODE = "HEALTH_CHECKER_DEBUG"
-var portFlag = cli.IntSliceFlag{
+var portFlag = &cli.IntSliceFlag{
Name: "port",
Usage: fmt.Sprintf("[One of port/script Required] The port number on which a TCP connection will be attempted. Specify one or more times. Example: 8000"),
}
-var scriptFlag = cli.StringSliceFlag{
+var scriptFlag = &cli.StringSliceFlag{
Name: "script",
Usage: fmt.Sprintf("[One of port/script Required] The path to script that will be run. Specify one or more times. Example: \"/usr/local/bin/health-check.sh --http-port 8000\""),
}
-var scriptTimeoutFlag = cli.IntFlag{
+var scriptTimeoutFlag = &cli.IntFlag{
Name: "script-timeout",
Usage: fmt.Sprintf("[Optional] Timeout, in seconds, to wait for the scripts to complete. Example: 10"),
Value: DEFAULT_SCRIPT_TIMEOUT_SEC,
}
-var singleflightFlag = cli.BoolFlag{
+var singleflightFlag = &cli.BoolFlag{
Name: "singleflight",
Usage: fmt.Sprintf("[Optional] Enable singleflight mode, which makes concurrent requests share the same check."),
}
-var listenerFlag = cli.StringFlag{
+var listenerFlag = &cli.StringFlag{
Name: "listener",
Usage: fmt.Sprintf("[Optional] The IP address and port on which inbound HTTP connections will be accepted."),
Value: fmt.Sprintf("%s:%d", DEFAULT_LISTENER_IP_ADDRESS, DEFAULT_LISTENER_PORT),
}
-var logLevelFlag = cli.StringFlag{
+var logLevelFlag = &cli.StringFlag{
Name: "log-level",
Usage: fmt.Sprintf("[Optional] Set the log level to `LEVEL`. Must be one of: %v", logrus.AllLevels),
Value: logrus.InfoLevel.String(),
--- ./commands/flags_test.go.dist 2025-01-31 08:58:34.464600500 -0600
+++ ./commands/flags_test.go 2025-01-31 08:55:37.404154500 -0600
@@ -5,7 +5,7 @@
"github.com/gruntwork-io/health-checker/options"
"github.com/gruntwork-io/health-checker/test"
"github.com/stretchr/testify/assert"
- "github.com/urfave/cli"
+ "github.com/urfave/cli/v2"
"strings"
"testing"
)