Code Monkey home page Code Monkey logo

Comments (12)

smainz avatar smainz commented on June 11, 2024 1

Yes, it is causes upstream, but I do not know if it can be called an issue.

If we change the Dockerfileto something like this:

RUN echo "/var/lib/woodpecker/woodpecker.sqlite" > /etc/woodpecker-datasource.conf
ENV WOODPECKER_DATABASE_DATASOURCE_FILE=/etc/woodpecker-datasource.conf

the problem should vanish.

If the user does set -e WOODPECKER_DATABASE_DATASOURCE... this will take precedence and if he sets -e WOODPECKER_DATABASE_DATASOURCE_FILE...it will overwrite the setting in the Dockerfile.

from woodpecker.

qwerty287 avatar qwerty287 commented on June 11, 2024 1

But we get this flag from Env via os package:

Yes, I know, I mean we're using the FilePath feature of urfave/cli.

Note that default values set from file (e.g. FilePath) take precedence over default values set from the environment (e.g. EnvVar).

Weird, then this should work 🤔 Or do I misunderstand something completely here?

from woodpecker.

zc-devs avatar zc-devs commented on June 11, 2024 1

Yeah, we need more gold tests :) There are no open issues about precedence. So, should work...

from woodpecker.

smainz avatar smainz commented on June 11, 2024 1

Precedence rules are different https://cli.urfave.org/v2/examples/flags/#precedence

Envelope var before file.

from woodpecker.

smainz avatar smainz commented on June 11, 2024 1

In my oppinion, the env var should take precedence to the content of some file.

The shorter the lifetime of a flag the higher the precedence. Rational: The user wants to override some argument for the next execution of a program without much hazzle.

So

  1. command line arg
  2. Env var
  3. Some file

Shall I post a PR for changing the Dockerfile?

from woodpecker.

zc-devs avatar zc-devs commented on June 11, 2024

Only database settings don't work, right? Do other (WOODPECKER_GRPC_SECRET_FILE, WOODPECKER_AGENT_SECRET_FILE, WOODPECKER_GITEA_CLIENT_FILE, WOODPECKER_GITEA_SECRET_FILE) settings work as intended?

the env var WOODPECKER_DATABASE_DATASOURCE is set in the Dockerfile and takes precedence

There

from woodpecker.

smainz avatar smainz commented on June 11, 2024

Yes, it is only the datasource, others work as expected.

I do not have an idea of what could be changed. The code uses a sqlite file relative to the executable, but this can not be used with docker, as yoiu can not mount a volume there.

from woodpecker.

zc-devs avatar zc-devs commented on June 11, 2024

I think we should process WOODPECKER_DATABASE_DATASOURCE_FILE with higher priority than WOODPECKER_DATABASE_DATASOURCE as it is supposed to be more secure. So, that is is not a documentation issue.

from woodpecker.

qwerty287 avatar qwerty287 commented on June 11, 2024

It looks like this is an upstream issue of https://github.com/urfave/cli because we're directly using the feature:

FilePath: os.Getenv("WOODPECKER_DATABASE_DATASOURCE_FILE"),

from woodpecker.

zc-devs avatar zc-devs commented on June 11, 2024

It looks like this is an upstream issue of https://github.com/urfave/cli because we're directly using the feature

But we get this flag from Env via os package:

- FilePath: os.Getenv("WOODPECKER_DATABASE_DATASOURCE_FILE"),
+ FilePath: "/etc/mysql/password",

Note that default values set from file (e.g. FilePath) take precedence over default values set from the environment (e.g. EnvVar).

Also If EnvVars contains more than one string, the first environment variable that resolves is used.

Precedence.

from woodpecker.

qwerty287 avatar qwerty287 commented on June 11, 2024

Shall I post a PR for changing the Dockerfile?

Would be fine for me.

from woodpecker.

6543 avatar 6543 commented on June 11, 2024

ah now i know where it did come from :D

please dont fix bugs in the wrong place ... this bugfix would e.g. not fix it for anything not using docker

(...yes it might not be a problem as that environments dont have preset things... but it still will exist)

from woodpecker.

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.