From c66470b6e3401126ff280b2a7aea2ebdd91d7b87 Mon Sep 17 00:00:00 2001 From: siyual-park Date: Sat, 16 Nov 2024 11:40:59 +0900 Subject: [PATCH] fix: remove stdout when start --- cmd/pkg/cli/start.go | 10 ++++++++++ pkg/scheme/scheme.go | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/cmd/pkg/cli/start.go b/cmd/pkg/cli/start.go index e6343e21..6535753d 100644 --- a/cmd/pkg/cli/start.go +++ b/cmd/pkg/cli/start.go @@ -1,6 +1,7 @@ package cli import ( + "io" "os" "os/signal" "syscall" @@ -68,6 +69,13 @@ func runStartCommand(config StartConfig) func(cmd *cobra.Command, args []string) return err } + out := cmd.OutOrStdout() + if out == os.Stdout { + out = nil + } + + cmd.SetOut(io.Discard) + if err := applySpecs(cmd); err != nil { return err } @@ -78,6 +86,8 @@ func runStartCommand(config StartConfig) func(cmd *cobra.Command, args []string) return err } + cmd.SetOut(out) + h := config.Hook if h == nil { h = hook.New() diff --git a/pkg/scheme/scheme.go b/pkg/scheme/scheme.go index a9b8100a..3233f7c5 100644 --- a/pkg/scheme/scheme.go +++ b/pkg/scheme/scheme.go @@ -1,6 +1,7 @@ package scheme import ( + "github.com/gofrs/uuid" "reflect" "slices" "sync" @@ -151,5 +152,8 @@ func (s *Scheme) Decode(sp spec.Spec) (spec.Spec, error) { return nil, err } + if structured.GetID() == uuid.Nil { + structured.SetID(uuid.Must(uuid.NewV7())) + } return structured, nil }