Skip to content

Commit

Permalink
Merge pull request #1951 from opengovern/fix-web-ui
Browse files Browse the repository at this point in the history
fix: fix ListCredentials client api
  • Loading branch information
artaasadi authored Nov 12, 2024
2 parents 298e931 + 62ff6ba commit 8ee9f74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pkg/metadata/http_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ func (h HttpHandler) SampleDataLoaded(echoCtx echo.Context) (bool, error) {

integrations, err := integrationClient.ListIntegrations(ctx, nil)
if err != nil {
h.logger.Error("failed to list integrations", zap.Error(err))
return false, echo.NewHTTPError(http.StatusInternalServerError, "failed to list integrations")
}

Expand All @@ -868,10 +869,11 @@ func (h HttpHandler) SampleDataLoaded(echoCtx echo.Context) (bool, error) {

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 {
for _, c := range credentials.Credentials {
credentialsMap[c.ID] = true
}

Expand Down
6 changes: 3 additions & 3 deletions services/integration/client/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type IntegrationServiceClient interface {
ListIntegrationsByFilters(ctx *httpclient.Context, req models.ListIntegrationsRequest) (*models.ListIntegrationsResponse, error)
IntegrationHealthcheck(ctx *httpclient.Context, integrationID string) (*models.Integration, error)
GetCredential(ctx *httpclient.Context, credentialID string) (*models.Credential, error)
ListCredentials(ctx *httpclient.Context) ([]models.Credential, error)
ListCredentials(ctx *httpclient.Context) (models.ListCredentialsResponse, error)
GetIntegrationGroup(ctx *httpclient.Context, integrationGroupName string) (*models.IntegrationGroup, error)
ListIntegrationGroups(ctx *httpclient.Context) ([]models.IntegrationGroup, error)
}
Expand Down Expand Up @@ -96,9 +96,9 @@ func (c *integrationClient) GetCredential(ctx *httpclient.Context, credentialID
return response, nil
}

func (c *integrationClient) ListCredentials(ctx *httpclient.Context) ([]models.Credential, error) {
func (c *integrationClient) ListCredentials(ctx *httpclient.Context) (models.ListCredentialsResponse, error) {
url := fmt.Sprintf("%s/api/v1/credentials", c.baseURL)
var response []models.Credential
var response models.ListCredentialsResponse

if statusCode, err := httpclient.DoRequest(ctx.Ctx, http.MethodGet, url, ctx.ToHeaders(), nil, &response); err != nil {
if 400 <= statusCode && statusCode < 500 {
Expand Down

0 comments on commit 8ee9f74

Please sign in to comment.