snapshot of https://github.com/ory/kratos.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped

This commit is contained in:
upstream-mirror
2026-09-15 21:19:12 +05:00
commit c60cc7ca75
8092 changed files with 394160 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
event_logger.yml
configmap.yml
Makefile
README.md
eventlog_snapshot

View File

@@ -0,0 +1 @@
tmp_snapshot

View File

@@ -0,0 +1,21 @@
FROM golang:1.26-alpine3.23 AS builder
RUN apk -U --no-cache add build-base
WORKDIR /go/src/github.com/ory/x
ADD go.mod go.mod
ADD go.sum go.sum
RUN go mod download
ADD . .
RUN go build -o /usr/bin/eventlogger ./watcherx/integrationtest
FROM alpine:3.22
COPY --from=builder /usr/bin/eventlogger /usr/bin/eventlogger
ENTRYPOINT ["eventlogger"]
CMD ["/etc/config/mock-config"]

View File

@@ -0,0 +1,65 @@
SHELL=/bin/bash -euo pipefail
CLUSTER_NAME=watcherx-integration-test
SNAPSHOT_FILE=eventlog_snapshot
define generate_snapshot
sleep 5
make update
sleep 1
kubectl logs eventlogger --context kind-${CLUSTER_NAME} >> $(1)
make apply
sleep 1
kubectl logs eventlogger --context kind-${CLUSTER_NAME} >> $(1)
make update
sleep 1
kubectl logs eventlogger --context kind-${CLUSTER_NAME} >> $(1)
endef
.PHONY: build
build:
docker build -f Dockerfile -t eventlogger:latest ../..
.PHONY: create
create:
kind create cluster --name ${CLUSTER_NAME} --wait 1m || true
.PHONY: load
load:
kind load docker-image eventlogger:latest --name ${CLUSTER_NAME}
.PHONY: apply
apply:
kubectl apply -f configmap.yml -f event_logger.yml --context kind-${CLUSTER_NAME}
.PHONY: delete
delete:
kind delete cluster --name ${CLUSTER_NAME}
.PHONY: setup
setup: build create load apply
.PHONY: snapshot
snapshot: setup container-restart
rm ${SNAPSHOT_FILE}
${call generate_snapshot,$(SNAPSHOT_FILE)}
.PHONY: check
check: setup container-restart
rm tmp_snapshot || true
${call generate_snapshot,tmp_snapshot}
diff tmp_snapshot ${SNAPSHOT_FILE}
.PHONY: logs
logs:
kubectl logs eventlogger --context kind-${CLUSTER_NAME}
.PHONY: container-restart
container-restart:
kubectl delete -f event_logger.yml --context kind-${CLUSTER_NAME}
kubectl apply -f event_logger.yml --context kind-${CLUSTER_NAME}
.PHONY: update
update:
cat configmap.yml | sed 's/somevalue/othervalue/' | kubectl apply -f - --context kind-${CLUSTER_NAME}
cat event_logger.yml | sed 's/somevalue/othervalue/' | kubectl apply -f - --context kind-${CLUSTER_NAME}

View File

@@ -0,0 +1,27 @@
# Integration Test for watcherx/FileWatcher
As kubernetes has a special way to change mounted config map values we want to
make sure our file watcher is compatible with that.
## Perquisites
The versions are the ones that definitely work.
- kind (v0.8.1)
- kubectl (v1.18.5)
- docker (v19.03.12-ce)
- make (v4.3)
## Structure
The `main.go` just logs all events it gets. It is deployed to a kind kubernetes
cluster together with a configmap that gets updated during the test. For details
on the test steps have a look at the `Makefile`.
## Running
To generate the log snapshot run `make snapshot`. That snapshot should be
committed. To check if the FileWatcher works run `make check`. For debugging
purposes single steps of the setup have descriptive make target names and can be
run separately. It is safe to delete the cluster at any point or rerun snapshot
generation.

View File

@@ -0,0 +1,6 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: changing-config
data:
mock-config: somevalue

View File

@@ -0,0 +1,19 @@
kind: Pod
apiVersion: v1
metadata:
name: eventlogger
annotations:
variant: somevalue
spec:
containers:
- name: eventlogger
image: eventlogger:latest
imagePullPolicy: Never
volumeMounts:
- name: changing-config
mountPath: /etc/config
restartPolicy: Never
volumes:
- name: changing-config
configMap:
name: changing-config

View File

@@ -0,0 +1,21 @@
watching file /etc/config/mock-config
got change event:
Data: othervalue,
Src: /etc/config/mock-config
watching file /etc/config/mock-config
got change event:
Data: othervalue,
Src: /etc/config/mock-config
got change event:
Data: somevalue,
Src: /etc/config/mock-config
watching file /etc/config/mock-config
got change event:
Data: othervalue,
Src: /etc/config/mock-config
got change event:
Data: somevalue,
Src: /etc/config/mock-config
got change event:
Data: othervalue,
Src: /etc/config/mock-config

View File

@@ -0,0 +1,45 @@
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/ory/x/watcherx"
)
func main() {
if len(os.Args) != 2 {
_, _ = fmt.Fprintf(os.Stderr, "expected 1 comand line argument but got %d\n", len(os.Args)-1)
os.Exit(1)
}
c := make(chan watcherx.Event)
_, err := watcherx.WatchFile(context.Background(), os.Args[1], c)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "could not initialize file watcher: %+v\n", err)
os.Exit(1)
}
fmt.Printf("watching file %s\n", os.Args[1])
for {
switch e := (<-c).(type) {
case *watcherx.ChangeEvent:
var data []byte
data, err = io.ReadAll(e.Reader())
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "could not read data: %+v\n", err)
os.Exit(1)
}
fmt.Printf("got change event:\nData: %s,\nSrc: %s\n", data, e.Source())
case *watcherx.RemoveEvent:
fmt.Printf("got remove event:\nSrc: %s\n", e.Source())
case *watcherx.ErrorEvent:
fmt.Printf("got error event:\nError: %s\n", e.Error())
default:
fmt.Println("got unknown event")
}
}
}