Commit Graph

23 Commits

Author SHA1 Message Date
Pablo Baeyens 72c7d7f29a
[component] Bump maximum length for component names to 1024 characters (#10818)
#### Description

Bumps component name length limit to 1024 characters.

#### Link to tracking issue

Fixes #10816

#### Testing

Added some unit tests.
2024-08-07 06:59:59 -07:00
Matthew Wear 95902c19f5
[component] Restrict character set for component.ID name (#10674)
#### Description
While working on
https://github.com/open-telemetry/opentelemetry-collector/pull/10495 we
discovered that there are not any restrictions on the `name` field of a
`component.ID`. There are restrictions on the `type` field introduced in
#9208. This PR adds similar restrictions to `name`.

A type must
- have at least one character,
- start with an ASCII alphabetic character and
- can only contain ASCII alphanumeric characters and '_'.

I found that we need a slightly different set of rules for name as some
tests use a digit and others use a uuid as a name. A name is still
optional, but if it's provided it must:
- have at least one character,
- start with an ASCII alphanumeric character and
- can only contain ASCII alphanumeric characters, '_', and '-'.

I'd be willing to adjust these restrictions if anyone has any opinions
on what should or should not be allowed.

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes #10673

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Unit tests

<!--Describe the documentation added.-->
#### Documentation
Code comments

<!--Please delete paragraphs that you did not use before submitting.-->
2024-07-25 19:36:29 +02:00
Antoine Toulme 1912879c19
[component] Remove deprecated `component.UnmarshalConfig` (#10340)
#### Description
Remove deprecated `component.UnmarshalConfig`

#### Link to tracking issue
Fixes #7102

Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com>
Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-06-06 10:05:26 -07:00
Antoine Toulme b6bdc4ee5b
[chore] fix some typos and a use of deprecated Go API (#10347) 2024-06-06 08:04:30 -07:00
Antoine Toulme 9a21643a54
[config] Deprecate component.UnmarshalConfig (#9750)
**Description:**
This PR removes the top level if/else in `component.UnmarshalConfig`,
handling recursive state in the confmap.Conf object instead.
This PR deprecates `component.UnmarshalConfig` in favor of calling
directly `Unmarshal` on the confmap.Conf object.

**Link to tracking Issue:**
Fixes #7102
Fixes #7101

---------

Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
2024-05-29 11:07:52 +02:00
Ankit Patel 65cdb184f3
Add length limit to component (#9901)
Changes component.Type validation regex to only allow a max of 63
characters in a type name.

Fixes #9872

---------

Co-authored-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
2024-04-10 09:22:10 -07:00
Tyler Helmuth 9c5bf54880
[component] make Type implement MarshalText (#9856)
**Description:**
Adds `MarshalText` function so that `Type` can be properly marshaled as yaml.

**Link to tracking Issue:** Fixes https://github.com/open-telemetry/opentelemetry-collector/issues/9855
2024-03-27 13:22:52 -07:00
Pablo Baeyens b2693620ef
[component] Change component.Type underlying type to a struct (#9472)
**Description:** 

Follow up to #9414 and
open-telemetry/opentelemetry-collector-contrib/pull/31038.

**Link to tracking Issue:** Fixes #9208.
2024-03-06 12:56:32 +01:00
Pablo Baeyens 26c157e3bf
[component] Add MustNewType constructor for component.Type (#9414)
**Description:** 

- Adds `component.MustNewType` to create a type. This function panics if
the type has invalid characters. Add similar functions
`component.MustNewID` and `component.MustNewIDWithName`.
- Adds `component.Type.String` to recover the string
- Use `component.MustNewType`, `component.MustNewID`,
`component.MustNewIDWithName` and `component.Type.String` everywhere in
this codebase. To do this I changed `component.Type` into an opaque
struct and checked for compile-time errors.

Some notes:

1. All components currently on core and contrib follow this rule. This
is still breaking for other components.
2. A future PR will change this into a struct, to actually validate this
(right now you can just do `component.Type("anything")` to bypass
validation). I want to do this in two steps to avoid breaking contrib
tests: we first introduce this function, and after that we change into a
struct.

**Link to tracking Issue:** Updates #9208
2024-02-02 17:33:03 +01:00
Antoine Toulme 6155cc25dd
Make the option `WithErrorUnused` enabled by default when unmarshaling configuration (#9154)
**Description:**
Make the option `WithErrorUnused` enabled by default when unmarshaling
configuration
The option `WithErrorUnused` is now enabled by default, and a new option
`WithIgnoreUnused` is introduced to ignore
errors about unused fields.

**Link to tracking Issue:**
This relates to #7102 to some extent.

**Testing:**
N/A

**Documentation:**
N/A
2023-12-22 11:11:39 -08:00
Alex Boten 80d704deb4
[chore] use license shortform (#7694)
* [chore] use license shortform

To remain consistent w/ contrib repo, see https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/22052

Signed-off-by: Alex Boten <aboten@lightstep.com>

* make goporto

Signed-off-by: Alex Boten <aboten@lightstep.com>

---------

Signed-off-by: Alex Boten <aboten@lightstep.com>
2023-05-18 13:11:17 -07:00
Bogdan Drutu a2f0153679
[chore] replace the usage of interface{} with any (#7053)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2023-01-30 15:01:25 -08:00
Bogdan Drutu 7cb2d7622d
Remove deprecated comonent.Config.[ID|SetIDName]; Deprecate config.*Settings (#6718)
* Remove deprecated comonent.Config.[ID|SetIDName]; Deprecate config.*Settings

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

* Update .chloggen/rmcfgid-1.yaml

Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
2022-12-12 14:35:45 -08:00
Bogdan Drutu b4ff8ba397
[chore] remove unnecessary commment, Validate is no longer implemented by Settings (#6676)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-12-05 08:22:21 -08:00
Bogdan Drutu d0fe772781
Deprecate component.Config.ID(), add helper for obsreporttest (#5870)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-11-29 14:35:49 -08:00
Bogdan Drutu 1028e3d2a2
Deprecate special Configs for each component type, use a standard opaque Config (#6617)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-11-23 15:02:54 -08:00
Daniel Jaglowski bd269df482
Add connector factory (#6611) 2022-11-23 10:15:54 -08:00
Bogdan Drutu 30c9c7154b
Deprecate Unmarshal[*]Config in favor of UnmarshalConfig (#6613)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-11-23 10:15:39 -08:00
Bogdan Drutu 5376db4058
Add recursive validation check for configs (#6545)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-11-22 10:18:38 -08:00
Bogdan Drutu ae6cd6500c
Remove Validate() from Config interfaces and make it optional interface (#6544)
The reason is to remove every Config to include the "config.*Settings" structs, which is one of the functionality they offer.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2022-11-21 12:24:13 -08:00
Bogdan Drutu 86d886cdc7
Deprecate Config.Validate() in favor of component.ValidateConfig (#6572)
* Deprecate Config.Validate() in favor of component.ValidateConfig

This PR is "split" from https://github.com/open-telemetry/opentelemetry-collector/pull/6544, to avoid breaking changes and go via deprecation.

It is a bit hacky, but better than breaking everyone who uses this interface.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

* Update config/receiver.go

Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-authored-by: Dmitrii Anoshin <anoshindx@gmail.com>
2022-11-17 13:50:30 -08:00
Bogdan Drutu 0b08d53164
Change component.DataType enum value names to be consistent with other in the repo (#6488)
No deprecation, they were added in this cycle. Deprecated old formats are in config package.

Signed-off-by: Bogdan <bogdandrutu@gmail.com>

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-11-07 17:48:05 -08:00
Bogdan d6ed8246b6 Deprecate all types and funcs in config package
The main reason is to remove the circular dependency between the config (including sub-packages) and component. Here is the current state:
* component depends on config
* config/sub-package[grpc, http, etc.] depends on config & component

Because of this "circular" dependency, we cannot split for example "config" into its own module, only if all the other config sub-packages are also split.

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
2022-11-05 10:04:49 -07:00