This commit is contained in:
ElevenNotes
2023-12-22 07:28:22 +01:00
parent 064fbaeac6
commit 426c69011b
2 changed files with 13 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
# Alpine :: Traefik Labels
![size](https://img.shields.io/docker/image-size/11notes/traefik-labels/0.1.6?color=0eb305) ![version](https://img.shields.io/docker/v/11notes/traefik-labels?color=eb7a09) ![pulls](https://img.shields.io/docker/pulls/11notes/traefik-labels?color=2b75d6) ![activity](https://img.shields.io/github/commit-activity/m/11notes/docker-traefik-labels?color=c91cb8) ![commit-last](https://img.shields.io/github/last-commit/11notes/docker-traefik-labels?color=c91cb8)
![size](https://img.shields.io/docker/image-size/11notes/traefik-labels/stable?color=0eb305) ![version](https://img.shields.io/docker/v/11notes/traefik-labels?color=eb7a09) ![pulls](https://img.shields.io/docker/pulls/11notes/traefik-labels?color=2b75d6) ![activity](https://img.shields.io/github/commit-activity/m/11notes/docker-traefik-labels?color=c91cb8) ![commit-last](https://img.shields.io/github/last-commit/11notes/docker-traefik-labels?color=c91cb8)
Run Traefik Labels based on Alpine Linux. Small, lightweight, secure and fast 🏔️

View File

@@ -18,7 +18,8 @@ class Labels{
constructor(){
this.#docker = new Docker({socketPath:'/run/docker.sock'});
if('' !== process.env.LABELS_WEBHOOK_AUTH_BASIC){
if(undefined !== process.env.LABELS_WEBHOOK_AUTH_BASIC){
console.log(`process.env.LABELS_WEBHOOK_AUTH_BASIC is ${process.env.LABELS_WEBHOOK_AUTH_BASIC}`);
this.#webhook.headers['Authorization'] = 'Basic ' + Buffer.from(process.env.LABELS_WEBHOOK_AUTH_BASIC).toString('base64')
}
}
@@ -32,7 +33,7 @@ class Labels{
}
async watch(){
if('' !== process.env.LABELS_WEBHOOK){
if(undefined !== process.env.LABELS_WEBHOOK){
this.#log(`using webhook ${process.env.LABELS_WEBHOOK}`);
}
@@ -103,14 +104,17 @@ class Labels{
if(!error){
const update = (/start|poll/i.test(status)) ? true : false;
const webHook = {event:status, labels:{}};
this.#log(`inspect container {${(data?.Name || data?.id).replace(/^\//i, '')}}${(
(null === status) ? '' : ` event[${status}]`
)}`);
let log = false;
for(const label in data?.Config?.Labels){
if(/traefik\//i.test(label)){
if('' !== process.env.LABELS_WEBHOOK){
if(!log){
this.#log(`inspect container {${(data?.Name || data?.id).replace(/^\//i, '')}}${(
(null === status) ? '' : ` event[${status}]`
)} traefik labels`);
log = true;
}
if(undefined !== process.env.LABELS_WEBHOOK){
webHook.labels[label] = data?.Config?.Labels[label];
}
if(update){
@@ -121,7 +125,7 @@ class Labels{
}
}
if('' !== process.env.LABELS_WEBHOOK){
if(undefined !== process.env.LABELS_WEBHOOK){
try{
await fetch(process.env.LABELS_WEBHOOK, {method:(
(update) ? 'PUT' : 'DELETE'