Skip to content

Commit

Permalink
[envprovider] Add README file (#12499)
Browse files Browse the repository at this point in the history
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Use mdatagen for the env provider. This switches the package test to be
generated and adds an autogenerated section to the readme.

I've also populated the readme with basic usage information.

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes
#12465
  • Loading branch information
evan-bradley authored Feb 26, 2025
1 parent 58f3efb commit e6b1e92
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
38 changes: 38 additions & 0 deletions confmap/provider/envprovider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Environment Variable Provider

<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [stable] |
| Distributions | [core], [contrib], [k8s], [otlp] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector?query=is%3Aissue%20is%3Aopen%20label%3Aprovider%2Fenvprovider%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aopen+is%3Aissue+label%3Aprovider%2Fenvprovider) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector?query=is%3Aissue%20is%3Aclosed%20label%3Aprovider%2Fenvprovider%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aclosed+is%3Aissue+label%3Aprovider%2Fenvprovider) |

[stable]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#stable
[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
[k8s]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-k8s
[otlp]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-otlp
<!-- end autogenerated section -->

## Usage

The scheme for this provider is `env`. Usage looks like the following:

```text
env:NAME_OF_ENVIRONMENT_VARIABLE
```

To use default values when the environment variable has not been set, you can
include a suffix to specify it:

```text
env:NAME_OF_ENVIRONMENT_VARIABLE:-default_value
```

Environment variables must match the following regular expression. That is, they
must be at least one character, start with a letter or underscore, and can only
include letters, numbers, and underscores.

```text
^[a-zA-Z_][a-zA-Z0-9_]*$
```

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions confmap/provider/envprovider/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type: env
github_project: open-telemetry/opentelemetry-collector

status:
class: provider
stability:
stable: [provider]
distributions: [core, contrib, k8s, otlp]
2 changes: 2 additions & 0 deletions confmap/provider/envprovider/provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:generate mdatagen metadata.yaml

package envprovider // import "go.opentelemetry.io/collector/confmap/provider/envprovider"

import (
Expand Down

0 comments on commit e6b1e92

Please sign in to comment.