[PR #4294] [misc]: Factorize SetFlagsFromEnvVars and support credentials #22934

Open
opened 2026-08-05 06:06:34 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/4294
Author: @Tom-Hubrecht
Created: 8/5/2025
Status: 🔄 Open

Base: mainHead: loadcredential


📝 Commits (1)

  • 07d7212 [misc]: Factorize SetFlagsFromEnvVars and add support for CREDENTIALS_DIRECTORY

📊 Changes

16 files changed (+77 additions, -121 deletions)

View changed files

📝 client/cmd/down.go (+1 -1)
📝 client/cmd/login.go (+1 -1)
📝 client/cmd/logout.go (+2 -1)
📝 client/cmd/profile.go (+2 -2)
📝 client/cmd/root.go (+2 -34)
📝 client/cmd/root_test.go (+2 -1)
📝 client/cmd/service_controller.go (+2 -2)
📝 client/cmd/service_installer.go (+2 -2)
📝 client/cmd/ssh.go (+2 -2)
📝 client/cmd/status.go (+1 -1)
📝 client/cmd/up.go (+2 -2)
relay/cmd/env.go (+0 -35)
📝 relay/cmd/root.go (+1 -1)
signal/cmd/env.go (+0 -35)
📝 signal/cmd/run.go (+1 -1)
util/flags.go (+56 -0)

📄 Description

Describe your changes

The code for setting up command flags values from environment variables was copied in three different places, this puts the helper function in the util package so that every component can use it. Furthermore, it now supports reading values from files in $CREDENTIALS_DIRECTORY, which allows direct integration with systemd's LoadCredential mechanism (but any platform can define such a variable and pass values as files).

Note however that it removes support from reading values from variables of the form WT_... which is very legacy.

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/4294 **Author:** [@Tom-Hubrecht](https://github.com/Tom-Hubrecht) **Created:** 8/5/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `loadcredential` --- ### 📝 Commits (1) - [`07d7212`](https://github.com/netbirdio/netbird/commit/07d721285f812c4ed70ff66762dd1f03a0fb49e2) [misc]: Factorize SetFlagsFromEnvVars and add support for CREDENTIALS_DIRECTORY ### 📊 Changes **16 files changed** (+77 additions, -121 deletions) <details> <summary>View changed files</summary> 📝 `client/cmd/down.go` (+1 -1) 📝 `client/cmd/login.go` (+1 -1) 📝 `client/cmd/logout.go` (+2 -1) 📝 `client/cmd/profile.go` (+2 -2) 📝 `client/cmd/root.go` (+2 -34) 📝 `client/cmd/root_test.go` (+2 -1) 📝 `client/cmd/service_controller.go` (+2 -2) 📝 `client/cmd/service_installer.go` (+2 -2) 📝 `client/cmd/ssh.go` (+2 -2) 📝 `client/cmd/status.go` (+1 -1) 📝 `client/cmd/up.go` (+2 -2) ➖ `relay/cmd/env.go` (+0 -35) 📝 `relay/cmd/root.go` (+1 -1) ➖ `signal/cmd/env.go` (+0 -35) 📝 `signal/cmd/run.go` (+1 -1) ➕ `util/flags.go` (+56 -0) </details> ### 📄 Description ## Describe your changes The code for setting up command flags values from environment variables was copied in three different places, this puts the helper function in the util package so that every component can use it. Furthermore, it now supports reading values from files in `$CREDENTIALS_DIRECTORY`, which allows direct integration with systemd's `LoadCredential` mechanism (but any platform can define such a variable and pass values as files). Note however that it removes support from reading values from variables of the form `WT_...` which is very legacy. ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [x] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 06:06:34 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#22934