Skip to content

Commit c67ff46

Browse files
authored
Merge pull request #6 from untergeek/feature/write_to_es
Major-minor-major changes
2 parents 528afda + 009e3af commit c67ff46

27 files changed

+882
-810
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
.vscode/
2+
.flake8
3+
mypy.ini
4+
pylintrc.toml
5+
pytest.ini
6+
src/testing
7+
18
# Byte-compiled / optimized / DLL files
29
__pycache__/
310
*.py[cod]

Dockerfile

+34-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
# syntax=docker/dockerfile:1
2-
ARG PYVER=3.11.5
3-
ARG ALPTAG=3.17
4-
FROM python:${PYVER}-alpine${ALPTAG} as builder
2+
ARG EXENAME=es-fieldusage
3+
ARG EXEPATH=/exe_path
4+
ARG EXECUTABLE=${EXEPATH}/${EXENAME}
5+
ARG LDPATH=${EXEPATH}/lib
6+
ARG CONFIGPATH=/.config
7+
ARG PYVER=3.12.5
8+
ARG ALPTAG=3.20
9+
FROM python:${PYVER}-alpine${ALPTAG} AS builder
510

611
# Add the community repo for access to patchelf binary package
712
ARG ALPTAG
813
RUN echo "https://dl-cdn.alpinelinux.org/alpine/v${ALPTAG}/community/" >> /etc/apk/repositories
914
RUN apk --no-cache upgrade && apk --no-cache add build-base tar musl-utils openssl-dev patchelf
1015
# patchelf-wrapper is necessary now for cx_Freeze, but not for Curator itself.
11-
RUN pip3 install setuptools cx_Freeze patchelf-wrapper
16+
RUN pip3 install cx_Freeze patchelf-wrapper
1217

1318
COPY . .
1419
# alpine4docker.sh does some link magic necessary for cx_Freeze execution
@@ -19,14 +24,13 @@ COPY . .
1924
# ln -s /lib /lib64
2025
RUN /bin/sh alpine4docker.sh
2126

22-
# Install Curator locally
27+
# Install project locally
2328
RUN pip3 install .
2429

25-
# Build (or rather Freeze) Curator
26-
RUN python3 setup.py build_exe
30+
# Build (or rather Freeze) the project
31+
RUN cxfreeze build
2732

28-
# This will add the cacert.pem from certifi to the default location Curator will look
29-
# and also move 'build/exe.{system().lower()}-{machine()}-{MAJOR}.{MINOR}' to fieldusage_build
33+
# Rename 'build/exe.{system().lower()}-{machine()}-{MAJOR}.{MINOR}' to curator_build
3034
RUN python3 post4docker.py
3135

3236
### End `builder` segment
@@ -35,12 +39,28 @@ RUN python3 post4docker.py
3539
ARG ALPTAG
3640
FROM alpine:${ALPTAG}
3741
RUN apk --no-cache upgrade && apk --no-cache add openssl-dev expat
38-
# The path `fieldusage_build` is from `builder` and `post4docker.py`
39-
COPY --from=builder fieldusage_build /esfieldusage/
40-
RUN mkdir /.esfieldusage
42+
43+
# The path `executable_build` is from `builder` and `post4docker.py`
44+
ARG EXEPATH
45+
COPY --from=builder executable_build ${EXEPATH}/
46+
4147
# This is for the Docker default filepath override
4248
RUN mkdir /fileoutput
49+
RUN chown nobody:nobody /fileoutput
50+
51+
ARG CONFIGPATH
52+
RUN mkdir ${CONFIGPATH}
53+
54+
ARG LDPATH
55+
ENV LD_LIBRARY_PATH=${LDPATH}
56+
57+
# COPY entrypoint.sh /
58+
59+
ARG EXECUTABLE
60+
RUN echo '#!/bin/sh' > /entrypoint.sh
61+
RUN echo >> /entrypoint.sh
62+
RUN echo "${EXECUTABLE} \"\$@\"" >> /entrypoint.sh
63+
RUN chmod +x /entrypoint.sh
4364

4465
USER nobody:nobody
45-
ENV LD_LIBRARY_PATH /esfieldusage/lib:$LD_LIBRARY_PATH
46-
ENTRYPOINT ["/esfieldusage/es-fieldusage"]
66+
ENTRYPOINT ["/entrypoint.sh"]

LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2023 Elasticsearch <http://elastic.co> and contributors.
1+
Copyright 2023-2024 Elasticsearch <http://elastic.co> and contributors.
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

README.md

+18-14
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77

88
**Table of Contents**
99

10-
- [Installation](#installation)
11-
- [Description](#description)
12-
- [Options](#top-level-help-output)
13-
- [Command: stdout](#command-stdout-help-output)
14-
- [Command: file](#command-file-help-output)
15-
- [Command: show-indices](#command-show-indices-help-output)
16-
- [Docker Usage](#docker-usage)
17-
- [License](#license)
10+
- [es-fieldusage](#es-fieldusage)
11+
- [Installation](#installation)
12+
- [Description](#description)
13+
- [Top-level help output](#top-level-help-output)
14+
- [Command: `stdout` help output](#command-stdout-help-output)
15+
- [Command `file` help output](#command-file-help-output)
16+
- [Command `show-indices` help output](#command-show-indices-help-output)
17+
- [Docker usage](#docker-usage)
18+
- [Docker build](#docker-build)
19+
- [Docker run](#docker-run)
20+
- [License](#license)
1821

1922
## Installation
2023

@@ -55,22 +58,23 @@ Options:
5558
--password TEXT Elasticsearch password
5659
--request_timeout FLOAT Request timeout in seconds
5760
--verify_certs / --no-verify_certs
58-
Verify SSL/TLS certificate(s) [default: verify_certs]
61+
Verify SSL/TLS certificate(s)
5962
--ca_certs TEXT Path to CA certificate file or directory
6063
--client_cert TEXT Path to client certificate file
6164
--client_key TEXT Path to client key file
6265
--loglevel [DEBUG|INFO|WARNING|ERROR|CRITICAL]
6366
Log level
6467
--logfile TEXT Log file
6568
--logformat [default|ecs] Log output format
69+
--blacklist TEXT Named entities will not be logged
6670
-v, --version Show the version and exit.
6771
-h, --help Show this message and exit.
6872
6973
Commands:
7074
show-all-options Show all configuration options
7175
stdout Output field usage information to the console
7276
73-
Learn more at https://github.com/untergeek/elastic-grab-bag/es_fieldusage
77+
Learn more at https://github.com/untergeek/es-fieldusage
7478
```
7579

7680
### Command: `stdout` help output
@@ -92,10 +96,10 @@ Options:
9296
--show-unaccessed / --hide-unaccessed
9397
Show unaccessed fields [default: hide-unaccessed]
9498
--show-counts / --hide-counts Show field access counts [default: hide-counts]
95-
--delimiter TEXT Value delimiter if access counts are shown [default: :]
99+
--delimiter TEXT Value delimiter if access counts are shown [default: ,]
96100
-h, --help Show this message and exit.
97101
98-
Learn more at https://github.com/untergeek/elastic-grab-bag/es_fieldusage
102+
Learn more at https://github.com/untergeek/es-fieldusage
99103
```
100104

101105
### Command `file` help output
@@ -121,7 +125,7 @@ Options:
121125
--delimiter TEXT Value delimiter if access counts are shown [default: ,]
122126
-h, --help Show this message and exit.
123127
124-
Learn more at https://github.com/untergeek/elastic-grab-bag/es_fieldusage
128+
Learn more at https://github.com/untergeek/es-fieldusage
125129
```
126130

127131
### Command `show-indices` help output
@@ -139,7 +143,7 @@ Usage: es-fieldusage show-indices SEARCH_PATTERN
139143
Options:
140144
-h, --help Show this message and exit.
141145
142-
Learn more at https://github.com/untergeek/elastic-grab-bag/es-fieldusage
146+
Learn more at https://github.com/untergeek/es-fieldusage
143147
```
144148

145149
## Docker usage

docker_test/VERSION

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Version: 1.1.1
2+
Released: 24 August 2024
3+
4+
# License and Changelog at https://github.com/untergeek/es-docker-test-scripts

docker_test/ansi_clean.bash

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
ansi_clean () {
4+
# This function is separate so nobody touches the control-M sequence
5+
# in the second sed stream filter
6+
echo ${1} | sed -e 's/\x1b\[[0-9;]*m//g' -e 's///g'
7+
}

0 commit comments

Comments
 (0)