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

Fix 'xargs: command line too long' in SOPS encryption task #1594

Merged
merged 4 commits into from
Oct 7, 2024
Merged

Fix 'xargs: command line too long' in SOPS encryption task #1594

merged 4 commits into from
Oct 7, 2024

Conversation

cypr0
Copy link
Contributor

@cypr0 cypr0 commented Oct 7, 2024

Problem:

The SOPS encryption task was failing with the error "command line too long" when processing many files using xargs. This happened because the number of files found by find exceeded the system's command-line length limit.

Solution:

  • Replaced xargs with a while read -r loop to process each file individually, avoiding command length limits.

  • Relocated existing precondition checks in the encryption task.

Changes:

  • Added shell checks for the SOPS configuration and Age key file at the beginning of the encryption task.

  • Replaced the xargs command with a while loop to handle file encryption without exceeding command-line length limitations.

This PR fixes the command line limit issue while retaining the original precondition checks to ensure all necessary files are present before encryption.

Comment on lines 16 to 23
if [ ! -f {{.SOPS_CONFIG_FILE}} ]; then
echo "Missing Sops config file"
exit 1
fi
if [ ! -f {{.AGE_FILE}} ]; then
echo "Missing Sops Age key file"
exit 1
fi
Copy link
Owner

@onedr0p onedr0p Oct 7, 2024

Choose a reason for hiding this comment

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

These can be added to preconditions on the task.

@onedr0p onedr0p merged commit c664007 into onedr0p:main Oct 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants