Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not set empty environment variables #4193

Merged
merged 18 commits into from
Dec 2, 2024

Conversation

zc-devs
Copy link
Contributor

@zc-devs zc-devs commented Oct 5, 2024

Related #1911, #1913.

While #1913 fixes manual trigger and numbers/booleans for automatic triggers, it pollutes Pod's environment with empty strings:

        - name: CI_STEP_NAME
        - name: CI_WORKFLOW_NUMBER
          value: '1'
        - name: CI_COMMIT_TARGET_BRANCH
        - name: CI_COMMIT_REFSPEC
        - name: CI_STEP_NUMBER
          value: '0'
        - name: CI_COMMIT_PULL_REQUEST

and refactor
@qwerty287
Copy link
Contributor

Not sure, but I think there's a difference between "end var is empty" and "an env var is not set".

@zc-devs
Copy link
Contributor Author

zc-devs commented Oct 6, 2024

Before #1913, default values (empty string, zero, false) are filtered. It caused confusing, when I run pipeline manually. So, I removed it entirely. Now, there are a lot of empty string vars.
I think filtering zeros and falses is a mistake, because it is valid value. If nothing/not set needs to be expressed, null pointer should be used in the model.
However, it is a little bit different for strings, IMO. What's the meaning of empty string? The same as null, if we are talking about the model. Therefore this PR.

This PR should not break manual trigger, because manual envs is a different map, and this PR filters only empty strings in transition from model to envs.
Besides, looking at #1913 tests, there's no test with empty value. They are filtered in UI, as I remember correctly. So, the same logic, as in this PR.

@6543 6543 added the breaking will break existing installations if no manual action happens label Oct 6, 2024
@qwerty287 qwerty287 added this to the 3.0.0 milestone Nov 17, 2024
Copy link
Contributor

@pat-s pat-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see arguments for both sides. I am not against a merge if this change gets properly documented, so that users can adjust their potential checks against empty/non-empty vars to now check for the existence.

While writing this, I realized that removing vars entirely makes checking a bit more cumbersome as one first needs to check for existence and then chain a check for a possible matching value.

@zc-devs We're currently curating issues for 3.0. If you want to get this into 3.0, please rebase and address the review in the next days.

docs/docs/20-usage/50-environment.md Outdated Show resolved Hide resolved
docs/docs/20-usage/50-environment.md Outdated Show resolved Hide resolved
docs/docs/20-usage/50-environment.md Outdated Show resolved Hide resolved
docs/docs/20-usage/50-environment.md Outdated Show resolved Hide resolved
docs/docs/20-usage/50-environment.md Outdated Show resolved Hide resolved
docs/docs/20-usage/50-environment.md Outdated Show resolved Hide resolved
@zc-devs
Copy link
Contributor Author

zc-devs commented Nov 25, 2024

I don't care, TBH.
Do maintainers want? Vote on this comment: 👍 want, 👎 don't.
It doesn't make sense to merge, correct and write the docs, if someone disagree.

@pat-s
Copy link
Contributor

pat-s commented Nov 26, 2024

You opened this PR, so I guess you care at least a little.

Nobody objects and I am also fine with it, so it is (still) up to you to rebase and get it in :)

zc-devs and others added 9 commits November 27, 2024 17:45
Co-authored-by: Patrick Schratz <patrick.schratz@gmail.com>
Co-authored-by: Patrick Schratz <patrick.schratz@gmail.com>
Co-authored-by: Patrick Schratz <patrick.schratz@gmail.com>
Co-authored-by: Patrick Schratz <patrick.schratz@gmail.com>
Co-authored-by: Patrick Schratz <patrick.schratz@gmail.com>
Co-authored-by: Patrick Schratz <patrick.schratz@gmail.com>
# Conflicts:
#	pipeline/frontend/metadata/environment.go
#	server/pipeline/stepbuilder/metadata_test.go
@woodpecker-bot
Copy link
Contributor

woodpecker-bot commented Dec 1, 2024

Deployment of preview was torn down

@pat-s
Copy link
Contributor

pat-s commented Dec 1, 2024

@zc-devs test failures

@pat-s pat-s merged commit 532c3e3 into woodpecker-ci:main Dec 2, 2024
6 of 7 checks passed
@woodpecker-bot woodpecker-bot mentioned this pull request Dec 2, 2024
1 task
@woodpecker-bot woodpecker-bot mentioned this pull request Dec 14, 2024
1 task
pat-s added a commit that referenced this pull request Dec 18, 2024
Co-authored-by: Patrick Schratz <patrick.schratz@gmail.com>
pat-s added a commit that referenced this pull request Dec 18, 2024
Co-authored-by: Patrick Schratz <patrick.schratz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking will break existing installations if no manual action happens
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants