Code Monkey home page Code Monkey logo

Comments (2)

SergioBenitez avatar SergioBenitez commented on June 3, 2024

Figment is working correctly, but what you've written does not match the configuration you're passing in. There are several items of concern.

#[serde(rename = "instance-host")]
pub instance_host: String,

By doing this, you're changing the field name to instance-host. As a result, a field passed in as instance_host will not be recognized. Maybe you meant to use serde(alias)?

Similar to the above, using figment_file_provider_adapter...

FileAdapter is not part of figment. Please consult that repository for issues relevant to that type.

As can be seen from code below, I have Env::split set correctly

I assume based on your intro text that you expect MASTODON_INSTANCE_HOST=foo to work with the following:

Figment::new().merge(Env::raw().split('_'))

For MASTODON_INSTANCE_HOST-foo, this would produce the equivalent of {mastodon={instance={host=foo}}}, as indicated in the docs. This does not match the structure you defined. Perhaps you want: Env::prefixed("MASTADON_"), to use serde(alias) instead of serde(rename), and then to extract to MastodonConfig directly. Or perhaps you need to split on __ instead; then MASTODON__INSTANCE_HOST would work, assuming you fix your structure.

from figment.

catuhana avatar catuhana commented on June 3, 2024

That all makes sense, sorry for creating a rushed-in issue without checking the library much. Thanks a lot!

from figment.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.