misc: add proper parsing of token for org relay#44
Merged
sheensantoscapadngan merged 2 commits intomainfrom Oct 23, 2025
Merged
misc: add proper parsing of token for org relay#44sheensantoscapadngan merged 2 commits intomainfrom
sheensantoscapadngan merged 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Added environment variable parsing for the token parameter in the relay systemd install command. The change allows users to specify the INFISICAL_TOKEN via environment variable in addition to the --token flag, consistent with how relay-auth-secret is already handled.
Key changes:
- Modified
relaySystemdInstallCmdto useGetCmdFlagOrEnvWithDefaultValuefor token parsing (packages/cmd/relay.go:170) - Added
INFISICAL_TOKEN_ENV_NAMEconstant to centralize the env var name (packages/gateway-v2/constants.go:16) - Updated error message to reflect both flag and env parsing
Improvements:
- The change follows existing patterns in the codebase (similar to how
relay-auth-secretis handled on line 204) - Validation logic at line 213-214 still works correctly to ensure token is required for non-instance types
Confidence Score: 4/5
- This PR is safe to merge with minimal risk
- The changes are straightforward and follow existing patterns in the codebase. The logic correctly handles token parsing from both flags and environment variables, with proper validation. One minor style issue was identified regarding hardcoded string usage in a different file (systemd.go), but this doesn't affect functionality.
- No files require special attention - changes are simple and consistent with existing code patterns
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| packages/cmd/relay.go | 4/5 | Added env variable parsing for token in systemd install command; error message updated appropriately |
| packages/gateway-v2/constants.go | 5/5 | Added INFISICAL_TOKEN_ENV_NAME constant for consistency |
Sequence Diagram
sequenceDiagram
participant User
participant CLI as relay systemd install
participant Util as GetCmdFlagOrEnvWithDefaultValue
participant Systemd as InstallRelaySystemdService
participant FS as File System
User->>CLI: sudo infisical relay systemd install
CLI->>Util: GetCmdFlagOrEnvWithDefaultValue("token", ["INFISICAL_TOKEN"], "")
Util->>Util: Check --token flag
alt Flag not empty
Util-->>CLI: Return flag value
else Flag empty
Util->>Util: Check INFISICAL_TOKEN env
alt Env not empty
Util-->>CLI: Return env value
else Env empty
Util-->>CLI: Return "" (default)
end
end
CLI->>CLI: Validate: if type != "instance" && token == ""
alt Validation fails
CLI->>User: Error: token is required
else Validation passes
CLI->>Systemd: InstallRelaySystemdService(token, ...)
Systemd->>FS: Write /etc/infisical/relay.conf
Note over Systemd,FS: Includes token config
Systemd->>FS: Write /etc/systemd/system/infisical-relay.service
Systemd->>CLI: Success
CLI->>User: Successfully installed
end
Additional Comments (1)
-
packages/relay/systemd.go, line 74 (link)style: hardcoded string should use constant
gatewayv2.INFISICAL_TOKEN_ENV_NAMEfor consistency
2 files reviewed, 1 comment
x032205
approved these changes
Oct 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description 📣
This PR adds ENV parsing of token value for org relay in systemd install
Type ✨
Tests 🛠️
# Here's some code block to paste some code snippets