Skip to content

Commit

Permalink
fix(*): fixes after releases on staging
Browse files Browse the repository at this point in the history
Multiple fixes:
- Since gorelease is not using earthly, we need
to have the list.go already filled before releasing.
I added it in the lint/pre-commit method on earthly,
so that the CI fails if not up to date.
- Remove a useless temporal search attributes
- Do the right translation of connectors for v2
  • Loading branch information
paul-nicolas committed Dec 18, 2024
1 parent c54d2c1 commit d16c439
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ lint:
COPY --pass-args +tidy/go.* .
WORKDIR /src
DO --pass-args core+GO_LINT
COPY (+compile-plugins/list.go) .
SAVE ARTIFACT cmd AS LOCAL cmd
SAVE ARTIFACT internal AS LOCAL internal
SAVE ARTIFACT pkg AS LOCAL pkg
SAVE ARTIFACT main.go AS LOCAL main.go
SAVE ARTIFACT list.go AS LOCAL internal/connectors/plugins/public/list.go

pre-commit:
WAIT
Expand Down
5 changes: 3 additions & 2 deletions internal/api/v2/handler_connectors_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ func connectorsInstall(backend backend.Backend) http.HandlerFunc {
ctx, span := otel.Tracer().Start(r.Context(), "v2_connectorsInstall")
defer span.End()

span.SetAttributes(attribute.String("provider", connectorProvider(r)))
provider := strings.ToLower(connectorProvider(r))
provider := strings.ToLower(toV3Provider(connectorProvider(r)))

span.SetAttributes(attribute.String("provider", provider))
if provider == "" {
otel.RecordError(span, errors.New("provider is required"))
api.BadRequest(w, ErrValidation, errors.New("provider is required"))
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v2/handler_connectors_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func connectorsList(backend backend.Backend) http.HandlerFunc {
data := make([]*connectorsListElement, len(connectors.Data))
for i := range connectors.Data {
data[i] = &connectorsListElement{
Provider: connectors.Data[i].Provider,
Provider: v3ProviderToV2(connectors.Data[i].Provider),
ConnectorID: connectors.Data[i].ID.String(),
Name: connectors.Data[i].Name,
ScheduledForDeletion: connectors.Data[i].ScheduledForDeletion,
Expand Down
72 changes: 72 additions & 0 deletions internal/api/v2/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,75 @@ func getPagination[T any](span trace.Span, r *http.Request, options T) (*bunpagi

return pointer.For(bunpaginate.NewPaginatedQueryOptions(options).WithQueryBuilder(qb).WithPageSize(pageSize)), nil
}

const (
ConnectorStripe string = "STRIPE"
ConnectorDummyPay string = "DUMMY-PAY"
ConnectorWise string = "WISE"
ConnectorModulr string = "MODULR"
ConnectorCurrencyCloud string = "CURRENCY-CLOUD"
ConnectorBankingCircle string = "BANKING-CIRCLE"
ConnectorMangopay string = "MANGOPAY"
ConnectorMoneycorp string = "MONEYCORP"
ConnectorAtlar string = "ATLAR"
ConnectorAdyen string = "ADYEN"
ConnectorGeneric string = "GENERIC"
)

func v3ProviderToV2(provider string) string {
switch provider {
case "adyen":
return ConnectorAdyen
case "atlar":
return ConnectorAdyen
case "bankingcircle":
return ConnectorBankingCircle
case "currencycloud":
return ConnectorCurrencyCloud
case "dummypay":
return ConnectorDummyPay
case "generic":
return ConnectorGeneric
case "mangopay":
return ConnectorMangopay
case "modulr":
return ConnectorModulr
case "moneycorp":
return ConnectorMoneycorp
case "stripe":
return ConnectorStripe
case "wise":
return ConnectorWise
default:
return provider
}
}

func toV3Provider(provider string) string {
switch provider {
case ConnectorAdyen:
return "adyen"
case ConnectorAtlar:
return "atlar"
case ConnectorBankingCircle:
return "bankingcircle"
case ConnectorCurrencyCloud:
return "currencycloud"
case ConnectorDummyPay:
return "dummypay"
case ConnectorGeneric:
return "generic"
case ConnectorMangopay:
return "mangopay"
case ConnectorModulr:
return "modulr"
case ConnectorMoneycorp:
return "moneycorp"
case ConnectorStripe:
return "stripe"
case ConnectorWise:
return "wise"
default:
return provider
}
}
1 change: 0 additions & 1 deletion internal/connectors/engine/search_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

var (
SearchAttributes = map[string]enums.IndexedValueType{
workflow.SearchAttributeWorkflowID: enums.INDEXED_VALUE_TYPE_KEYWORD,
workflow.SearchAttributeScheduleID: enums.INDEXED_VALUE_TYPE_KEYWORD,
workflow.SearchAttributeStack: enums.INDEXED_VALUE_TYPE_KEYWORD,
}
Expand Down
1 change: 0 additions & 1 deletion internal/connectors/engine/workflow/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
)

const (
SearchAttributeWorkflowID = "PaymentWorkflowID"
SearchAttributeScheduleID = "PaymentScheduleID"
SearchAttributeStack = "Stack"
)
Expand Down
14 changes: 14 additions & 0 deletions internal/connectors/plugins/public/list.go
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
package public

import (
_ "github.com/formancehq/payments/internal/connectors/plugins/public/adyen"
_ "github.com/formancehq/payments/internal/connectors/plugins/public/atlar"
_ "github.com/formancehq/payments/internal/connectors/plugins/public/bankingcircle"
_ "github.com/formancehq/payments/internal/connectors/plugins/public/currencycloud"
_ "github.com/formancehq/payments/internal/connectors/plugins/public/dummypay"
_ "github.com/formancehq/payments/internal/connectors/plugins/public/generic"
_ "github.com/formancehq/payments/internal/connectors/plugins/public/mangopay"
_ "github.com/formancehq/payments/internal/connectors/plugins/public/modulr"
_ "github.com/formancehq/payments/internal/connectors/plugins/public/moneycorp"
_ "github.com/formancehq/payments/internal/connectors/plugins/public/stripe"
_ "github.com/formancehq/payments/internal/connectors/plugins/public/wise"
)

0 comments on commit d16c439

Please sign in to comment.