From 120ecb631a83c5727157e10991b7f79966c0e2b3 Mon Sep 17 00:00:00 2001 From: Github Actions Date: Thu, 26 Sep 2024 15:48:48 +0000 Subject: [PATCH 01/12] Version bump [ci skip] --- box.json | 2 +- changelog.md | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/box.json b/box.json index 629286c..e652ff2 100644 --- a/box.json +++ b/box.json @@ -2,7 +2,7 @@ "name":"Elasticsearch for the Coldbox Framework", "author":"Ortus Solutions Date: Tue, 5 Nov 2024 08:56:08 -0500 Subject: [PATCH 02/12] CI - Upgrade checkout action to v4 - fixes deprecation warning --- .github/workflows/ci.yml | 2 +- .github/workflows/gh-release.yml | 2 +- .github/workflows/pr.yml | 2 +- .github/workflows/tests.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32a123a..6e77f79 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout Repository - uses: actions/checkout@v3.2.0 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/gh-release.yml b/.github/workflows/gh-release.yml index 5d77f1a..9bbe2a2 100644 --- a/.github/workflows/gh-release.yml +++ b/.github/workflows/gh-release.yml @@ -10,7 +10,7 @@ jobs: create-release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.2.0 + - uses: actions/checkout@v4 - uses: taiki-e/create-gh-release-action@v1.5.0 with: # Produced by the build/Build.cfc diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e6847eb..815e430 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout Repository - uses: actions/checkout@v3.2.0 + uses: actions/checkout@v4 - uses: Ortus-Solutions/commandbox-action@v1.0.2 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b5251c0..3cb0836 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,7 +40,7 @@ jobs: experimental: true steps: - name: Checkout Repository - uses: actions/checkout@v3.2.0 + uses: actions/checkout@v4 - name: Setup Java uses: actions/setup-java@v3.9.0 From 396f2d0131a0b01e7f656a75279d003501344dd3 Mon Sep 17 00:00:00 2001 From: Michael Born Date: Tue, 5 Nov 2024 08:57:46 -0500 Subject: [PATCH 03/12] CI - Bump create-gh-release-action to drop node 16 deprecation warning --- .github/workflows/gh-release.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gh-release.yml b/.github/workflows/gh-release.yml index 9bbe2a2..7898a59 100644 --- a/.github/workflows/gh-release.yml +++ b/.github/workflows/gh-release.yml @@ -11,9 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: taiki-e/create-gh-release-action@v1.5.0 + - uses: taiki-e/create-gh-release-action@v1.8.2 with: # Produced by the build/Build.cfc changelog: changelog.md - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} From 94356039c44adf30728e2717fdfae1850bd8de81 Mon Sep 17 00:00:00 2001 From: Michael Born Date: Tue, 5 Nov 2024 09:15:43 -0500 Subject: [PATCH 04/12] CI - Try disabling authentication for ES 8 CI tests --- build/resources/elasticsearch.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/resources/elasticsearch.yml b/build/resources/elasticsearch.yml index 0069792..ef84104 100644 --- a/build/resources/elasticsearch.yml +++ b/build/resources/elasticsearch.yml @@ -2,4 +2,7 @@ discovery.type: "single-node" cluster.name: "docker-cluster" xpack.security.enabled: "false" network.host: 0.0.0.0 -path.repo: ["/tmp"] \ No newline at end of file +path.repo: ["/tmp"] + +# ES 8 requires explicit setting of the following +xpack.security.enabled: false \ No newline at end of file From 8cecae90bdd4578ec66b4f70ca06fedb2b509d08 Mon Sep 17 00:00:00 2001 From: Michael Born Date: Tue, 5 Nov 2024 09:25:38 -0500 Subject: [PATCH 05/12] CI - Re-enable auth for ES 8, it seemed to break ALL tests --- build/resources/elasticsearch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/resources/elasticsearch.yml b/build/resources/elasticsearch.yml index ef84104..403241d 100644 --- a/build/resources/elasticsearch.yml +++ b/build/resources/elasticsearch.yml @@ -5,4 +5,4 @@ network.host: 0.0.0.0 path.repo: ["/tmp"] # ES 8 requires explicit setting of the following -xpack.security.enabled: false \ No newline at end of file +# xpack.security.enabled: false \ No newline at end of file From 740b2e8d870aec8025b31730b41d0be442c4a078 Mon Sep 17 00:00:00 2001 From: Michael Born Date: Tue, 5 Nov 2024 09:26:09 -0500 Subject: [PATCH 06/12] CI - More action version upgrades to avoid soon-coming deprecations --- .github/workflows/ci.yml | 2 +- .github/workflows/tests.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e77f79..d832788 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: fetch-depth: 0 - name: Setup Java - uses: actions/setup-java@v3.9.0 + uses: actions/setup-java@v4 with: distribution: "temurin" java-version: "11" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3cb0836..31781b1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,7 +43,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Java - uses: actions/setup-java@v3.9.0 + uses: actions/setup-java@v4 with: distribution: "temurin" java-version: "${{ matrix.javaVersion }}" @@ -62,7 +62,7 @@ jobs: - name: Scan project file system id: scan - uses: anchore/scan-action@v2 + uses: anchore/scan-action@v5 with: path: "./" fail-build: true @@ -108,7 +108,7 @@ jobs: - name: Upload Test Results to Artifacts if: always() - uses: actions/upload-artifact@v3.1.1 + uses: actions/upload-artifact@v4 with: name: test-results-${{ matrix.cfengine }} path: | @@ -121,7 +121,7 @@ jobs: - name: Upload Debugging Log To Artifacts if: ${{ failure() }} - uses: actions/upload-artifact@v3.1.1 + uses: actions/upload-artifact@v4 with: name: Failure Debugging Info - ${{ matrix.cfengine }} path: | From e192bfcdb4dce706d610b01018508166467222e6 Mon Sep 17 00:00:00 2001 From: Jon Clausen Date: Sun, 10 Nov 2024 10:54:33 -0500 Subject: [PATCH 07/12] Add onLogstashEntryCreate interception point, add mode to saveAll --- ModuleConfig.cfc | 3 ++- box.json | 2 +- changelog.md | 5 +++++ models/io/HyperClient.cfc | 19 ++++++++++++++++--- models/util/Util.cfc | 3 +++ 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/ModuleConfig.cfc b/ModuleConfig.cfc index 1d606ac..944e4ab 100644 --- a/ModuleConfig.cfc +++ b/ModuleConfig.cfc @@ -75,7 +75,8 @@ component { interceptorSettings = { customInterceptionPoints : [ "cbElasticsearchPreSave", - "cbElasticsearchPostSave" + "cbElasticsearchPostSave", + "onLogstashEntryCreate" ] }; diff --git a/box.json b/box.json index e652ff2..4a280bd 100644 --- a/box.json +++ b/box.json @@ -1,6 +1,6 @@ { "name":"Elasticsearch for the Coldbox Framework", - "author":"Ortus Solutions ", "location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbelasticsearch/@build.version@/cbelasticsearch-@build.version@+@build.number@.zip", "version":"3.4.2", "slug":"cbelasticsearch", diff --git a/changelog.md b/changelog.md index 4c9340d..3c2da3c 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `onLogstashEntryCreate` interception point, to allow influencing and additions to final log object +- Add `mode` argument to client `saveAll` method to allow for a `create` mode to be used for data streams + ## [3.4.1] - 2024-09-26 ### Added diff --git a/models/io/HyperClient.cfc b/models/io/HyperClient.cfc index 25aace2..ed122a1 100644 --- a/models/io/HyperClient.cfc +++ b/models/io/HyperClient.cfc @@ -1230,7 +1230,8 @@ component accessors="true" threadSafe singleton { array function saveAll( required array documents, boolean throwOnError = false, - struct params = {} + struct params = {}, + string mode = "update" ){ var requests = []; @@ -1259,10 +1260,22 @@ component accessors="true" threadSafe singleton { } } + var opAction = { "#mode#" : { "_index" : doc.getIndex() } }; + + if( if( !isNull( doc.getId() ) ) ){ + opAction[ mode ][ "_id" ] = doc.getId(); + } + + var docAction = { "doc" : memento }; + + if( mode == "update" ){ + docAction[ "doc_as_upsert" ] = true; + } + requests.append( [ - { "update" : { "_index" : doc.getIndex(), "_id" : doc.getId() } }, - { "doc" : memento, "doc_as_upsert" : true } + opAction, + docAction ], true ); diff --git a/models/util/Util.cfc b/models/util/Util.cfc index 35b44fc..9d30370 100644 --- a/models/util/Util.cfc +++ b/models/util/Util.cfc @@ -1,6 +1,7 @@ component accessors="true" singleton { property name="appEnvironment" inject="box:setting:environment"; + property name="interceptorService" inject="coldbox:InterceptorService"; /** * Ensures a CF native struct is returned ( allowing for dot-notation ) @@ -158,6 +159,8 @@ component accessors="true" singleton { } generateLogEntrySignature( logObj ); + + interceptorService.announce( "onLogstashEntryCreate", { "entry" : logObj } ); } /** From d4e7763cd84c2cd55bfefd62b7139dcd857b5de7 Mon Sep 17 00:00:00 2001 From: Jon Clausen Date: Sun, 10 Nov 2024 11:03:08 -0500 Subject: [PATCH 08/12] syntax fix --- models/io/HyperClient.cfc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/io/HyperClient.cfc b/models/io/HyperClient.cfc index ed122a1..0e71703 100644 --- a/models/io/HyperClient.cfc +++ b/models/io/HyperClient.cfc @@ -1262,7 +1262,7 @@ component accessors="true" threadSafe singleton { var opAction = { "#mode#" : { "_index" : doc.getIndex() } }; - if( if( !isNull( doc.getId() ) ) ){ + if( !isNull( doc.getId() ) ){ opAction[ mode ][ "_id" ] = doc.getId(); } From 9e2e2ce12241e0912e16dddf4cc4a965ccd740e2 Mon Sep 17 00:00:00 2001 From: Jon Clausen Date: Sun, 10 Nov 2024 11:05:24 -0500 Subject: [PATCH 09/12] fix artifact naming --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 31781b1..cada01a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -110,7 +110,7 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: - name: test-results-${{ matrix.cfengine }} + name: test-results-${{ matrix.cfengine }}-${{ matrix.coldboxVersion }}-jdk${{ matrix.javaVersion }}-es${{ matrix.ELASTICSEARCH_VERSION }} path: | test-harness/tests/results/**/* From 7c8db32ae22727b36640ea6e93a604e4b0f413f0 Mon Sep 17 00:00:00 2001 From: Jon Clausen Date: Sun, 10 Nov 2024 11:06:33 -0500 Subject: [PATCH 10/12] add more info to failure debugging log --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cada01a..45ee0cc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -123,7 +123,7 @@ jobs: if: ${{ failure() }} uses: actions/upload-artifact@v4 with: - name: Failure Debugging Info - ${{ matrix.cfengine }} + name: Failure Debugging Info - ${{ matrix.cfengine }} | Coldbox ${{ matrix.coldboxVersion }} ( jdk${{ matrix.javaVersion }}-es${{ matrix.ELASTICSEARCH_VERSION }} ) path: | .engine/**/logs/* .engine/**/WEB-INF/cfusion/logs/* From e435aa5494b005bda897f87fe5f5d12551164d79 Mon Sep 17 00:00:00 2001 From: Jon Clausen Date: Sun, 10 Nov 2024 11:15:29 -0500 Subject: [PATCH 11/12] increase sleep time for GHA --- test-harness/tests/specs/unit/AppenderServiceTest.cfc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-harness/tests/specs/unit/AppenderServiceTest.cfc b/test-harness/tests/specs/unit/AppenderServiceTest.cfc index 6e34d6b..ba4a48b 100644 --- a/test-harness/tests/specs/unit/AppenderServiceTest.cfc +++ b/test-harness/tests/specs/unit/AppenderServiceTest.cfc @@ -109,7 +109,7 @@ component extends="coldbox.system.testing.BaseTestCase" { "Test message", 4 ); - sleep( 1000 ); + sleep( 1500 ); expect( getDataStreamCount( appender.getProperty( "dataStreamPattern" ) ) ).toBe( dataStreamCount + 1 ); } ); From ee1300e952fdc681d0a0af86fe0aa1f1034bfe9d Mon Sep 17 00:00:00 2001 From: Jon Clausen Date: Sun, 10 Nov 2024 11:17:15 -0500 Subject: [PATCH 12/12] changelog for v3.4.1 --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 3c2da3c..3c350ce 100644 --- a/changelog.md +++ b/changelog.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * * * -## [Unreleased] +## [3.4.1] - 2024-11-10 ### Added