Giter Club home page Giter Club logo

Comments (10)

lamont-granquist avatar lamont-granquist commented on July 19, 2024

@wrightp it looks like we're getting scalars or arrays of scalars back from the mixlib-install API here, depending on conditions, which should probably be fixed in mixlib-install so it returns either an array or a scalar?

from chef_client_updater.

wrightp avatar wrightp commented on July 19, 2024

#artifact_info will return a scalar if an exact artifact is found based on the query. If multiple artifacts match the query it will return an array of scalars for all matching artifacts. The team has had several discussions on whether to always return an array or to behave as it does now. If you have input please share.

from chef_client_updater.

lamont-granquist avatar lamont-granquist commented on July 19, 2024

it should be always array.

i'd actually state more strongly that ruby return types should be considered like the /should/ be strongly typed so they're predictable. also some of the positively worst bugs i've seen in the chef client codebase have come from having instance variables like @url duck-typing and being settable to either a String or a URI -- which is slick and works fine until it all goes horribly wrong and become nearly impossible for smart people to reason about the behavior. i'm actually somewhat skeptical as well about automatic coercion on the input side of methods, and the stuff like #to_s'ing an input parameter so you can use strings, or symbols or anything that stringifies is convenient but also can be very annoying down the road. sometimes its better to be strict and only accept one or the other and force the caller to do the explicit coercion (its possible that most of the time i've seen that go badly is the prior example where state gets stored which can be symbol, a string, or any other object that #to_ses without explicit coercion and then down the road you buy yourself a heap of pain when someone feeds you a String when conventionally everyone has been using symbols and some consumer of the state explodes because you didn't understand the contract on the state was so loose).

TL;DR: strongly typed languages have some very good points.

from chef_client_updater.

wrightp avatar wrightp commented on July 19, 2024

Thanks. I concur. I'll propose this for 4.0.

from chef_client_updater.

lamont-granquist avatar lamont-granquist commented on July 19, 2024

its easy enough to coerce it to an array here as well, so i can fix this bug and get this issue closed

from chef_client_updater.

lamont-granquist avatar lamont-granquist commented on July 19, 2024

so @wrightp do i want .first or .last? i'm assuming .first?

Mixlib::Versioning.parse(Array.new(mixlib_install.artifact_info).first.version)

from chef_client_updater.

wrightp avatar wrightp commented on July 19, 2024

I have always used first in this case. All artifacts will be of the same version

from chef_client_updater.

lamont-granquist avatar lamont-granquist commented on July 19, 2024

ah i get it, cool.

from chef_client_updater.

wrightp avatar wrightp commented on July 19, 2024

To elaborate... The scalar value will be returned based on platform, platform version, architecture, product, product version, channel. The array will return all available platform permutations of channel, product, product versions if no platform information is provided to the constructor.

from chef_client_updater.

Stromweld avatar Stromweld commented on July 19, 2024

@lamont-granquist Is 3.x going to be released soon with this fix in it?

from chef_client_updater.

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.