Skip to content

Commit

Permalink
fix: nil check main (#5276)
Browse files Browse the repository at this point in the history
* fix: nil pointer error

* style: address code review comment
  • Loading branch information
vLia committed Apr 4, 2024
1 parent e515775 commit 6453592
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions pkg/tcl/apitcl/v1/testworkflowmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ func (s *apiTCL) sendCreateWorkflowTelemetry(ctx context.Context, workflow *test
}

var dataSource string
if len(workflow.Spec.Content.Files) != 0 {
dataSource = "files"
} else if workflow.Spec.Content.Git != nil {
dataSource = "git"
isKubeshopGitURI := false
if workflow.Spec.Content != nil {
if len(workflow.Spec.Content.Files) != 0 {
dataSource = "files"
} else if workflow.Spec.Content.Git != nil {
dataSource = "git"
if strings.Contains(workflow.Spec.Content.Git.Uri, "kubeshop") {
isKubeshopGitURI = true
}
}
}

hasArtifacts := false
Expand All @@ -54,13 +60,6 @@ func (s *apiTCL) sendCreateWorkflowTelemetry(ctx context.Context, workflow *test
image = workflow.Spec.Container.Image
}

isKubeshopGitURI := false
if workflow.Spec.Content != nil && workflow.Spec.Content.Git != nil {
if strings.Contains(workflow.Spec.Content.Git.Uri, "kubeshop") {
isKubeshopGitURI = true
}
}

out, err := telemetry.SendCreateWorkflowEvent("testkube_api_create_test_workflow", telemetry.CreateWorkflowParams{
CreateParams: telemetry.CreateParams{
AppVersion: version.Version,
Expand Down Expand Up @@ -107,10 +106,16 @@ func (s *apiTCL) sendCreateWorkflowTemplateTelemetry(ctx context.Context, templa
}

var dataSource string
if template.Spec.Content != nil && len(template.Spec.Content.Files) != 0 {
dataSource = "files"
} else if template.Spec.Content.Git != nil {
dataSource = "git"
isKubeshopGitURI := false
if template.Spec.Content != nil {
if len(template.Spec.Content.Files) != 0 {
dataSource = "files"
} else if template.Spec.Content.Git != nil {
dataSource = "git"
if strings.Contains(template.Spec.Content.Git.Uri, "kubeshop") {
isKubeshopGitURI = true
}
}
}

hasArtifacts := false
Expand All @@ -126,13 +131,6 @@ func (s *apiTCL) sendCreateWorkflowTemplateTelemetry(ctx context.Context, templa
image = template.Spec.Container.Image
}

isKubeshopGitURI := false
if template.Spec.Content != nil && template.Spec.Content.Git != nil {
if strings.Contains(template.Spec.Content.Git.Uri, "kubeshop") {
isKubeshopGitURI = true
}
}

out, err := telemetry.SendCreateWorkflowEvent("testkube_api_create_test_workflow_template", telemetry.CreateWorkflowParams{
CreateParams: telemetry.CreateParams{
AppVersion: version.Version,
Expand Down Expand Up @@ -178,10 +176,16 @@ func (s *apiTCL) sendRunWorkflowTelemetry(ctx context.Context, workflow *testwor
}

var dataSource string
if len(workflow.Spec.Content.Files) != 0 {
dataSource = "files"
} else if workflow.Spec.Content.Git != nil {
dataSource = "git"
isKubeshopGitURI := false
if workflow.Spec.Content != nil {
if len(workflow.Spec.Content.Files) != 0 {
dataSource = "files"
} else if workflow.Spec.Content.Git != nil {
dataSource = "git"
if strings.Contains(workflow.Spec.Content.Git.Uri, "kubeshop") {
isKubeshopGitURI = true
}
}
}

hasArtifacts := false
Expand All @@ -196,12 +200,6 @@ func (s *apiTCL) sendRunWorkflowTelemetry(ctx context.Context, workflow *testwor
if workflow.Spec.Container != nil {
image = workflow.Spec.Container.Image
}
isKubeshopGitURI := false
if workflow.Spec.Content != nil && workflow.Spec.Content.Git != nil {
if strings.Contains(workflow.Spec.Content.Git.Uri, "kubeshop") {
isKubeshopGitURI = true
}
}

out, err := telemetry.SendRunWorkflowEvent("testkube_api_run_test_workflow", telemetry.RunWorkflowParams{
RunParams: telemetry.RunParams{
Expand Down

0 comments on commit 6453592

Please sign in to comment.