Skip to content

Commit

Permalink
Merge pull request #2090 from opengovern/fix-add-linode
Browse files Browse the repository at this point in the history
fix: fix sample data loaded check
  • Loading branch information
artaasadi authored Dec 1, 2024
2 parents 1f730dd + 2e22cda commit 7518088
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
1 change: 1 addition & 0 deletions services/integration/api/models/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const (
IntegrationStateActive IntegrationState = "ACTIVE"
IntegrationStateInactive IntegrationState = "INACTIVE"
IntegrationStateArchived IntegrationState = "ARCHIVED"
IntegrationStateSample IntegrationState = "SAMPLE_INTEGRATION"
)

type DiscoverIntegrationRequest struct {
Expand Down
33 changes: 5 additions & 28 deletions services/metadata/http_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,37 +852,14 @@ func (h HttpHandler) SampleDataLoaded(echoCtx echo.Context) (bool, error) {
return false, echo.NewHTTPError(http.StatusInternalServerError, "failed to list integrations")
}

integrationChecks := strings.Split(h.cfg.SampledataIntegrationsCheck, ",")
integrationsMap := make(map[string]bool)
for _, c := range integrationChecks {
integrationsMap[c] = true
}

credentials, err := integrationClient.ListCredentials(ctx)
if err != nil {
h.logger.Error("failed to list credentials", zap.Error(err))
return false, echo.NewHTTPError(http.StatusInternalServerError, "failed to list credentials")
}
credentialsMap := make(map[string]bool)
for _, c := range credentials.Credentials {
credentialsMap[c.ID] = true
}

if len(integrations.Integrations) == 0 {
return false, nil
}

for _, c := range integrations.Integrations {
if _, ok := integrationsMap[c.IntegrationID]; !ok {
return false, nil
} else {
if _, ok2 := credentialsMap[c.CredentialID]; ok2 {
return false, nil
}
loaded := false
for _, integration := range integrations.Integrations {
if integration.State == integrationApi.IntegrationStateSample {
loaded = true
}
}

return true, nil
return loaded, nil
}

// VaultConfigured godoc
Expand Down

0 comments on commit 7518088

Please sign in to comment.