Skip to content

Commit

Permalink
chore: upgrade to latest go-libs
Browse files Browse the repository at this point in the history
also add pre-commit config
  • Loading branch information
gfyrag committed Nov 23, 2022
1 parent 7a29c6d commit e79c6cc
Show file tree
Hide file tree
Showing 49 changed files with 215 additions and 202 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ linters:
- noctx # TODO: FIX
- contextcheck # TODO: FIX
- containedctx # TODO: FIX
- typecheck

issues:
exclude-rules:
Expand Down
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
exclude: client
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: .cloud
- id: check-added-large-files
- repo: https://github.com/formancehq/pre-commit-hooks
rev: dd079f7c30ad72446d615f55a000d4f875e79633
hooks:
- id: gogenerate
files: swagger.yaml
- id: gomodtidy
- id: goimports
- id: gofmt
- id: golangci-lint
- id: gotests
- id: commitlint
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ lint-fix:

run-tests:
go test -race -count=1 ./...

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
Payments works as a standalone binary, the latest of which can be downloaded from the [releases page](https://github.com/numary/payments/releases). You can move the binary to any executable path, such as to `/usr/local/bin`. Installations using brew, apt, yum or docker are also [available](https://docs.formance.com/oss/payments/get-started/installation).

```SHELL
payments
payments
```

# What is it?

Basically, a framework.

A framework to ingest payin and payout coming from different payment providers (PSP).
A framework to ingest payin and payout coming from different payment providers (PSP).

The framework contains connectors. Each connector is basically a translator for a PSP.
Translator, because the main role of a connector is to translate specific PSP payin/payout formats to a generalized format used at Formance.
Expand Down
60 changes: 24 additions & 36 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

_ "github.com/bombsimon/logrusr/v3"
"github.com/formancehq/go-libs/sharedotlp/pkg/sharedotlptraces"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -37,46 +38,33 @@ func rootCommand() *cobra.Command {
root.AddCommand(server)

root.PersistentFlags().Bool(debugFlag, false, "Debug mode")
root.Flags().BoolP("toggle", "t", false, "Help message for toggle")
root.Flags().Bool(debugFlag, false, "Debug mode")
root.Flags().String(mongodbURIFlag, "mongodb://localhost:27017", "MongoDB address")
root.Flags().String(mongodbDatabaseFlag, "payments", "MongoDB database name")
root.Flags().Bool(otelTracesFlag, false, "Enable OpenTelemetry traces support")
root.Flags().String(otelTracesExporterFlag, "stdout", "OpenTelemetry traces exporter")
root.Flags().String(otelTracesExporterJaegerEndpointFlag,
"", "OpenTelemetry traces Jaeger exporter endpoint")
root.Flags().String(otelTracesExporterJaegerUserFlag,
"", "OpenTelemetry traces Jaeger exporter user")
root.Flags().String(otelTracesExporterJaegerPasswordFlag,
"", "OpenTelemetry traces Jaeger exporter password")
root.Flags().String(otelTracesExporterOTLPModeFlag,
"grpc", "OpenTelemetry traces OTLP exporter mode (grpc|http)")
root.Flags().String(otelTracesExporterOTLPEndpointFlag,
"", "OpenTelemetry traces grpc endpoint")
root.Flags().Bool(otelTracesExporterOTLPInsecureFlag,
false, "OpenTelemetry traces grpc insecure")
root.Flags().String(envFlag, "local", "Environment")
root.Flags().Bool(publisherKafkaEnabledFlag, false, "Publish write events to kafka")
root.Flags().StringSlice(publisherKafkaBrokerFlag, []string{}, "Kafka address is kafka enabled")
root.Flags().StringSlice(publisherTopicMappingFlag,
server.Flags().BoolP("toggle", "t", false, "Help message for toggle")
server.Flags().String(mongodbURIFlag, "mongodb://localhost:27017", "MongoDB address")
server.Flags().String(mongodbDatabaseFlag, "payments", "MongoDB database name")
server.Flags().String(envFlag, "local", "Environment")
server.Flags().Bool(publisherKafkaEnabledFlag, false, "Publish write events to kafka")
server.Flags().StringSlice(publisherKafkaBrokerFlag, []string{}, "Kafka address is kafka enabled")
server.Flags().StringSlice(publisherTopicMappingFlag,
[]string{}, "Define mapping between internal event types and topics")
root.Flags().Bool(publisherHTTPEnabledFlag, false, "Sent write event to http endpoint")
root.Flags().Bool(publisherKafkaSASLEnabled, false, "Enable SASL authentication on kafka publisher")
root.Flags().String(publisherKafkaSASLUsername, "", "SASL username")
root.Flags().String(publisherKafkaSASLPassword, "", "SASL password")
root.Flags().String(publisherKafkaSASLMechanism, "", "SASL authentication mechanism")
root.Flags().Int(publisherKafkaSASLScramSHASize, 512, "SASL SCRAM SHA size")
root.Flags().Bool(publisherKafkaTLSEnabled, false, "Enable TLS to connect on kafka")
root.Flags().Bool(authBasicEnabledFlag, false, "Enable basic auth")
root.Flags().StringSlice(authBasicCredentialsFlag, []string{},
server.Flags().Bool(publisherHTTPEnabledFlag, false, "Sent write event to http endpoint")
server.Flags().Bool(publisherKafkaSASLEnabled, false, "Enable SASL authentication on kafka publisher")
server.Flags().String(publisherKafkaSASLUsername, "", "SASL username")
server.Flags().String(publisherKafkaSASLPassword, "", "SASL password")
server.Flags().String(publisherKafkaSASLMechanism, "", "SASL authentication mechanism")
server.Flags().Int(publisherKafkaSASLScramSHASize, 512, "SASL SCRAM SHA size")
server.Flags().Bool(publisherKafkaTLSEnabled, false, "Enable TLS to connect on kafka")
server.Flags().Bool(authBasicEnabledFlag, false, "Enable basic auth")
server.Flags().StringSlice(authBasicCredentialsFlag, []string{},
"HTTP basic auth credentials (<username>:<password>)")
root.Flags().Bool(authBearerEnabledFlag, false, "Enable bearer auth")
root.Flags().String(authBearerIntrospectURLFlag, "", "OAuth2 introspect URL")
root.Flags().StringSlice(authBearerAudienceFlag, []string{}, "Allowed audiences")
root.Flags().Bool(authBearerAudiencesWildcardFlag, false, "Don't check audience")
root.Flags().Bool(authBearerUseScopesFlag,
server.Flags().Bool(authBearerEnabledFlag, false, "Enable bearer auth")
server.Flags().String(authBearerIntrospectURLFlag, "", "OAuth2 introspect URL")
server.Flags().StringSlice(authBearerAudienceFlag, []string{}, "Allowed audiences")
server.Flags().Bool(authBearerAudiencesWildcardFlag, false, "Don't check audience")
server.Flags().Bool(authBearerUseScopesFlag,
false, "Use scopes as defined by rfc https://datatracker.ietf.org/doc/html/rfc8693")

sharedotlptraces.InitOTLPTracesFlags(server.Flags())

viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_"))
viper.AutomaticEnv()

Expand Down
22 changes: 7 additions & 15 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (

"github.com/Shopify/sarama"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/numary/go-libs/sharedlogging"
"github.com/numary/go-libs/sharedlogging/sharedlogginglogrus"
"github.com/numary/go-libs/sharedotlp/pkg/sharedotlptraces"
"github.com/numary/go-libs/sharedpublish"
"github.com/numary/go-libs/sharedpublish/sharedpublishhttp"
"github.com/numary/go-libs/sharedpublish/sharedpublishkafka"
"github.com/formancehq/go-libs/sharedlogging"
"github.com/formancehq/go-libs/sharedlogging/sharedlogginglogrus"
"github.com/formancehq/go-libs/sharedotlp/pkg/sharedotlptraces"
"github.com/formancehq/go-libs/sharedpublish"
"github.com/formancehq/go-libs/sharedpublish/sharedpublishhttp"
"github.com/formancehq/go-libs/sharedpublish/sharedpublishkafka"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -83,15 +83,7 @@ func runServer(cmd *cobra.Command, args []string) error {
}

options = append(options, databaseOptions)

options = append(options, sharedotlptraces.TracesModule(sharedotlptraces.ModuleConfig{
Exporter: viper.GetString(otelTracesExporterFlag),
OTLPConfig: &sharedotlptraces.OTLPConfig{
Mode: viper.GetString(otelTracesExporterOTLPModeFlag),
Endpoint: viper.GetString(otelTracesExporterOTLPEndpointFlag),
Insecure: viper.GetBool(otelTracesExporterOTLPInsecureFlag),
},
}))
options = append(options, sharedotlptraces.CLITracesModule(viper.GetViper()))

options = append(options,
fx.Provide(fx.Annotate(func(p message.Publisher) *sharedpublish.TopicMapperPublisher {
Expand Down
5 changes: 5 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
extends: [
'@commitlint/config-conventional'
]
}
Loading

0 comments on commit e79c6cc

Please sign in to comment.