mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
- go.mod module path + all self-imports: github.com/formancehq/payments -> github.com/hanzo-fi/payments (1590 .go files / 3152 refs; 20 modules: root, pkg/client, pkg/domain, 18 ce/plugins). External dep kept: formancehq/go-libs. - plugins: each ce/plugins/* consumed a *published* pkg/domain; added local 'replace .../pkg/domain => ../../../pkg/domain' (consistent with root) so every standalone plugin module builds in-monorepo. compile-plugin.sh MOD var rebranded too. - branding: README, LICENSE (dual MIT+EE; upstream copyright retained + Hanzo added), goreleaser (release images -> registry.hanzo.ai/hanzo-fi, OCI labels, homepage), proto go_package, renovate, speakeasy gen.yaml, connector-template *.gotpl. - CI: removed Numary/Formance workflows + composite action; added canonical hanzo.yml + cicd.yml (hanzoai/ci, gated HANZO_CI_ENABLED) + secretless ci.yml (go build/vet). - kept as data/compat keys: wire capability enums ALLOW_FORMANCE_*, generated SDK type client.Formance, domain field FormanceRedirectURL, OTEL_SERVICE_NAME, upstream base image. - verified: go build ./... (default + -tags ee) + all 20 nested modules green.
117 lines
5.7 KiB
Bash
Executable File
117 lines
5.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Regenerates the build-tag-split plugin wiring files:
|
|
# internal/connectors/plugins/registry/generated_ce.go (//go:build !ee)
|
|
# internal/connectors/plugins/registry/generated_ee.go (//go:build ee)
|
|
# internal/connectors/plugins/registry/enterprise_ce.go (//go:build !ee)
|
|
# internal/connectors/plugins/registry/enterprise_ee.go (//go:build ee)
|
|
#
|
|
# Run from the repository root (or any subdirectory — the script locates the root itself).
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
|
|
CE_DIR="$REPO_ROOT/ce/plugins"
|
|
EE_DIR="$REPO_ROOT/ee/plugins"
|
|
OUT_CE="$REPO_ROOT/internal/connectors/plugins/registry/generated_ce.go"
|
|
OUT_EE="$REPO_ROOT/internal/connectors/plugins/registry/generated_ee.go"
|
|
OUT_ENTERPRISE_CE="$REPO_ROOT/internal/connectors/plugins/registry/enterprise_ce.go"
|
|
OUT_ENTERPRISE_EE="$REPO_ROOT/internal/connectors/plugins/registry/enterprise_ee.go"
|
|
MOD="github.com/hanzo-fi/payments"
|
|
|
|
# ── gather plugin lists ───────────────────────────────────────────────────────
|
|
ce_plugins=$(find "$CE_DIR" -mindepth 1 -maxdepth 1 -type d | sort | while read -r d; do basename "$d"; done)
|
|
ee_plugins=$(find "$EE_DIR" -mindepth 1 -maxdepth 1 -type d | sort | while read -r d; do basename "$d"; done)
|
|
|
|
# ── helpers ───────────────────────────────────────────────────────────────────
|
|
|
|
# emit one import line per plugin name
|
|
# $1 = import path prefix (e.g. "github.com/hanzo-fi/payments/internal/connectors/plugins/public")
|
|
# reads plugin names from stdin (one per line)
|
|
emit_imports() {
|
|
prefix="$1"
|
|
while IFS= read -r name; do
|
|
printf '\t%s "%s/%s"\n' "$name" "$prefix" "$name"
|
|
done
|
|
}
|
|
|
|
# emit one map entry per plugin name
|
|
# dummypay maps to DummyPSPName (a registry-package constant) rather than dummypay.ProviderName
|
|
# reads plugin names from stdin (one per line)
|
|
emit_entries() {
|
|
while IFS= read -r name; do
|
|
if [ "$name" = "dummypay" ]; then
|
|
printf '\t\tDummyPSPName: %s.Registration,\n' "$name"
|
|
else
|
|
printf '\t\t%s.ProviderName:\t%s.Registration,\n' "$name" "$name"
|
|
fi
|
|
done
|
|
}
|
|
|
|
# emit one EnterpriseOnlyPlugins set entry per plugin name.
|
|
# Keys are string literals (the provider name == EE plugin directory name): the
|
|
# CE build does not import the EE plugin packages, so we cannot reference their
|
|
# ProviderName constants here. GetPlugin lowercases the provider before lookup
|
|
# and EE directory names are already lowercase.
|
|
# reads plugin names from stdin (one per line)
|
|
emit_enterprise_entries() {
|
|
while IFS= read -r name; do
|
|
printf '\t"%s": {},\n' "$name"
|
|
done
|
|
}
|
|
|
|
# ── generated_ce.go ───────────────────────────────────────────────────────────
|
|
{
|
|
printf '//go:build !ee\n\npackage registry\n\nimport (\n'
|
|
printf '%s\n' "$ce_plugins" | emit_imports "$MOD/ce/plugins"
|
|
printf '\tpkgplugins "%s/pkg/domain/plugins"\n)\n\nfunc init() {\n\tload(map[string]pkgplugins.Registration{\n' "$MOD"
|
|
printf '%s\n' "$ce_plugins" | emit_entries
|
|
printf '\t})\n}\n'
|
|
} > "$OUT_CE"
|
|
|
|
# ── generated_ee.go ───────────────────────────────────────────────────────────
|
|
{
|
|
printf '//go:build ee\n\npackage registry\n\nimport (\n'
|
|
printf '%s\n' "$ce_plugins" | emit_imports "$MOD/ce/plugins"
|
|
printf '%s\n' "$ee_plugins" | emit_imports "$MOD/ee/plugins"
|
|
printf '\tpkgplugins "%s/pkg/domain/plugins"\n)\n\nfunc init() {\n\tload(map[string]pkgplugins.Registration{\n' "$MOD"
|
|
printf '%s\n' "$ce_plugins" | emit_entries
|
|
printf '%s\n' "$ee_plugins" | emit_entries
|
|
printf '\t})\n}\n'
|
|
} > "$OUT_EE"
|
|
|
|
# ── enterprise_ce.go ──────────────────────────────────────────────────────────
|
|
# Lists the connectors only available in the Enterprise Edition so a CE binary
|
|
# can return a helpful 400 instead of "plugin not found" when one is requested.
|
|
{
|
|
printf '//go:build !ee\n\n'
|
|
printf '// Code generated by tools/compile-plugins/compile-plugin.sh; DO NOT EDIT.\n\n'
|
|
printf 'package registry\n\n'
|
|
printf '// EnterpriseOnlyPlugins lists connectors that are only available in the\n'
|
|
printf '// Enterprise Edition. When a user attempts to use one of these connectors\n'
|
|
printf '// on a Community Edition binary, we return a more helpful error message.\n'
|
|
printf 'var EnterpriseOnlyPlugins = map[string]struct{}{\n'
|
|
printf '%s\n' "$ee_plugins" | emit_enterprise_entries
|
|
printf '}\n'
|
|
} > "$OUT_ENTERPRISE_CE"
|
|
|
|
# ── enterprise_ee.go ──────────────────────────────────────────────────────────
|
|
{
|
|
printf '//go:build ee\n\n'
|
|
printf '// Code generated by tools/compile-plugins/compile-plugin.sh; DO NOT EDIT.\n\n'
|
|
printf 'package registry\n\n'
|
|
printf '// EnterpriseOnlyPlugins is empty in the Enterprise Edition because all\n'
|
|
printf '// connectors are compiled in and therefore available.\n'
|
|
printf 'var EnterpriseOnlyPlugins = map[string]struct{}{}\n'
|
|
} > "$OUT_ENTERPRISE_EE"
|
|
|
|
gofmt -w "$OUT_CE" "$OUT_EE" "$OUT_ENTERPRISE_CE" "$OUT_ENTERPRISE_EE"
|
|
|
|
echo "Regenerated:"
|
|
echo " $OUT_CE"
|
|
echo " $OUT_EE"
|
|
echo " $OUT_ENTERPRISE_CE"
|
|
echo " $OUT_ENTERPRISE_EE"
|