diff --git a/go.mod b/go.mod index 331f362b1..2ee9a581c 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( github.com/lib/pq v1.10.9 github.com/nats-io/nats.go v1.36.0 github.com/open-policy-agent/opa v0.69.0 - github.com/opengovern/og-util v1.10.1 + github.com/opengovern/og-util v1.11.0 github.com/opensearch-project/opensearch-go/v2 v2.3.0 github.com/opensearch-project/opensearch-go/v4 v4.2.0 github.com/ory/dockertest/v3 v3.10.0 diff --git a/go.sum b/go.sum index d18ea9546..f7713e2f8 100644 --- a/go.sum +++ b/go.sum @@ -1001,6 +1001,8 @@ github.com/opengovern/og-util v1.10.0 h1:Fj3GIl9fpLzoWUwVbZsZ4pc6wlV8SZj5PIfL8wX github.com/opengovern/og-util v1.10.0/go.mod h1:9uNpGalixRoQkUzPPBdT+JG1epg8FTRx/qmkfTyUZHE= github.com/opengovern/og-util v1.10.1 h1:D51GVWKI1J1d9v50z6Eg4gG0Q79+aFLGrxe4ynJCAck= github.com/opengovern/og-util v1.10.1/go.mod h1:9uNpGalixRoQkUzPPBdT+JG1epg8FTRx/qmkfTyUZHE= +github.com/opengovern/og-util v1.11.0 h1:Amct1bHXDF5TBnymstPUEWpWaC+Lji5dnJ8Mr6fkbMA= +github.com/opengovern/og-util v1.11.0/go.mod h1:9uNpGalixRoQkUzPPBdT+JG1epg8FTRx/qmkfTyUZHE= github.com/opensearch-project/opensearch-go/v2 v2.3.0 h1:nQIEMr+A92CkhHrZgUhcfsrZjibvB3APXf2a1VwCmMQ= github.com/opensearch-project/opensearch-go/v2 v2.3.0/go.mod h1:8LDr9FCgUTVoT+5ESjc2+iaZuldqE+23Iq0r1XeNue8= github.com/opensearch-project/opensearch-go/v4 v4.2.0 h1:uaBexfVdeSU15yOUPYF+IY059koVP0oNQPyoSde6N/A= diff --git a/services/integration/api/integration-types/api.go b/services/integration/api/integration-types/api.go index 9c65b292d..699256901 100644 --- a/services/integration/api/integration-types/api.go +++ b/services/integration/api/integration-types/api.go @@ -67,7 +67,10 @@ func (a *API) GetResourceTypeFromTableName(c echo.Context) error { rtMap := a.typeManager.GetIntegrationTypeMap() if value, ok := rtMap[a.typeManager.ParseType(integrationType)]; ok { - resourceType := value.GetResourceTypeFromTableName(tableName) + resourceType, err := value.GetResourceTypeFromTableName(tableName) + if err != nil { + return echo.NewHTTPError(500, err.Error()) + } if resourceType != "" { res := models.GetResourceTypeFromTableNameResponse{ ResourceType: resourceType, @@ -96,7 +99,12 @@ func (a *API) GetConfiguration(c echo.Context) error { rtMap := a.typeManager.GetIntegrationTypeMap() if value, ok := rtMap[a.typeManager.ParseType(integrationType)]; ok { - return c.JSON(200, value.GetConfiguration()) + conf, err := value.GetConfiguration() + if err != nil { + return echo.NewHTTPError(500, err.Error()) + } + + return c.JSON(200, conf) } else { return echo.NewHTTPError(404, "integration type not found") } @@ -156,7 +164,10 @@ func (a *API) ListTables(c echo.Context) error { rtMap := a.typeManager.GetIntegrationTypeMap() if value, ok := rtMap[a.typeManager.ParseType(integrationType)]; ok { - tables := value.ListAllTables() + tables, err := value.ListAllTables() + if err != nil { + return echo.NewHTTPError(500, err.Error()) + } return c.JSON(200, models.ListTablesResponse{Tables: tables}) } else { return echo.NewHTTPError(404, "integration type not found") diff --git a/services/integration/api/integrations/api.go b/services/integration/api/integrations/api.go index 8c93c2889..98dbd5b56 100644 --- a/services/integration/api/integrations/api.go +++ b/services/integration/api/integrations/api.go @@ -1098,7 +1098,11 @@ func (h API) GetIntegrationTypeUiSpec(c echo.Context) error { if !ok { return echo.NewHTTPError(http.StatusNotFound, "invalid integration type") } - cnf := integrationType.GetConfiguration() + cnf, err := integrationType.GetConfiguration() + if err != nil { + h.logger.Error("failed to get configuration", zap.Error(err)) + return echo.NewHTTPError(http.StatusInternalServerError, "failed to get configuration") + } var result interface{} if err := json.Unmarshal(cnf.UISpec, &result); err != nil { @@ -1170,7 +1174,11 @@ func (h API) DisableIntegrationType(c echo.Context) error { if !ok { return echo.NewHTTPError(http.StatusNotFound, "invalid integration type") } - cnf := integrationType.GetConfiguration() + cnf, err := integrationType.GetConfiguration() + if err != nil { + h.logger.Error("failed to get configuration", zap.Error(err)) + return echo.NewHTTPError(http.StatusInternalServerError, "failed to get configuration"+err.Error()) + } // Scheduled deployment var describerDeployment appsv1.Deployment @@ -1320,7 +1328,11 @@ func (h API) UpgradeIntegrationType(c echo.Context) error { if !ok { return echo.NewHTTPError(http.StatusNotFound, "invalid integration type") } - cnf := integrationType.GetConfiguration() + cnf, err := integrationType.GetConfiguration() + if err != nil { + h.logger.Error("failed to get configuration", zap.Error(err)) + return echo.NewHTTPError(http.StatusInternalServerError, "failed to get configuration") + } integrationTypeInfo, err := h.database.GetIntegrationType(integrationTypeName) if err != nil { @@ -1464,7 +1476,11 @@ func (h API) EnableIntegrationTypeHelper(ctx context.Context, logger *zap.Logger if !ok { return echo.NewHTTPError(http.StatusNotFound, "invalid integration type") } - cnf := integrationType.GetConfiguration() + cnf, err := integrationType.GetConfiguration() + if err != nil { + logger.Error("failed to get integration type configuration", zap.Error(err)) + return echo.NewHTTPError(http.StatusInternalServerError, "failed to get integration type configuration") + } describerDeployment.ObjectMeta.Name = cnf.DescriberDeploymentName describerDeployment.ObjectMeta.Namespace = currentNamespace diff --git a/services/integration/integration-type/aws-account/aws_account.go b/services/integration/integration-type/aws-account/aws_account.go index 3d9b02f24..9c2c4c487 100644 --- a/services/integration/integration-type/aws-account/aws_account.go +++ b/services/integration/integration-type/aws-account/aws_account.go @@ -16,7 +16,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -30,7 +30,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberDeploymentName: configs.DescriberDeploymentName, DescriberRunCommand: configs.DescriberRunCommand, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, providerId string, labels map[string]string, annotations map[string]string) (bool, error) { @@ -117,17 +117,21 @@ func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[st return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil +} + +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationTypeAwsCloudAccount, nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationTypeAwsCloudAccount +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) Ping() error { + return nil } diff --git a/services/integration/integration-type/azure-subscription/azure_subscription.go b/services/integration/integration-type/azure-subscription/azure_subscription.go index 9a67bead7..bb86c3392 100644 --- a/services/integration/integration-type/azure-subscription/azure_subscription.go +++ b/services/integration/integration-type/azure-subscription/azure_subscription.go @@ -11,7 +11,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -25,7 +25,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberDeploymentName: configs.DescriberDeploymentName, DescriberRunCommand: configs.DescriberRunCommand, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, providerId string, labels map[string]string, annotations map[string]string) (bool, error) { @@ -83,18 +83,22 @@ func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[st return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil +} + +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationTypeAzureSubscription, nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationTypeAzureSubscription +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) Ping() error { + return nil } diff --git a/services/integration/integration-type/cloudflare-account/cloudflare_account.go b/services/integration/integration-type/cloudflare-account/cloudflare_account.go index 99b8a3fef..87b245578 100644 --- a/services/integration/integration-type/cloudflare-account/cloudflare_account.go +++ b/services/integration/integration-type/cloudflare-account/cloudflare_account.go @@ -12,7 +12,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -26,7 +26,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberRunCommand: configs.DescriberRunCommand, DescriberDeploymentName: configs.DescriberDeploymentName, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, providerId string, labels map[string]string, annotations map[string]string) (bool, error) { @@ -82,18 +82,22 @@ func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[st return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil +} + +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationNameCloudflareAccount, nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationNameCloudflareAccount +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) Ping() error { + return nil } diff --git a/services/integration/integration-type/cohereai-project/cohere_project.go b/services/integration/integration-type/cohereai-project/cohere_project.go index f1f5d8ae3..ece4a38e9 100644 --- a/services/integration/integration-type/cohereai-project/cohere_project.go +++ b/services/integration/integration-type/cohereai-project/cohere_project.go @@ -12,7 +12,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -26,7 +26,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberDeploymentName: configs.DescriberDeploymentName, DescriberRunCommand: configs.DescriberRunCommand, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, providerId string, labels map[string]string, annotations map[string]string) (bool, error) { @@ -86,18 +86,22 @@ func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[st return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil +} + +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationTypeCohereaiProject, nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationTypeCohereaiProject +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) Ping() error { + return nil } diff --git a/services/integration/integration-type/digitalocean-team/digitalocean-team.go b/services/integration/integration-type/digitalocean-team/digitalocean-team.go index d980d7e45..3ec292831 100644 --- a/services/integration/integration-type/digitalocean-team/digitalocean-team.go +++ b/services/integration/integration-type/digitalocean-team/digitalocean-team.go @@ -12,7 +12,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -26,7 +26,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberDeploymentName: configs.DescriberDeploymentName, DescriberRunCommand: configs.DescriberRunCommand, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, _ string, _ map[string]string, _ map[string]string) (bool, error) { @@ -71,18 +71,22 @@ func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[st return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil +} + +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationTypeDigitalOceanTeam, nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationTypeDigitalOceanTeam +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) Ping() error { + return nil } diff --git a/services/integration/integration-type/doppler-account/doppler_account.go b/services/integration/integration-type/doppler-account/doppler_account.go index 3baead3c0..7181d2e59 100644 --- a/services/integration/integration-type/doppler-account/doppler_account.go +++ b/services/integration/integration-type/doppler-account/doppler_account.go @@ -12,7 +12,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -26,7 +26,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberDeploymentName: configs.DescriberDeploymentName, DescriberRunCommand: configs.DescriberRunCommand, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, providerId string, labels map[string]string, annotations map[string]string) (bool, error) { @@ -81,17 +81,21 @@ func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[st return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil +} + +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationTypeDopplerAccount, nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationTypeDopplerAccount +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) Ping() error { + return nil } diff --git a/services/integration/integration-type/entra-id-directory/entra_id_directory.go b/services/integration/integration-type/entra-id-directory/entra_id_directory.go index eefccb76f..ad4042760 100644 --- a/services/integration/integration-type/entra-id-directory/entra_id_directory.go +++ b/services/integration/integration-type/entra-id-directory/entra_id_directory.go @@ -11,7 +11,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -25,7 +25,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberDeploymentName: configs.DescriberDeploymentName, DescriberRunCommand: configs.DescriberRunCommand, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, providerId string, labels map[string]string, annotations map[string]string) (bool, error) { @@ -82,17 +82,21 @@ func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[st return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil +} +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationTypeEntraidDirectory, nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationTypeEntraidDirectory + +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) Ping() error { + return nil } diff --git a/services/integration/integration-type/google-workspace-account/google_workspace_account.go b/services/integration/integration-type/google-workspace-account/google_workspace_account.go index 87567ebca..7152abe65 100644 --- a/services/integration/integration-type/google-workspace-account/google_workspace_account.go +++ b/services/integration/integration-type/google-workspace-account/google_workspace_account.go @@ -12,7 +12,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -26,7 +26,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberDeploymentName: configs.DescriberDeploymentName, DescriberRunCommand: configs.DescriberRunCommand, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, providerId string, labels map[string]string, annotations map[string]string) (bool, error) { @@ -84,18 +84,22 @@ func (i *Integration) GetResourceTypesByLabels(map[string]string) (map[string]in return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil +} + +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationTypeGoogleWorkspaceAccount, nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationTypeGoogleWorkspaceAccount +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) Ping() error { + return nil } diff --git a/services/integration/integration-type/integrations.go b/services/integration/integration-type/integrations.go index c8da2584a..3c0b8ea8e 100644 --- a/services/integration/integration-type/integrations.go +++ b/services/integration/integration-type/integrations.go @@ -125,7 +125,14 @@ func NewIntegrationTypeManager(logger *zap.Logger, integrationTypeDb *gorm.DB) * continue } - integrationTypes[itInterface.GetIntegrationType()] = itInterface + iType, err := itInterface.GetIntegrationType() + if err != nil { + logger.Error("failed to get integration type from plugin", zap.Error(err)) + client.Kill() + continue + } + + integrationTypes[iType] = itInterface } return &IntegrationTypeManager{ diff --git a/services/integration/integration-type/linode-account/linode_account.go b/services/integration/integration-type/linode-account/linode_account.go index d2b3b7438..866294e62 100644 --- a/services/integration/integration-type/linode-account/linode_account.go +++ b/services/integration/integration-type/linode-account/linode_account.go @@ -12,7 +12,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -26,7 +26,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberDeploymentName: configs.DescriberDeploymentName, DescriberRunCommand: configs.DescriberRunCommand, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, providerId string, labels map[string]string, annotations map[string]string) (bool, error) { @@ -80,18 +80,22 @@ func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[st return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil +} + +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationTypeLinodeProject, nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationTypeLinodeProject +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) Ping() error { + return nil } diff --git a/services/integration/integration-type/oci-repository/oci-repository.go b/services/integration/integration-type/oci-repository/oci-repository.go index 10f558d23..9d236747e 100644 --- a/services/integration/integration-type/oci-repository/oci-repository.go +++ b/services/integration/integration-type/oci-repository/oci-repository.go @@ -12,7 +12,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -26,7 +26,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberDeploymentName: configs.DescriberDeploymentName, DescriberRunCommand: configs.DescriberRunCommand, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, _ string, _ map[string]string, _ map[string]string) (bool, error) { @@ -110,18 +110,22 @@ func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[st return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil +} + +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationTypeOciRepository, nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationTypeOciRepository +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) Ping() error { + return nil } diff --git a/services/integration/integration-type/openai-integration/openai_integration.go b/services/integration/integration-type/openai-integration/openai_integration.go index 12f7f5ff4..d13243007 100644 --- a/services/integration/integration-type/openai-integration/openai_integration.go +++ b/services/integration/integration-type/openai-integration/openai_integration.go @@ -13,7 +13,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -27,7 +27,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberDeploymentName: configs.DescriberDeploymentName, DescriberRunCommand: configs.DescriberRunCommand, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, providerId string, labels map[string]string, annotations map[string]string) (bool, error) { @@ -82,16 +82,16 @@ func (i *Integration) GetResourceTypesByLabels(labels map[string]string) (map[st return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationTypeOpenaiIntegration +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationTypeOpenaiIntegration, nil } func hashSHA256(input string) string { @@ -103,6 +103,10 @@ func hashSHA256(input string) string { return hex.EncodeToString(hashedBytes) } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil +} + +func (i *Integration) Ping() error { + return nil } diff --git a/services/integration/integration-type/render-account/render_account.go b/services/integration/integration-type/render-account/render_account.go index 3230067f2..aeb4f98ae 100644 --- a/services/integration/integration-type/render-account/render_account.go +++ b/services/integration/integration-type/render-account/render_account.go @@ -11,7 +11,7 @@ import ( type Integration struct{} -func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { +func (i *Integration) GetConfiguration() (interfaces.IntegrationConfiguration, error) { return interfaces.IntegrationConfiguration{ NatsScheduledJobsTopic: configs.JobQueueTopic, NatsManualJobsTopic: configs.JobQueueTopicManuals, @@ -25,7 +25,7 @@ func (i *Integration) GetConfiguration() interfaces.IntegrationConfiguration { DescriberDeploymentName: configs.DescriberDeploymentName, DescriberRunCommand: configs.DescriberRunCommand, - } + }, nil } func (i *Integration) HealthCheck(jsonData []byte, providerId string, labels map[string]string, annotations map[string]string) (bool, error) { @@ -66,18 +66,22 @@ func (i *Integration) GetResourceTypesByLabels(map[string]string) (map[string]in return resourceTypesMap, nil } -func (i *Integration) GetResourceTypeFromTableName(tableName string) string { +func (i *Integration) GetResourceTypeFromTableName(tableName string) (string, error) { if v, ok := configs.TablesToResourceTypes[tableName]; ok { - return v + return v, nil } - return "" + return "", nil +} + +func (i *Integration) GetIntegrationType() (integration.Type, error) { + return configs.IntegrationTypeRenderAccount, nil } -func (i *Integration) GetIntegrationType() integration.Type { - return configs.IntegrationTypeRenderAccount +func (i *Integration) ListAllTables() (map[string][]interfaces.CloudQLColumn, error) { + return make(map[string][]interfaces.CloudQLColumn), nil } -func (i *Integration) ListAllTables() map[string][]interfaces.CloudQLColumn { - return make(map[string][]interfaces.CloudQLColumn) +func (i *Integration) Ping() error { + return nil }