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

feat: trace #266

Open
wants to merge 2 commits into
base: 2.x.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion cmd/create/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func init() {

func execute(cmd *cobra.Command) {
ctx := cmd.Context()
traceID := util.GenerateTraceID()
// Validate accounts parameter
if err := validateAccounts(accounts); err != nil {
log.Fatal("Invalid accounts parameter: ", err)
Expand All @@ -70,9 +71,10 @@ func execute(cmd *cobra.Command) {
EnvName: envName,
Accounts: util.SplitProviderAccount(accounts),
ProvisioningType: provisioningType,
})
}, traceID)

if err != nil {
log.Info("TraceId: ", traceID)
log.Fatal("Failed to create environment ", err)
}
}
5 changes: 4 additions & 1 deletion cmd/delete/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package delete

import (
"github.com/dream11/odin/internal/service"
"github.com/dream11/odin/pkg/util"
environment "github.com/dream11/odin/proto/gen/go/dream11/od/environment/v1"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -34,11 +35,13 @@ func init() {

func execute(cmd *cobra.Command) {
ctx := cmd.Context()
traceID := util.GenerateTraceID()
err := environmentClient.DeleteEnvironment(&ctx, &environment.DeleteEnvironmentRequest{
EnvName: name,
})
}, traceID)

if err != nil {
log.Info("TraceId: ", traceID)
log.Fatal("Failed to delete environment ", err)
}
}
7 changes: 5 additions & 2 deletions cmd/deploy/service-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package deploy

import (
"encoding/json"
"github.com/dream11/odin/pkg/util"
"os"

"github.com/dream11/odin/pkg/config"
Expand Down Expand Up @@ -36,6 +37,7 @@ func executeDeployServiceSet(cmd *cobra.Command) {
env = config.EnsureEnvPresent(env)

ctx := cmd.Context()
traceID := util.GenerateTraceID()
if serviceSetName == "" && provisioningFile == "" {
log.Fatal("Please provide either --name or --file.")
}
Expand All @@ -61,8 +63,9 @@ func executeDeployServiceSet(cmd *cobra.Command) {
deployServiceSetRequest.Name = serviceSetName
}

err := serviceClient.DeployServiceSet(&ctx, &deployServiceSetRequest)
err := serviceClient.DeployServiceSet(&ctx, &deployServiceSetRequest, traceID)
if err != nil {
log.Fatal("Failed to deploy service ", err)
log.Info("TraceId: ", traceID)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trace id should be always be logged as a debug message

log.Fatal("Failed to deploy service set", err)
}
}
8 changes: 6 additions & 2 deletions cmd/deploy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package deploy

import (
"encoding/json"
"github.com/dream11/odin/pkg/util"
"os"

"github.com/dream11/odin/internal/service"
Expand Down Expand Up @@ -43,6 +44,7 @@ func init() {
func execute(cmd *cobra.Command) {
env = config.EnsureEnvPresent(env)
ctx := cmd.Context()
traceID := util.GenerateTraceID()
if (serviceName == "" && serviceVersion == "") && (definitionFile != "" && provisioningFile != "") {
definitionData, err := os.ReadFile(definitionFile)
if err != nil {
Expand All @@ -69,9 +71,10 @@ func execute(cmd *cobra.Command) {
EnvName: env,
ServiceDefinition: &definitionProto,
ProvisioningConfig: provisioningProto,
})
}, traceID)

if err != nil {
log.Info("TraceId: ", traceID)
log.Fatal("Failed to deploy service ", err)
}
} else if (serviceName != "" && serviceVersion != "") && (definitionFile == "" && provisioningFile == "") {
Expand All @@ -82,9 +85,10 @@ func execute(cmd *cobra.Command) {
ServiceName: serviceName,
ServiceVersion: serviceVersion,
},
})
}, traceID)

if err != nil {
log.Info("TraceId: ", traceID)
log.Fatal("Failed to deploy service ", err)
}
} else {
Expand Down
5 changes: 4 additions & 1 deletion cmd/describe/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package describe
import (
"encoding/json"
"fmt"
"github.com/dream11/odin/pkg/util"

serviceBackend "github.com/dream11/odin/internal/service"
comp "github.com/dream11/odin/proto/gen/go/dream11/od/component/v1"
Expand Down Expand Up @@ -45,12 +46,14 @@ func executeDescribeComponentType(cmd *cobra.Command) {
"version": componentVersion,
}
ctx := cmd.Context()
traceID := util.GenerateTraceID()
response, err := componentClient.DescribeComponentType(&ctx, &comp.DescribeComponentTypeRequest{
ComponentType: componentName,
Params: params,
})
}, traceID)

if err != nil {
log.Info("TraceId: ", traceID)
log.Fatal("Failed to describe service: ", err)
}

Expand Down
5 changes: 4 additions & 1 deletion cmd/describe/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package describe
import (
"encoding/json"
"fmt"
"github.com/dream11/odin/pkg/util"

"github.com/dream11/odin/internal/service"
"github.com/dream11/odin/pkg/constant"
Expand Down Expand Up @@ -36,6 +37,7 @@ func init() {

func executeEnv(cmd *cobra.Command) {
ctx := cmd.Context()
traceID := util.GenerateTraceID()
params := map[string]string{}

if serviceName != "" {
Expand All @@ -47,9 +49,10 @@ func executeEnv(cmd *cobra.Command) {
response, err := environmentClient.DescribeEnvironment(&ctx, &environment.DescribeEnvironmentRequest{
Params: params,
EnvName: name,
})
}, traceID)

if err != nil {
log.Info("TraceId: ", traceID)
log.Fatal("Failed to describe environment ", err)
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/describe/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package describe
import (
"encoding/json"
"fmt"
"github.com/dream11/odin/pkg/util"
"strconv"

serviceBackend "github.com/dream11/odin/internal/service"
Expand Down Expand Up @@ -57,11 +58,12 @@ func execute(cmd *cobra.Command) {
}

ctx := cmd.Context()
traceID := util.GenerateTraceID()
response, err := serviceClient.DescribeService(&ctx, &service.DescribeServiceRequest{
ServiceName: serviceName,
Version: serviceVersion,
Params: params,
})
}, traceID)

if err != nil {
log.Fatal("Failed to describe service: ", err)
Expand Down
4 changes: 3 additions & 1 deletion cmd/list/componentType.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package list
import (
"encoding/json"
"fmt"
"github.com/dream11/odin/pkg/util"

"github.com/dream11/odin/internal/service"
"github.com/dream11/odin/pkg/constant"
Expand Down Expand Up @@ -36,6 +37,7 @@ func init() {

func componentExecute(cmd *cobra.Command) {
ctx := cmd.Context()
traceID := util.GenerateTraceID()
params := make(map[string]string)

// Add non-empty parameters to the map
Expand All @@ -49,7 +51,7 @@ func componentExecute(cmd *cobra.Command) {
// Make the API call with the populated parameters
response, err := componentTypeClient.ListComponentType(&ctx, &component.ListComponentTypeRequest{
Params: params,
})
}, traceID)

if err != nil {
log.Fatal("Failed to list component types ", err)
Expand Down
4 changes: 3 additions & 1 deletion cmd/list/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package list
import (
"encoding/json"
"fmt"
"github.com/dream11/odin/pkg/util"
"strconv"

"github.com/dream11/odin/internal/service"
Expand Down Expand Up @@ -41,13 +42,14 @@ func init() {

func execute(cmd *cobra.Command) {
ctx := cmd.Context()
traceID := util.GenerateTraceID()
response, err := environmentClient.ListEnvironments(&ctx, &environment.ListEnvironmentRequest{
Params: map[string]string{
"name": name,
"account": account,
"provisioningType": provisioningType,
"displayAll": strconv.FormatBool(displayAll)},
})
}, traceID)

if err != nil {
log.Fatal("Failed to list environments ", err)
Expand Down
4 changes: 3 additions & 1 deletion cmd/list/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package list
import (
"encoding/json"
"fmt"
"github.com/dream11/odin/pkg/util"

"github.com/dream11/odin/internal/service"
"github.com/dream11/odin/pkg/constant"
Expand Down Expand Up @@ -36,11 +37,12 @@ func init() {

func listService(cmd *cobra.Command) {
ctx := cmd.Context()
traceID := util.GenerateTraceID()
response, err := serviceClient.ListService(&ctx, &serviceProto.ListServiceRequest{
Name: serviceName,
Version: version,
Tags: tags,
})
}, traceID)

if err != nil {
log.Fatal("Failed to list services ", err)
Expand Down
7 changes: 4 additions & 3 deletions cmd/operate/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package operate

import (
"encoding/json"
"github.com/dream11/odin/pkg/util"

"github.com/dream11/odin/internal/service"
"github.com/dream11/odin/pkg/config"
fileUtil "github.com/dream11/odin/pkg/util"
serviceProto "github.com/dream11/odin/proto/gen/go/dream11/od/service/v1"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -54,6 +54,7 @@ func execute(cmd *cobra.Command) {
env = config.EnsureEnvPresent(env)

ctx := cmd.Context()
traceID := util.GenerateTraceID()
//validate the variables
var optionsData map[string]interface{}

Expand All @@ -65,7 +66,7 @@ func execute(cmd *cobra.Command) {
}

if isFilePresent {
parsedConfig, err := fileUtil.ParseFile(file)
parsedConfig, err := util.ParseFile(file)
if err != nil {
log.Fatal("Error while parsing file " + file + " : " + err.Error())
}
Expand All @@ -89,7 +90,7 @@ func execute(cmd *cobra.Command) {
IsComponentOperation: true,
Operation: operation,
Config: config,
})
}, traceID)

if err != nil {
log.Fatal("Failed to operate on component", err)
Expand Down
7 changes: 4 additions & 3 deletions cmd/operate/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package operate

import (
"encoding/json"
"github.com/dream11/odin/pkg/util"

"github.com/dream11/odin/internal/service"
"github.com/dream11/odin/pkg/config"
fileUtil "github.com/dream11/odin/pkg/util"
serviceProto "github.com/dream11/odin/proto/gen/go/dream11/od/service/v1"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -44,6 +44,7 @@ func executeOperateService(cmd *cobra.Command) {
env = config.EnsureEnvPresent(env)

ctx := cmd.Context()
traceID := util.GenerateTraceID()
//validate the variables
var optionsData map[string]interface{}

Expand All @@ -55,7 +56,7 @@ func executeOperateService(cmd *cobra.Command) {
}

if isFilePresent {
parsedConfig, err := fileUtil.ParseFile(file)
parsedConfig, err := util.ParseFile(file)
if err != nil {
log.Fatal("Error while parsing file " + file + " : " + err.Error())
}
Expand All @@ -78,7 +79,7 @@ func executeOperateService(cmd *cobra.Command) {
IsComponentOperation: false,
Operation: operation,
Config: config,
})
}, traceID)

if err != nil {
log.Fatal("Failed to operate on service", err)
Expand Down
4 changes: 3 additions & 1 deletion cmd/release/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package release

import (
"encoding/json"
"github.com/dream11/odin/pkg/util"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -38,6 +39,7 @@ func init() {

func execute(cmd *cobra.Command) {
ctx := cmd.Context()
traceID := util.GenerateTraceID()

var err error

Expand Down Expand Up @@ -102,7 +104,7 @@ func execute(cmd *cobra.Command) {
}
serviceReleaseRequest.ProvisioningConfigs = provisioningConfigMap
serviceReleaseRequest.ServiceDefinition = &definitionProto
err = serviceClient.ReleaseService(&ctx, &serviceReleaseRequest)
err = serviceClient.ReleaseService(&ctx, &serviceReleaseRequest, traceID)
if err != nil {
log.Fatal("Failed to release service ", err)
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/undeploy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package undeploy
import (
"github.com/dream11/odin/internal/service"
"github.com/dream11/odin/pkg/config"
"github.com/dream11/odin/pkg/util"
serviceProto "github.com/dream11/odin/proto/gen/go/dream11/od/service/v1"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -39,11 +40,12 @@ func execute(cmd *cobra.Command) {
envName = config.EnsureEnvPresent(envName)

ctx := cmd.Context()
traceID := util.GenerateTraceID()

err := serviceClient.UndeployService(&ctx, &serviceProto.UndeployServiceRequest{
EnvName: envName,
ServiceName: name,
})
}, traceID)

if err != nil {
log.Fatal("Failed to undeploy service ", err)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.17

require (
github.com/briandowns/spinner v1.23.0
github.com/google/uuid v1.3.0
github.com/olekukonko/tablewriter v0.0.5
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ github.com/google/s2a-go v0.1.0/go.mod h1:OJpEgntRZo8ugHpF9hkoLJbS5dSI20XZeXJ9JV
github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8=
github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8=
Expand Down
Loading
Loading