Skip to content

Commit

Permalink
fix log output
Browse files Browse the repository at this point in the history
  • Loading branch information
cw-sakamoto committed Dec 11, 2023
1 parent 15eaf8b commit d31b484
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
5 changes: 2 additions & 3 deletions cmd/cert-manager/cert-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,15 @@ func NewCertManager(checker *cmd.Checker) (*CertManager, error) {
k8sclientset, err := config.NewK8sClientset()

if err != nil {
checker.Logger().Errorf("Error NewK8sClientset: %s ", err)
return nil, fmt.Errorf("error NewK8sClientset: %s", err)
}

scheme := runtime.NewScheme()
_ = cmapiv1.AddToScheme(scheme)

k8sclient, err := config.NewK8sClient(client.Options{Scheme: scheme})
if err != nil {
checker.Logger().Errorf("NewK8sClient: %s", err)
return nil, err
return nil, fmt.Errorf("error NewK8sClient: %s", err)
}

return &CertManager{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cluster-autoscaler/clusterAutoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewClusterAutoscaler(checker *cmd.Checker) (*ClusterAutoscaler, error) {

k8sclientset, err := config.NewK8sClientset()
if err != nil {
checker.Logger().Error("Error NewK8sClientset: ", err)
return nil, fmt.Errorf("error NewK8sClientset: %s", err)
}

return &ClusterAutoscaler{
Expand Down
6 changes: 2 additions & 4 deletions cmd/fluent/fluent.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ func NewFluent(checker *cmd.Checker) (*Fluent, error) {

k8sclient, err := config.NewK8sClientset()
if err != nil {
checker.Logger().Errorf("NewK8sClientset: %s", err)
return nil, err
return nil, fmt.Errorf("NewK8sClientset: %s", err)
}

awsConfig, err := config.NewAwsConfig(checker.Ctx)
if err != nil {
checker.Logger().Errorf("NewAwsConfig: %s", err)
return nil, err
return nil, fmt.Errorf("NewAwsConfig: %s", err)
}

return &Fluent{
Expand Down
11 changes: 5 additions & 6 deletions cmd/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ func NewIngress(checker *cmd.Checker, noDnsCheck bool) (*Ingress, error) {

k8sclient, err := config.NewK8sClientset()
if err != nil {
checker.Logger().Errorf("NewK8sClientset: %s", err)
return nil, err
return nil, fmt.Errorf("error NewK8sClientset: %s", err)
}

return &Ingress{
Expand Down Expand Up @@ -112,19 +111,19 @@ func (i *Ingress) createResources() error {
ObjectMeta: metav1.ObjectMeta{
Name: i.Namespace,
}}); err != nil {
i.Chatwork.AddMessage(fmt.Sprintf("Error Create Namespace: %s", err))
i.Chatwork.AddMessage(fmt.Sprintf("Error Create Namespace: %s\n", err))
return err
}
if err := k.CreateDeployment(i.Ctx, i.createDeploymentObject(), i.Timeout); err != nil {
i.Chatwork.AddMessage(fmt.Sprintf("Error Create Deployment: %s", err))
i.Chatwork.AddMessage(fmt.Sprintf("Error Create Deployment: %s\n", err))
return err
}
if err := k.CreateService(i.Ctx, i.createServiceObject()); err != nil {
i.Chatwork.AddMessage(fmt.Sprintf("Error Create Service: %s", err))
i.Chatwork.AddMessage(fmt.Sprintf("Error Create Service: %s\n", err))
return err
}
if err := k.CreateIngress(i.Ctx, i.createIngressObject(), i.Timeout); err != nil {
i.Chatwork.AddMessage(fmt.Sprintf("Error Create Ingress: %s", err))
i.Chatwork.AddMessage(fmt.Sprintf("Error Create Ingress: %s\n", err))
return err
}
return nil
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ func main() {
logger().Debug("log level: ", logLevel)

chatwork = initChatwork(logger)

ctx = newSignalContext(logger, chatwork)

cmdIngress.Flags().BoolVar(&noDnsCheck, "no-dns-check", false, "This is a flag for the dns check. If you want to skip the dns check, please specify false.(default: false)")
Expand All @@ -219,6 +220,7 @@ func main() {

if err := rootCmd.Execute(); err != nil {
chatwork.AddMessage("Error: " + err.Error() + "\n")
chatwork.Send()
logger().Fatal("Error: ", err)
}
}
Expand Down

0 comments on commit d31b484

Please sign in to comment.