Skip to content

Commit

Permalink
Merge pull request #6 from untergeek/feature/write_to_es
Browse files Browse the repository at this point in the history
Major-minor-major changes
  • Loading branch information
untergeek authored Aug 26, 2024
2 parents 528afda + 009e3af commit c67ff46
Show file tree
Hide file tree
Showing 27 changed files with 882 additions and 810 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.vscode/
.flake8
mypy.ini
pylintrc.toml
pytest.ini
src/testing

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
48 changes: 34 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# syntax=docker/dockerfile:1
ARG PYVER=3.11.5
ARG ALPTAG=3.17
FROM python:${PYVER}-alpine${ALPTAG} as builder
ARG EXENAME=es-fieldusage
ARG EXEPATH=/exe_path
ARG EXECUTABLE=${EXEPATH}/${EXENAME}
ARG LDPATH=${EXEPATH}/lib
ARG CONFIGPATH=/.config
ARG PYVER=3.12.5
ARG ALPTAG=3.20
FROM python:${PYVER}-alpine${ALPTAG} AS builder

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

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

# Install Curator locally
# Install project locally
RUN pip3 install .

# Build (or rather Freeze) Curator
RUN python3 setup.py build_exe
# Build (or rather Freeze) the project
RUN cxfreeze build

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

### End `builder` segment
Expand All @@ -35,12 +39,28 @@ RUN python3 post4docker.py
ARG ALPTAG
FROM alpine:${ALPTAG}
RUN apk --no-cache upgrade && apk --no-cache add openssl-dev expat
# The path `fieldusage_build` is from `builder` and `post4docker.py`
COPY --from=builder fieldusage_build /esfieldusage/
RUN mkdir /.esfieldusage

# The path `executable_build` is from `builder` and `post4docker.py`
ARG EXEPATH
COPY --from=builder executable_build ${EXEPATH}/

# This is for the Docker default filepath override
RUN mkdir /fileoutput
RUN chown nobody:nobody /fileoutput

ARG CONFIGPATH
RUN mkdir ${CONFIGPATH}

ARG LDPATH
ENV LD_LIBRARY_PATH=${LDPATH}

# COPY entrypoint.sh /

ARG EXECUTABLE
RUN echo '#!/bin/sh' > /entrypoint.sh
RUN echo >> /entrypoint.sh
RUN echo "${EXECUTABLE} \"\$@\"" >> /entrypoint.sh
RUN chmod +x /entrypoint.sh

USER nobody:nobody
ENV LD_LIBRARY_PATH /esfieldusage/lib:$LD_LIBRARY_PATH
ENTRYPOINT ["/esfieldusage/es-fieldusage"]
ENTRYPOINT ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2023 Elasticsearch <http://elastic.co> and contributors.
Copyright 2023-2024 Elasticsearch <http://elastic.co> and contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@

**Table of Contents**

- [Installation](#installation)
- [Description](#description)
- [Options](#top-level-help-output)
- [Command: stdout](#command-stdout-help-output)
- [Command: file](#command-file-help-output)
- [Command: show-indices](#command-show-indices-help-output)
- [Docker Usage](#docker-usage)
- [License](#license)
- [es-fieldusage](#es-fieldusage)
- [Installation](#installation)
- [Description](#description)
- [Top-level help output](#top-level-help-output)
- [Command: `stdout` help output](#command-stdout-help-output)
- [Command `file` help output](#command-file-help-output)
- [Command `show-indices` help output](#command-show-indices-help-output)
- [Docker usage](#docker-usage)
- [Docker build](#docker-build)
- [Docker run](#docker-run)
- [License](#license)

## Installation

Expand Down Expand Up @@ -55,22 +58,23 @@ Options:
--password TEXT Elasticsearch password
--request_timeout FLOAT Request timeout in seconds
--verify_certs / --no-verify_certs
Verify SSL/TLS certificate(s) [default: verify_certs]
Verify SSL/TLS certificate(s)
--ca_certs TEXT Path to CA certificate file or directory
--client_cert TEXT Path to client certificate file
--client_key TEXT Path to client key file
--loglevel [DEBUG|INFO|WARNING|ERROR|CRITICAL]
Log level
--logfile TEXT Log file
--logformat [default|ecs] Log output format
--blacklist TEXT Named entities will not be logged
-v, --version Show the version and exit.
-h, --help Show this message and exit.
Commands:
show-all-options Show all configuration options
stdout Output field usage information to the console
Learn more at https://github.com/untergeek/elastic-grab-bag/es_fieldusage
Learn more at https://github.com/untergeek/es-fieldusage
```

### Command: `stdout` help output
Expand All @@ -92,10 +96,10 @@ Options:
--show-unaccessed / --hide-unaccessed
Show unaccessed fields [default: hide-unaccessed]
--show-counts / --hide-counts Show field access counts [default: hide-counts]
--delimiter TEXT Value delimiter if access counts are shown [default: :]
--delimiter TEXT Value delimiter if access counts are shown [default: ,]
-h, --help Show this message and exit.
Learn more at https://github.com/untergeek/elastic-grab-bag/es_fieldusage
Learn more at https://github.com/untergeek/es-fieldusage
```

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

### Command `show-indices` help output
Expand All @@ -139,7 +143,7 @@ Usage: es-fieldusage show-indices SEARCH_PATTERN
Options:
-h, --help Show this message and exit.
Learn more at https://github.com/untergeek/elastic-grab-bag/es-fieldusage
Learn more at https://github.com/untergeek/es-fieldusage
```

## Docker usage
Expand Down
4 changes: 4 additions & 0 deletions docker_test/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Version: 1.1.1
Released: 24 August 2024

# License and Changelog at https://github.com/untergeek/es-docker-test-scripts
7 changes: 7 additions & 0 deletions docker_test/ansi_clean.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

ansi_clean () {
# This function is separate so nobody touches the control-M sequence
# in the second sed stream filter
echo ${1} | sed -e 's/\x1b\[[0-9;]*m//g' -e 's///g'
}
Expand Down
Loading

0 comments on commit c67ff46

Please sign in to comment.