Giter Site home page Giter Site logo

Comments (5)

dimabru avatar dimabru commented on May 18, 2024 1

I see. Can we achieve the same solution running datree config set token $TOKEN && datree test ...?
I'm trying to avoid multiple touch-points for token insertion. This can add complexity to debugging if we place the same token in multiple places with ambiguity regarding variable precedence.

This is not a constraint though, if adding a token flag is the best solution we can certainly do that and update docs for clarity

from datree.

kevholmes avatar kevholmes commented on May 18, 2024 1

I'll mock something up to see if we can get $TOKEN into the datree docker img that pre-commit runs. It's not something that I've run into in the documentation so it might be supported just undocumented. It makes sense to try and exhaust our potential solutions before adding more complexity to the app.

from datree.

kevholmes avatar kevholmes commented on May 18, 2024

Would you consider a PR to add in a --token flag to the CLI that accepts this parameter rather than an environment variable? Through this approach a user could configure their .pre-commit-config.yaml file like so:

repos:
- repo: https://github.com/datreeio/datree
  rev: 0.14.49
  hooks:
  - id: datree-docker
    args: ['--token abcd123456789']

If you're open to that approach I could mock something up to quickly test if this solution will work with the existing pre-commit-hooks.yaml file and the existing args being passed in using the docker_image language type in pre-commit.

from datree.

dimabru avatar dimabru commented on May 18, 2024

Hi @kevholmes ,
We actually have support for env variable. If you use DATREE_TOKEN (https://hub.datree.io/account-token#lz-how-it-works) you can set a token in runtime, which will work similarly to --token flag.
Using datree config set token <token> will also do the trick.

The issue here is adding this behavior to the docker run functionality, allowing docker to have the local token in the pre-commit step. One of the solutions can be doing docker run -e DATREE_TOKEN=$LOCAL_TOKEN with a script running beforehand updating LOCAL_TOKEN with the token located in ~/.datree/config.yaml if exists.

from datree.

kevholmes avatar kevholmes commented on May 18, 2024

Hey @dimabru,

Yeah, that's my issue with using the env var solution, there's not really any support for that with the docker_image type in pre-commit. We can pass in extra command line args for the cli invocation of datree but there's no documented way to use environment variables in such a way with pre-commit. I could try to write a test script up where we attempt to pass in an env-var through pre-commit but I do not believe it supports any kind of env var awareness.

from datree.

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.