mirror of
https://github.com/kubernetes-sigs/kind.git
synced 2025-12-01 07:26:05 +07:00
replace all os.Exit with log.Fatal
This commit is contained in:
@@ -7,6 +7,7 @@ go_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//kind/pkg/build:go_default_library",
|
||||
"//vendor/github.com/sirupsen/logrus:go_default_library",
|
||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -17,8 +17,7 @@ limitations under the License.
|
||||
package base
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/test-infra/kind/pkg/build"
|
||||
@@ -50,6 +49,6 @@ func run(flags *flags, cmd *cobra.Command, args []string) {
|
||||
ctx.SourceDir = flags.Source
|
||||
err := ctx.Build()
|
||||
if err != nil {
|
||||
os.Exit(-1)
|
||||
log.Fatalf("Build failed! %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ limitations under the License.
|
||||
package node
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -50,12 +48,10 @@ func run(flags *flags, cmd *cobra.Command, args []string) {
|
||||
// TODO(bentheelder): make this more configurable
|
||||
ctx, err := build.NewNodeImageBuildContext(flags.BuildType)
|
||||
if err != nil {
|
||||
log.Errorf("Error creating build context: %v", err)
|
||||
os.Exit(-1)
|
||||
log.Fatalf("Error creating build context: %v", err)
|
||||
}
|
||||
err = ctx.Build()
|
||||
if err != nil {
|
||||
log.Errorf("Error building node image: %v", err)
|
||||
os.Exit(-1)
|
||||
log.Fatalf("Error building node image: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ limitations under the License.
|
||||
package create
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -53,8 +51,7 @@ func run(flags *flags, cmd *cobra.Command, args []string) {
|
||||
// load the config
|
||||
config, err := cluster.LoadCreateConfig(flags.Config)
|
||||
if err != nil {
|
||||
log.Errorf("Error loading config: %v", err)
|
||||
os.Exit(-1)
|
||||
log.Fatalf("Error loading config: %v", err)
|
||||
}
|
||||
// validate the config
|
||||
err = config.Validate()
|
||||
@@ -64,17 +61,15 @@ func run(flags *flags, cmd *cobra.Command, args []string) {
|
||||
for _, problem := range configErrors.Errors() {
|
||||
log.Error(problem)
|
||||
}
|
||||
os.Exit(-1)
|
||||
log.Fatal("Aborting due to invalid configuration.")
|
||||
}
|
||||
// create a cluster context and create the cluster
|
||||
ctx, err := cluster.NewContext(flags.Name)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to create cluster context! %v", err)
|
||||
os.Exit(-1)
|
||||
log.Fatalf("Failed to create cluster context! %v", err)
|
||||
}
|
||||
err = ctx.Create(config)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to create cluster: %v", err)
|
||||
os.Exit(-1)
|
||||
log.Fatalf("Failed to create cluster: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ limitations under the License.
|
||||
package delete
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -50,12 +48,10 @@ func run(flags *flags, cmd *cobra.Command, args []string) {
|
||||
// TODO(bentheelder): make this more configurable
|
||||
ctx, err := cluster.NewContext(flags.Name)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to create cluster context! %v", err)
|
||||
os.Exit(-1)
|
||||
log.Fatalf("Failed to create cluster context! %v", err)
|
||||
}
|
||||
err = ctx.Delete()
|
||||
if err != nil {
|
||||
log.Errorf("Failed to delete cluster: %v", err)
|
||||
os.Exit(-1)
|
||||
log.Fatalf("Failed to delete cluster: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user