-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: integrations view * chore: address review comments
- Loading branch information
1 parent
987e8c5
commit 65b6c29
Showing
10 changed files
with
153 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package models | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/google/uuid" | ||
) | ||
|
||
type IntegrationType string | ||
|
||
const ( | ||
IntegrationTypeScraper IntegrationType = "scrapers" | ||
IntegrationTypeLoggingBackends IntegrationType = "logging_backends" | ||
IntegrationTypeTopology IntegrationType = "topology" | ||
) | ||
|
||
type Integration struct { | ||
ID uuid.UUID `json:"id"` | ||
Name string `json:"name"` | ||
Description string `json:"description"` | ||
Integration IntegrationType `json:"integration"` | ||
Source string `json:"source"` | ||
AgentID *uuid.UUID `json:"agent_id,omitempty"` | ||
CreatedAt time.Time `json:"created_at"` | ||
UpdatedAt time.Time `json:"updated_at"` | ||
DeletedAt *time.Time `json:"deleted_at,omitempty"` | ||
CreatedBy *uuid.UUID `json:"created_by,omitempty"` | ||
JobName string `json:"job_name"` | ||
JobSuccess int `json:"job_success_count"` | ||
JobError int `json:"job_error_count"` | ||
JobDetails string `json:"job_details"` | ||
JobHostname string `json:"job_hostname"` | ||
JobDuration int `json:"job_duration_millis"` | ||
JobResource string `json:"job_resource_type"` | ||
JobStatus string `json:"job_status"` | ||
JobTimeStart time.Time `json:"job_time_start"` | ||
JobTimeEnd time.Time `json:"job_time_end"` | ||
JobCreatedAt time.Time `json:"job_created_at"` | ||
} | ||
|
||
func (t *Integration) TableName() string { | ||
return "integrations_with_status" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ const ( | |
SourceCRD = "KubernetesCRD" | ||
SourceConfigFile = "ConfigFile" | ||
SourceUI = "UI" | ||
SourceTopology = "Topology" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package tests | ||
|
||
import ( | ||
"github.com/flanksource/duty/models" | ||
"github.com/flanksource/duty/testutils" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Integration view", func() { | ||
It("should be able to call integrations view", func() { | ||
var integrations []models.Integration | ||
err := testutils.DefaultContext.DB().Find(&integrations).Error | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(len(integrations)).To(BeNumerically(">", 0)) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
CREATE | ||
OR REPLACE VIEW integrations_with_status AS | ||
SELECT | ||
id, | ||
NAME, | ||
description, | ||
'scrapers' AS integration_type, | ||
source, | ||
agent_id, | ||
created_at, | ||
updated_at, | ||
deleted_at, | ||
created_by, | ||
job_name, | ||
job_success_count, | ||
job_error_count, | ||
job_details, | ||
job_hostname, | ||
job_duration_millis, | ||
job_resource_type, | ||
job_status, | ||
job_time_start, | ||
job_time_end, | ||
job_created_at | ||
FROM | ||
config_scrapers_with_status | ||
UNION | ||
SELECT | ||
id, | ||
NAME, | ||
'', | ||
'topologies' AS integration_type, | ||
source, | ||
agent_id, | ||
created_at, | ||
updated_at, | ||
deleted_at, | ||
created_by, | ||
job_name, | ||
job_success_count, | ||
job_error_count, | ||
job_details, | ||
job_hostname, | ||
job_duration_millis, | ||
job_resource_type, | ||
job_status, | ||
job_time_start, | ||
job_time_end, | ||
job_created_at | ||
FROM | ||
topologies_with_status | ||
UNION | ||
SELECT | ||
id, | ||
NAME, | ||
'', | ||
'logging_backends' AS integration_type, | ||
source, | ||
agent_id, | ||
created_at, | ||
updated_at, | ||
deleted_at, | ||
created_by, | ||
'', | ||
0, | ||
0, | ||
NULL, | ||
'', | ||
0, | ||
NULL, | ||
'', | ||
NULL, | ||
NULL, | ||
NULL | ||
FROM | ||
logging_backends; |