Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: support multiple configs #26

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -%>"
Loading