Giter Club home page Giter Club logo

Comments (2)

trulede avatar trulede commented on September 27, 2024 1

Seems like the the code is only checking if the variable exists, not if it is also set.

Expectation is that nil or "" (empty string) would cause such a variable to fail the requires checks.

Documentation has this:

Variables set to empty zero length strings, will pass the requires check.

which is not so good. I really have to question that, both in what it means (what is an empty and zero length string), and if such behavior is even useful. The code behind variables is quite involved, so in many places you find variables being defaulted to an empty string (i.e. "") and other things.

Again with the documentation:

If you want to check that certain variables are set before running a task then you can use requires. This is useful when might not be clear to users which variables are needed, or if you want clear message about what is required. Also some tasks could have dangerous side effects if run with un-set variables.

which seems OK, but misses the use-cases where one task calls another with non-trivial variable passing, and included task files ... these are cases where requires would be useful. We have it in our task files, but it only acts as documentation for us (since it does not work).

I think the required checks should be:

  1. Does the variable exist (in the scope of a compiled task).
  2. Is the variable set.
  3. Is the variable set to a string of length greater than 0.

In the case that 3 would not be accepted as part of the implementation, then we need a way to set a variable to nil via the template engine (e.g a slim sprig function).

from task.

trulede avatar trulede commented on September 27, 2024

Seems like the the code is only checking if the variable exists, not if it is also set.

Expectation is that nil or "" (empty string) would cause such a variable to fail the requires checks.

from task.

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.