Skip to content

Commit

Permalink
Merge pull request #26 from cyberkov/feature-support-multiple-configs
Browse files Browse the repository at this point in the history
Feature: support multiple configs
  • Loading branch information
voxel01 authored Dec 9, 2024
2 parents f98c7d9 + 0b33285 commit 190436a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
10 changes: 10 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ The following parameters are available in the `otelcol` class:
* [`config_file_owner`](#-otelcol--config_file_owner)
* [`config_file_group`](#-otelcol--config_file_group)
* [`config_file_mode`](#-otelcol--config_file_mode)
* [`configs`](#-otelcol--configs)
* [`receivers`](#-otelcol--receivers)
* [`processors`](#-otelcol--processors)
* [`exporters`](#-otelcol--exporters)
Expand Down Expand Up @@ -150,6 +151,15 @@ mode of config_file

Default value: `'0644'`

##### <a name="-otelcol--configs"></a>`configs`

Data type: `Array[String]`

additional config files or resources to add. Since this can be environment variables, http urls or files
you are required to ensure the existence of a file!

Default value: `[]`

##### <a name="-otelcol--receivers"></a>`receivers`

Data type: `Hash[String, Hash]`
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
# group of config_file
# @param config_file_mode
# mode of config_file
# @param configs
# additional config files or resources to add. Since this can be environment variables, http urls or files
# you are required to ensure the existence of a file!
# @param receivers
# Hash for receivers config
# @param processors
Expand Down Expand Up @@ -61,6 +64,7 @@
String $config_file_owner = 'root',
String $config_file_group = 'root',
Stdlib::Filemode $config_file_mode = '0644',
Array[String] $configs = [],
Hash[String, Hash] $receivers = {},
Hash[String, Hash] $processors = {},
Hash[String, Hash] $exporters = {},
Expand Down
11 changes: 11 additions & 0 deletions spec/classes/otelcol_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@
}
end

context 'with configs' do
let :params do
{
configs: ['customconfig.yaml', 'env:MY_CONFIG_IN_AN_ENVVAR', 'https://server/config.yaml', '"yaml:exporters::debug::verbosity: normal"']
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('otelcol-environment').with_content(%r{--config=/etc/otelcol/config.yaml --config=customconfig.yaml --config=env:MY_CONFIG_IN_AN_ENVVAR --config=https://server/config.yaml --config="yaml:exporters::debug::verbosity: normal"}) }
end

context 'with config_file owner' do
let :params do
{
Expand Down
2 changes: 1 addition & 1 deletion templates/environment.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

# Command-line options for the <%= scope.lookupvar('otelcol::package_name')%> service.
# Run `/usr/bin/<%= scope.lookupvar('otelcol::package_name') %> --help` to see all available options.
OTELCOL_OPTIONS="<%= scope.lookupvar('otelcol::run_options')%> --config=<%= scope.lookupvar('otelcol::config_file')%>"
OTELCOL_OPTIONS="<%= scope.lookupvar('otelcol::run_options')%> --config=<%= scope.lookupvar('otelcol::config_file') %><% unless scope.lookupvar('otelcol::configs').empty? -%> --config=<%= scope.lookupvar('otelcol::configs').join(' --config=') %><% end -%>"

0 comments on commit 190436a

Please sign in to comment.