8000 fix(local): fix missing doc and target about plugin compilation by paul-nicolas · Pull Request #422 · formancehq/payments · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(local): fix missing doc and target about plugin compilation #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ In a real-world scenario, you'd want to build a connector that fetches data from
To make this process easier, we've dockerized the Connectivity Service which allows you to run it directly from your local environment. You can bring up the project by calling docker from within the project's home directory:

```sh
$ earthly -P +compile-plugins --local_save=true
$ docker compose up
```

Expand Down
12 changes: 5 additions & 7 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ sources:
SAVE ARTIFACT /src

compile-plugins:
ARG local_save=false
FROM core+builder-image
COPY (+sources/*) /src
WORKDIR /src/internal/connectors/plugins/public
RUN printf "package public\n\n" > list.go
RUN printf "import (\n" >> list.go
FOR c IN $(ls -d */ | sed 's#/##')
RUN printf " _ \"github.com/formancehq/payments/internal/connectors/plugins/public/$c\"\n" >> list.go
END
RUN printf ")\n" >> list.go
RUN ./src/tools/compile-plugins/compile-plugin.sh list.go /src/internal/connectors/plugins/public
SAVE ARTIFACT /src/internal/connectors/plugins/public/list.go /list.go
IF $local_save
SAVE ARTIFACT /src/internal/connectors/plugins/public/list.go AS LOCAL internal/connectors/plugins/public/list.go
END

compile:
FROM core+builder-image
Expand Down
5 changes: 4 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set dotenv-load
default:
@just --list

pre-commit: tidy generate lint
pre-commit: tidy generate lint openapi compile-plugins
pc: pre-commit

lint:
Expand All @@ -12,6 +12,9 @@ lint:
tidy:
@go mod tidy

compile-plugins:
./tools/compile-plugins/compile-plugin.sh list.go internal/connectors/plugins/public

[group('openapi')]
compile-connector-configs:
@go build -o compile-configs {{justfile_directory()}}/tools/compile-configs
Expand Down
35 changes: 35 additions & 0 deletions tools/compile-plugins/compile-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

# Check if enough arguments are provided
if [ "$#" -lt 2 ]; then
echo "Error: Not enough arguments provided."
echo "Usage: $0 <output_filename> <plugins_directory>"
exit 1
fi

output_file="$1"
plugins_dir="$2"

# Save current directory to return to it later
current_dir=$(pwd)

# Change to plugins directory
cd "$plugins_dir" || { echo "Error: Cannot change to directory $plugins_dir"; exit 1; }

# Create output file with package declaration
printf "package public\n\n" > "$output_file"
printf "import (\n" >> "$output_file"

# Find all directories and generate import statements
find . -mindepth 1 -maxdepth 1 -type d | sort | while read -r dir; do
c=$(basename "$dir")
printf " _ \"github.com/formancehq/payments/internal/connectors/plugins/public/%s\"\n" "$c" >> "$output_file"
done

# Finish import block
printf ")\n" >> "$output_file"

# Return to original directory
cd "$current_dir" || { echo "Error: Cannot return to original directory"; exit 1; }

echo "Successfully generated $output_file with plugin imports"
Loading
0