Skip to content

Commit ed489c8

Browse files
Merge branch 'main' into feature/remove-auth
2 parents 44053e1 + 9502123 commit ed489c8

24 files changed

Lines changed: 1376 additions & 75 deletions

.github/workflows/go.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Go
1717
uses: actions/setup-go@v3
1818
with:
19-
go-version: 1.24.4
19+
go-version: 1.24.x
2020

2121
- name: Get coverage tool
2222
run: |
@@ -27,7 +27,7 @@ jobs:
2727
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}"
2828
echo $BRANCH_NAME
2929
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV
30-
30+
3131
- name: Create failing badge
3232
uses: schneegans/dynamic-badges-action@v1.0.0
3333
with:
@@ -44,14 +44,14 @@ jobs:
4444
cd application/backend
4545
go test ./... -coverprofile cover.out
4646
go tool cover -func cover.out > covered.txt
47-
47+
4848
- name: Get coverage
4949
run: |
5050
cd application/backend
5151
for word in $(cat covered.txt); do total_percent=$word; done
5252
echo $total_percent
5353
echo "COVERAGE=$total_percent" >> $GITHUB_ENV
54-
54+
5555
- name: Create passing badge
5656
uses: schneegans/dynamic-badges-action@v1.0.0
5757
if: ${{ env.COVERAGE!=null }}
@@ -63,7 +63,7 @@ jobs:
6363
message: Passed
6464
color: green
6565
namedLogo: checkmarx
66-
66+
6767
- name: Create coverage badge
6868
uses: schneegans/dynamic-badges-action@v1.0.0
6969
if: ${{ env.COVERAGE!=null }}

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.ai-factory.json
2+
.mcp.json
3+
AGENTS.md
4+
skills-lock.json
5+
.codex/
6+
.agents/
7+
.ai-factory/
8+
9+
**/__pycache__/

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,30 @@ Once done, just go to <your host> and login as "admin" with <any password>.
9595
### Docket socket URL
9696
By default the app will connect using the raw unix socket. But this can be overriden via the ENV variable `DOCKER_HOST`. That way you can specify fully qualified URL to the socket or URL of an docker socket proxy.
9797

98-
In `compose-socket-proxy.yml` you can see a sample compose file for starting the socket proxy. To use it in the app set `DOCKER_HOST=http://localhost:2375` in the ENV.
98+
In `compose-socket-proxy.yml` you can see a sample compose file for starting the socket proxy. To use it in the app set `DOCKER_HOST=http://localhost:2375` in the ENV.
99+
100+
## Local Docker testing
101+
102+
Use the local test compose to run `onlogs + socket-proxy + logprinter` together:
103+
104+
```sh
105+
cd application
106+
docker compose -f compose-local-test.yml up --build
107+
```
108+
109+
Open `http://localhost:2874` and login with:
110+
111+
- Username: `admin`
112+
- Password: `admin`
113+
114+
Stop containers:
115+
116+
```sh
117+
docker compose -f compose-local-test.yml down
118+
```
119+
120+
Stop and remove volumes too (clean state):
121+
122+
```sh
123+
docker compose -f compose-local-test.yml down -v
124+
```

application/backend/app/containerdb/containerdb.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package containerdb
33
import (
44
"fmt"
55
"os"
6+
"regexp"
67
"strings"
78
"sync"
89
"time"
@@ -207,6 +208,7 @@ var (
207208
logCleanupMu sync.Mutex
208209
nextCleanup time.Time
209210
isCleanupRunning bool
211+
ansiEscapeRegex = regexp.MustCompile(`[\x1B\x9B][[\]()#;?]*(?:(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><])`)
210212
)
211213

212214
func MaybeScheduleCleanup(host string, container string) {
@@ -275,6 +277,11 @@ func PutLogMessage(db *leveldb.DB, host string, container string, message_item [
275277
}
276278

277279
func fitsForSearch(logLine string, message string, caseSensetivity bool) bool {
280+
logLine = ansiEscapeRegex.ReplaceAllString(logLine, "")
281+
message = ansiEscapeRegex.ReplaceAllString(message, "")
282+
logLine = strings.Join(strings.Fields(logLine), " ")
283+
message = strings.Join(strings.Fields(message), " ")
284+
278285
if !caseSensetivity {
279286
logLine = strings.ToLower(logLine)
280287
message = strings.ToLower(message)

application/backend/app/containerdb/containerdb_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,19 @@ func TestGetLogs(t *testing.T) {
9898
t.Error("Invalid last logItem datetime: ", logs[3][0])
9999
}
100100
}
101+
102+
func TestFitsForSearchWithANSI(t *testing.T) {
103+
logLine := "\x1b[37mWARNING\x1b[2m AzL4Y8oR KsTdiwHodbZ0i \tmOK2Wz \x1b[0m"
104+
105+
if !fitsForSearch(logLine, "WARNING Az", true) {
106+
t.Error("Expected query to match when ANSI escape codes are present")
107+
}
108+
109+
if !fitsForSearch(logLine, "KsTdiwHodbZ0i m", true) {
110+
t.Error("Expected query to match across tab-separated boundary")
111+
}
112+
113+
if fitsForSearch(logLine, "NOT_PRESENT", true) {
114+
t.Error("Expected non-existing query not to match")
115+
}
116+
}

application/backend/app/daemon/daemon.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ func (h *DaemonService) CreateDaemonToDBStream(ctx context.Context, containerNam
161161
func (h *DaemonService) GetContainersList(ctx context.Context) []string {
162162
result, err := h.DockerClient.GetContainerNames(ctx)
163163
if err != nil {
164-
panic(err)
164+
fmt.Println("ERROR: failed to get containers list from docker daemon:", err)
165+
return vars.DockerContainers
165166
}
166167

167168
var names []string

application/backend/app/routes/routes_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
func initTestConfig() *RouteController {
25-
cli, _ := client.NewClientWithOpts(client.FromEnv)
25+
cli, _ := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
2626
defer cli.Close()
2727

2828
dockerService := &docker.DockerService{

application/backend/app/streamer/streamer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func initTestConfig() *StreamController {
13-
cli, _ := client.NewClientWithOpts(client.FromEnv)
13+
cli, _ := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
1414
defer cli.Close()
1515

1616
dockerService := &docker.DockerService{

application/backend/main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,16 @@ func main() {
4545
godotenv.Load(".env")
4646
init_config()
4747

48-
cli, _ := client.NewClientWithOpts(client.FromEnv)
48+
cli, err := client.NewClientWithOpts(
49+
client.FromEnv,
50+
client.WithAPIVersionNegotiation(),
51+
)
52+
if err != nil {
53+
fmt.Println("ERROR: unable to initialize Docker client:", err)
54+
return
55+
}
4956
defer cli.Close()
57+
fmt.Println("INFO: Docker client initialized with API version negotiation")
5058

5159
dockerService := &docker.DockerService{
5260
Client: cli,

application/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# docker buildx create --use
2-
docker buildx build --load --platform=linux/amd64,linux/arm64 --tag "devforth/onlogs:latest" --tag "devforth/onlogs:1.1.4" .
2+
docker buildx build --load --platform=linux/amd64,linux/arm64 --tag "devforth/onlogs:latest" --tag "devforth/onlogs:1.1.11" .

0 commit comments

Comments
 (0)