Skip to content

hirosassa/ksnotify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ksnotify

build codecov License: MIT

A CLI command to parse kubectl diff result and notify it to GitLab

What ksnotify does

  1. Parse the execution result of kubectl diff
  2. Notify it to GitLab

The comment posted by ksnotify is as follows:


Plan result

CI link

  • updated
    • apps.v1.Deployment.test.test-app
Details (Click me)

apps.v1.Deployment.jasmine.test-app

 @@ -5,7 +5,6 @@
     deployment.kubernetes.io/revision: "3"
+  labels:
+    app: test-app
   name: test-app
   namespace: test
 spec:
@@ -27,7 +26,6 @@
       creationTimestamp: null
       labels:
         app: test-app
-        skaffold.dev/run-id: 1234
     spec:
       containers:
       - args:

Install

GitHub Releases

Download the prebuilt binary from GitHub Releases and install it to $PATH.

aqua

Install ksnotify with aqua, which is a declarative CLI Version Manager.

$ aqua g -i hirosassa/ksnotify

Usage

prerequisites

Create and export GitLab access token to environmental variables as follows:

export KSNOTIFY_GITLAB_TOKEN="xxxxxx"

ref: Project access tokens | GitLab

Post diff results to GitLab

Basic usage is as follows:

skaffold render -p dev | kubectl diff -f - 2> /dev/null | | ksnotify --notifier gitlab --ci gitlab

If you want to update existing comment instead of create a new comment, you should add --patch flag like

skaffold render -p dev | kubectl diff -f - 2> /dev/null | | ksnotify --notifier gitlab --ci gitlab --patch

To suppress skaffold labels like skaffold.dev/run-id: 1234 automatically added by skaffold, you should add --suppress-skaffold flag like

skaffold render -p dev | kubectl diff -f - 2> /dev/null | | ksnotify --notifier gitlab --ci gitlab --suppress-skaffold

The concrete example of GitLab CI configuration is shown in example.

For developers

To run ksnotify locally, use local option for debug. For local mode, ksnotify just renders contents on stdout.

skaffold render -p dev | kubectl diff -f - 2> /dev/null | ~/Dev/ksnotify/ksnotify --ci local --notifier gitlab --suppress-skaffold

> ## Plan result
> [CI link](  )
>
> * updated
> blah
> blah