Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cli #278

Open
wants to merge 2 commits into
base: 2.x.x
Choose a base branch
from
Open
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
Next Next commit
fix cli
umanggoyald11 committed Jan 18, 2025
commit 012f58675d54c48ffa074deb2509a9fe63924e6a
1 change: 1 addition & 0 deletions cmd/create/create.go
Original file line number Diff line number Diff line change
@@ -14,4 +14,5 @@ var createCmd = &cobra.Command{

func init() {
cmd.RootCmd.AddCommand(createCmd)

}
23 changes: 17 additions & 6 deletions cmd/deploy/service.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
"context"
"encoding/json"
"errors"
"google.golang.org/grpc/status"
"os"
"regexp"

@@ -15,6 +16,11 @@
"github.com/spf13/cobra"
)

const (
Red = "\033[31m" // Red color for errors
Reset = "\033[0m" // Reset to default
)

var env string
var definitionFile string
var provisioningFile string
@@ -92,23 +98,20 @@
})

if err != nil {
log.Fatal("Failed to deploy service ", err)
handleDeployServiceError(err)
}
}

func deployUsingServiceNameAndVersion(ctx context.Context) {
log.Info("deploying service :", serviceName, ":", serviceVersion, " in env :", env)
err := serviceClient.DeployReleasedService(&ctx, &serviceProto.DeployReleasedServiceRequest{
_ = serviceClient.DeployReleasedService(&ctx, &serviceProto.DeployReleasedServiceRequest{
EnvName: env,
ServiceIdentifier: &serviceProto.ServiceIdentifier{
ServiceName: serviceName,
ServiceVersion: serviceVersion,
},
})

if err != nil {
log.Fatal("Failed to deploy service ", err)
}
}

func deployUsingServiceNameAndLabels(ctx context.Context) {
@@ -122,7 +125,7 @@
})

if err != nil {
log.Fatal("Failed to deploy service ", err)
handleDeployServiceError(err)
}
}

@@ -137,3 +140,11 @@
}
return nil
}

func handleDeployServiceError(err error) {
if st, ok := status.FromError(err); ok {
log.Fatalf("%s %s: %s %s", Red, st.Message(), Reset)

Check failure on line 146 in cmd/deploy/service.go

GitHub Actions / lint

github.com/sirupsen/logrus.Fatalf format %s reads arg #4, but call has 3 args
} else {
log.Fatalf("%s %s: %s %v", Red, err, Reset)

Check failure on line 148 in cmd/deploy/service.go

GitHub Actions / lint

github.com/sirupsen/logrus.Fatalf format %v reads arg #4, but call has 3 args
}
}
31 changes: 19 additions & 12 deletions internal/ui/logger.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
package ui

import (
"github.com/dream11/odin/pkg/constant"
"github.com/dream11/odin/pkg/util"
log "github.com/sirupsen/logrus"
)
import log "github.com/sirupsen/logrus"

func init() {
type CustomTextFormatter struct {
BaseFormatter *log.TextFormatter
}

func (f *CustomTextFormatter) Format(entry *log.Entry) ([]byte, error) {
// Return only the log message, ignoring the log level and timestamp
return []byte(entry.Message + "\n"), nil
}

log.SetFormatter(&log.TextFormatter{
ForceColors: true,
DisableColors: false,
TimestampFormat: "2006-01-02 15:04:05", // Custom format
FullTimestamp: true,
func init() {
log.SetFormatter(&CustomTextFormatter{
BaseFormatter: &log.TextFormatter{
ForceColors: true,
DisableColors: false,
DisableTimestamp: true,
DisableLevelTruncation: true,
},
})
level, err := log.ParseLevel(util.GetEnvOrDefault(constant.LogLevelKey, "info"))

level, err := log.ParseLevel("info")
if err != nil {
log.Warning("Invalid log level. Allowed values are: panic, fatal, error, warn, info, debug, trace")
log.SetLevel(log.InfoLevel)