kubernetes / git-sync

A sidecar app which clones a git repo and keeps it in sync with the upstream.
Apache License 2.0
2.13k stars 406 forks source link

v4 slack webhook #865

Closed cfsnate closed 3 weeks ago

cfsnate commented 3 months ago

hoping to send webhook to slack on sync, 400 error using built in webhook function per https://github.com/kubernetes/git-sync/issues/508

no apt in v4 so can't install curl in a custom image to do a custom script

am I missing something?

thockin commented 3 months ago

I'm not AGAINST trying to find a way to make this work, if someone wants to contribute tests and an implementation.

cfsnate commented 3 months ago

I got curl working in quite an annoying and fragile way. but it works. files taken from stock debian bullseye

FROM registry.k8s.io/git-sync/git-sync:v4.2.1
USER root

ADD curl/binary/curl /usr/bin/curl

RUN chmod +x /usr/bin/curl

ADD curl/lib/libcurl.so.4.7.0 /usr/lib/aarch64-linux-gnu/libcurl.so.4

ADD curl/lib/libssl.so.1.1 /usr/lib/aarch64-linux-gnu/libssl.so.1.1

ADD curl/lib/libcrypto.so.1.1 /usr/lib/aarch64-linux-gnu/libcrypto.so.1.1

ADD curl/lib/libldap_r-2.4.so.2.11.5 /usr/lib/aarch64-linux-gnu/libldap_r-2.4.so.2

ADD curl/lib/liblber-2.4.so.2.11.5 /usr/lib/aarch64-linux-gnu/liblber-2.4.so.2

ADD slack.sh /opt/slack.sh

RUN chmod +x /opt/slack.sh

USER git-sync

will play with this a bit more tomorrow

thockin commented 3 months ago

Alternatively:

If we want to include curl, I'd like an e2e test showing it works for some simple things (and doesn't drag in other deps, like git does :) Here's a starting point:

diff --git a/Dockerfile.in b/Dockerfile.in
index dadb69e..18fb5a3 100644
--- a/Dockerfile.in
+++ b/Dockerfile.in
@@ -60,6 +60,7 @@ RUN /stage_binaries.sh -o {ARG_STAGING} \
        -p git \
        -p openssh-client \
        -p ca-certificates \
+       -p curl \
        -p socat \
        -b /bin/grep \
        -b /bin/sed \
matkovic commented 3 months ago

Have exactly the same problems with sending notifications with webhook to slack. The way I managed to install curl into the image is with this

FROM curlimages/curl:8.6.0 AS curl_build

FROM registry.k8s.io/git-sync/git-sync:v4.1.0
USER root
COPY --from=curl_build /usr/bin/curl /usr/bin/curl
COPY --from=curl_build /usr/lib /usr/lib
COPY --from=curl_build /lib /lib

USER git-sync

curl command works, but have not tested it much yet. If I encounter problems, I can let you know

thockin commented 3 months ago

If someone can help craft an e2e that mimicks a slack integration, I could merge curl. I just want to make sure I don't add curl only to find it is missing some other helper package(s).

thockin commented 3 weeks ago

I merged curl - I'd still love an e2e for this