From 47383e3c3e18d72598fcd3441e91892d637b8376 Mon Sep 17 00:00:00 2001 From: Pierre Gerbelot Date: Wed, 18 Jun 2025 15:26:05 +0200 Subject: [PATCH 1/2] feat: log also events that are updated --- main.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 1c93243..21d599d 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( var ( ignoreNormal = flag.Bool("ignore-normal", false, "ignore events of type 'Normal' to reduce noise") + ignoreUpdate = flag.Bool("ignore-update", true, "ignore update of events") ) func main() { @@ -58,11 +59,16 @@ func main() { 0, cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { - if (*ignoreNormal && obj.(*corev1.Event).Type == corev1.EventTypeNormal) { + if *ignoreNormal && obj.(*corev1.Event).Type == corev1.EventTypeNormal { return } - j, _ := json.Marshal(obj) - loggerEvent.Printf("%s\n", string(j)) + logEvent(obj, loggerEvent) + }, + UpdateFunc: func(oldObj, newObj interface{}) { + if *ignoreUpdate || (*ignoreNormal && newObj.(*corev1.Event).Type == corev1.EventTypeNormal) { + return + } + logEvent(newObj, loggerEvent) }, }, ) @@ -72,3 +78,8 @@ func main() { go controller.Run(stop) select {} } + +func logEvent(obj interface{}, logger *log.Logger) { + j, _ := json.Marshal(obj) + logger.Printf("%s\n", string(j)) +} From 8f7c600eac335e3d04d86981f0878f1e0d57d7ab Mon Sep 17 00:00:00 2001 From: Pierre Gerbelot Date: Mon, 23 Jun 2025 10:45:31 +0200 Subject: [PATCH 2/2] add github workflow to build a github packages --- .github/workflows/docker-image.yml | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..2f9fab9 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,56 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: create and publish Docker image + +on: + push: + branches: ['main'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: checkout repository + uses: actions/checkout@v3 + + - name: log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=schedule + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + type=raw,value={{branch}} + type=raw,value={{sha}} + - name: build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file