Skip to content

[configoptional] programmatic usage is uneasy #13856

@atoulme

Description

@atoulme

Component(s)

No response

Describe the issue you're reporting

The configoptional.Optional struct does not allow programmatic setting of values. This is what we have to use instead:

rf := otlpreceiver.NewFactory()
cfg := rf.CreateDefaultConfig().(*otlpreceiver.Config)
_ = cfg.GRPC.Unmarshal(confmap.NewFromStringMap(map[string]any{"endpoint": fmt.Sprintf("%s:%d", listeningAddress, grpcPort)}))
_ = cfg.HTTP.Unmarshal(confmap.NewFromStringMap(map[string]any{"endpoint": fmt.Sprintf("%s:%d", listeningAddress, httpPort)}))

The same problem applies if say we try to explicitly the value to nil.

I seek that we add to the configoptional.Optional struct methods that allow to set values, including the case where the value is explicitly nil.

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions