Skip to content

Commit

Permalink
Use safe navigation operator for container image name and tag (#53)
Browse files Browse the repository at this point in the history
* Use safe navigation operator for container image name and tag

Use safe navigation operator to get container.image.name and container.image.tag in order to avoid splitting a nil string

* Use docker compose

* Update docker container name syntax
  • Loading branch information
dyladan authored Oct 4, 2024
1 parent 9e6594e commit 3a82157
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions example/configmap-saas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ data:
status ${ record.dig(:log, :severity) || record.dig(:log, :level) || (record["log"] =~ /\W?\berror\b\W?/i ? "ERROR" : (record["log"] =~ /\W?\bwarn\b\W?/i ? "WARN" : (record["log"] =~ /\W?\bdebug\b\W?/i ? "DEBUG" : (record["log"] =~ /\W?\binfo\b\W?/i ? "INFO" : "NONE")))) }
content ${record["log"]}
container.name ${record.dig("kubernetes","container_name")}
container.image.name ${record.dig("kubernetes","container_image").split(':')[0]}
container.image.tag ${record.dig("kubernetes","container_image").split(':')[1]}
container.image.name ${record.dig("kubernetes","container_image")&.split(':')&.[](0)}
container.image.tag ${record.dig("kubernetes","container_image")&.split(':')&.[](1)}
dt.kubernetes.node.name ${record.dig("kubernetes","host")}
dt.kubernetes.cluster.id "#{ENV['CLUSTER_ID']}"
dt.kubernetes.node.system_uuid ${File.read("/sys/devices/virtual/dmi/id/product_uuid").strip}
Expand Down
6 changes: 3 additions & 3 deletions test/integration_fluent/fluent_plugin_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

class TestFluentPluginIntegration < Test::Unit::TestCase
def setup
puts `cd test/integration_fluent/fixtures && docker-compose up -d --force-recreate --build`
puts `cd test/integration_fluent/fixtures && docker compose up -d --force-recreate --build`
puts 'waiting 5s for integration test to start'
sleep 5
end

def teardown
puts `cd test/integration_fluent/fixtures && docker-compose down`
puts `cd test/integration_fluent/fixtures && docker compose down`
end

def test_fluent_plugin_integration
Expand All @@ -41,7 +41,7 @@ def test_fluent_plugin_integration
puts 'waiting 10s for output plugin to flush'
sleep 10

logs = `docker logs fixtures_logsink_1`
logs = `docker logs fixtures-logsink-1`

line1 = '[{"foo":"bar"},{"abc":"def"},{"xyz":"123"},{"abc":"def"},{"xyz":"123"}]'
line2 = '[{"abc":"def"},{"xyz":"123"}]'
Expand Down

0 comments on commit 3a82157

Please sign in to comment.